MyBB Community Forums
[F] Error adding Warn Points. - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: Archived Bug Reports (https://community.mybb.com/forum-74.html)
+------ Forum: MyBB 1.4.4 (https://community.mybb.com/forum-110.html)
+------ Thread: [F] Error adding Warn Points. (/thread-45959.html)



[F] Error adding Warn Points. - Ryu.Hack - 03-01-2009

Hello, I found this error adding Warn Points:

SQL Error:
    1364 - Field 'revokereason' doesn't have a default value
Query:
    INSERT INTO mybb_warnings (`uid`,`tid`,`pid`,`title`,`points`,`dateline`,`issuedby`,`expires`,`expired`,`notes`) VALUES ('2','3','20','','10','1235899865','1','1236504665','0','Demasiado flood xd')

And the system dont add the Warning Points. What I do need for resolve this problem?

Thanks in Advanced.


RE: Error adding Warn Points. - dvb - 03-01-2009

When I'm trying to export the structure of "warnings" I'm receiving this:
CREATE TABLE IF NOT EXISTS `prefix_warnings` (
  `wid` int(10) unsigned NOT NULL auto_increment,
  `uid` int(10) unsigned NOT NULL default '0',
  `tid` int(10) unsigned NOT NULL default '0',
  `pid` int(10) unsigned NOT NULL default '0',
  `title` varchar(120) NOT NULL default '',
  `points` int(10) unsigned NOT NULL default '0',
  `dateline` bigint(30) NOT NULL default '0',
  `issuedby` int(10) unsigned NOT NULL default '0',
  `expires` bigint(30) NOT NULL default '0',
  `expired` int(1) NOT NULL default '0',
  `daterevoked` bigint(30) NOT NULL default '0',
  `revokedby` int(10) unsigned NOT NULL default '0',
  `revokereason` text NOT NULL,
  `notes` text NOT NULL,
  PRIMARY KEY  (`wid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;
So as you can see the fields revokereason & notes really doesn't have a default value (while still "NOT NULL") but I can't reproduce that...
My test doesn't show any error and the points given.

----

After some more testing I've found that this is related to the 'strict mode', in my board I'm receiving just a warning from mysql (I'm not in 'strict mode')

The code that cause this error is:
warnings.php, lines 235-247 Wrote:
		$new_warning = array(
			"uid" => $user['uid'],
			"tid" => intval($warning_type['tid']),
			"pid" => intval($post['pid']),
			"title" => $db->escape_string($warning_title),
			"points" => intval($points),
			"dateline" => TIME_NOW,
			"issuedby" => $mybb->user['uid'],
			"expires" => $warning_expires,
			"expired" => 0,
			"notes" => $db->escape_string($mybb->input['notes'])
		);
		$db->insert_query("warnings", $new_warning);

Possible fix, replace with:
		$new_warning = array(
			"uid" => $user['uid'],
			"tid" => intval($warning_type['tid']),
			"pid" => intval($post['pid']),
			"title" => $db->escape_string($warning_title),
			"points" => intval($points),
			"dateline" => TIME_NOW,
			"issuedby" => $mybb->user['uid'],
			"expires" => $warning_expires,
			"expired" => 0,
			"revokereason" => '',
			"notes" => $db->escape_string($mybb->input['notes'])
		);
		$db->insert_query("warnings", $new_warning);
I've just added:
            "revokereason" => '',

----

A note to the developers!
When you're fixing this bug, don't forget to also fix the installer with a default value to prevent new similar bugs


RE: Error adding Warn Points. - Ryu.Hack - 03-01-2009

Yeah! The bug is fixed with this replace. Thanks ^^


[F] Error adding Warn Points. - Ryan Gordon - 03-04-2009

Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

With regards,
MyBB Group


RE: [F] Error adding Warn Points. - Cry-Frodo Baggins - 04-13-2009

I tried this fix and it still doesn't work for me. Can someone please attach their warnings file so that I can upload it?

Thanks