MyBB Community Forums

Full Version: [F] Error adding Warn Points.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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
Yeah! The bug is fixed with this replace. Thanks ^^
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
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