Advertisement:

Author Topic: Field 'id_reporter' doesn't have a default value  (Read 1166 times)

Offline videoed

  • Jr. Member
  • **
  • Posts: 174
  • Gender: Male
  • Ramón Cutanda
    • videoedicion.org
Field 'id_reporter' doesn't have a default value
« on: March 21, 2019, 05:51:06 PM »
I have recently upgraded from 2.0.15 to 2.1 RC1. The report funcion doesn't work. I get this error:
Code: [Select]
Field 'id_reporter' doesn't have a default value
File: /var/www/vhosts/videoedicion.org/httpdocs/foro/Sources/ReportToMod.php
Line: 303
In my ReportToMod.php line 303 is the number "1" almost at the end of this function. So no clues for me...


Code: [Select]
    // Otherwise, we shall make one!
    else
    {
        if (empty($message['real_name']))
            $message['real_name'] = $message['poster_name'];

        $id_report = $smcFunc['db_insert']('',
            '{db_prefix}log_reported',
            array(
                'id_msg' => 'int', 'id_topic' => 'int', 'id_board' => 'int', 'id_member' => 'int', 'membername' => 'string',
                'subject' => 'string', 'body' => 'string', 'time_started' => 'int', 'time_updated' => 'int',
                'num_reports' => 'int', 'closed' => 'int',
            ),
            array(
                $_POST['msg'], $message['id_topic'], $message['id_board'], $message['id_poster'], $message['real_name'],
                $message['subject'], $message['body'], time(), time(), 1, 0,
            ),
            array('id_report'),
            1
        );
    }


Any help with this?

Thanks!

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,305
Re: Field 'id_reporter' doesn't have a default value
« Reply #1 on: March 21, 2019, 11:34:35 PM »
It's a mysql bug.  Assign a default value of "Null" to the field, that should fix it.

Offline albertlast

  • Development Contributor
  • Full Member
  • *
  • Posts: 589
Re: Field 'id_reporter' doesn't have a default value
« Reply #2 on: March 22, 2019, 12:04:56 AM »
Look like a real bug,
So  don't do the null thing,
What sir osis  says.

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,305
Re: Field 'id_reporter' doesn't have a default value
« Reply #3 on: March 22, 2019, 12:21:05 AM »
Is that '1' a stray character?

Offline albertlast

  • Development Contributor
  • Full Member
  • *
  • Posts: 589
Re: Field 'id_reporter' doesn't have a default value
« Reply #4 on: March 22, 2019, 12:26:19 AM »
this is the new way in 2.1 to get the ai value from ai field while inserting:
https://github.com/SimpleMachines/SMF2.1/blob/release-2.1/Sources/Subs-Db-mysql.php#L725

Offline albertlast

  • Development Contributor
  • Full Member
  • *
  • Posts: 589
Re: Field 'id_reporter' doesn't have a default value
« Reply #5 on: March 22, 2019, 12:31:24 AM »
Well i checked the code for upgrade,
ther it's look fine.

So it look like the problem only exists on your side,
you can fixit by altering the id_report to auto_increment field.

Offline videoed

  • Jr. Member
  • **
  • Posts: 174
  • Gender: Male
  • Ramón Cutanda
    • videoedicion.org
Re: Field 'id_reporter' doesn't have a default value
« Reply #6 on: March 22, 2019, 02:33:45 AM »
My table already had the auto_increment value so, considering that table was empty, I dropped it and recreated it using the template from the install_2-1_mysql.sql file included in the full install package. That solved the problem :-)

Thanks for the help!

Offline videoed

  • Jr. Member
  • **
  • Posts: 174
  • Gender: Male
  • Ramón Cutanda
    • videoedicion.org
Re: Field 'id_reporter' doesn't have a default value
« Reply #7 on: March 28, 2019, 11:07:11 AM »
The report worked in my testings, but it broke again. Because the error message complains of not having a "default" value, I added a NULL default value in the table. Now I have tried with more than a dozen reports and everything seems to be working normally.

Thanks,

Offline albertlast

  • Development Contributor
  • Full Member
  • *
  • Posts: 589
Re: Field 'id_reporter' doesn't have a default value
« Reply #8 on: March 28, 2019, 01:20:03 PM »
Well this make no sense,
since it's pk with ai,
the error should not happen.

Would be better when you show us your table structur instead of doing wrong things.

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,305
Re: Field 'id_reporter' doesn't have a default value
« Reply #9 on: March 28, 2019, 04:53:19 PM »
Does 2.1 code address the mysql bug?  This has been a recurring problem in 2.0.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,642
    • StoryBB/StoryBB on GitHub
Re: Field 'id_reporter' doesn't have a default value
« Reply #10 on: March 28, 2019, 04:57:24 PM »
Does 2.1 code address the mysql bug?  This has been a recurring problem in 2.0.


It's not a bug, it's MySQL finally working to spec.

And no, 2.1 doesn't address it, it forces the same behaviour on everyone, including people who previously avoided it. Maybe mod authors will get their **** together and do it properly from the start this time.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,305
Re: Field 'id_reporter' doesn't have a default value
« Reply #11 on: March 28, 2019, 05:11:20 PM »
So then, adding 'Null' to the field to fix the problem is not 'doing wrong things', is it?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,642
    • StoryBB/StoryBB on GitHub
Re: Field 'id_reporter' doesn't have a default value
« Reply #12 on: March 28, 2019, 05:16:56 PM »
So then, adding 'Null' to the field to fix the problem is not 'doing wrong things', is it?


To a column that is explicitly designed to not receive values from the user and to generate them on demand would appear to be the wrong thing.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,305
Re: Field 'id_reporter' doesn't have a default value
« Reply #13 on: March 28, 2019, 05:23:21 PM »
That's been the recommended fix here for some time, and afaik it's worked in all instances.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,642
    • StoryBB/StoryBB on GitHub
Re: Field 'id_reporter' doesn't have a default value
« Reply #14 on: March 28, 2019, 05:44:01 PM »
Yes, except for when the column is autoincrement like this one is.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,305
Re: Field 'id_reporter' doesn't have a default value
« Reply #15 on: March 28, 2019, 05:49:47 PM »
What effect does it have?  If field starts out with no value, or 'null' value, won't it still auto increment to '1' on first use?  After that it would no longer matter.

Offline albertlast

  • Development Contributor
  • Full Member
  • *
  • Posts: 589
Re: Field 'id_reporter' doesn't have a default value
« Reply #16 on: March 28, 2019, 06:01:44 PM »
Very important point what this here make differently to all other similiar issues,
this is here a smf field, exists since 2.0.x,
so it's not a mod field.

Secondly this field in this table is pk,
pk are not allowed to be null -> this fields can't be null able, when everything is setup in the right way.

Third in the 2.0 and 2.1 setup is this field defined as pk with ai,
so this issue shouldn't exists.

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,305
Re: Field 'id_reporter' doesn't have a default value
« Reply #17 on: March 28, 2019, 06:05:18 PM »
Well, apparently it worked for OP.  Will it break something else?

Offline videoed

  • Jr. Member
  • **
  • Posts: 174
  • Gender: Male
  • Ramón Cutanda
    • videoedicion.org
Re: Field 'id_reporter' doesn't have a default value
« Reply #18 on: March 28, 2019, 06:06:33 PM »
I am not a coder or a developer. I have a VERY limited understanding of PHP or MySQL and you can take for granted that I don't really know what I am doing.

I tried to set the field as auto_increment, as suggested. But I get this error:

Code: [Select]
#1075 - Incorrect table definition; there can be only one auto column and it must be defined as key
Then I just followed the "instructions" of the error message. If the system complaints about not having a "default" value... well.. I just tried that. To set a default value. As a "non-coder" user that made perfect sense to me. And the thing is that it works... Why? I have NO IDEA; but it works and I just wanted to share.

If you have any other suggestion to make my reports work or give me a reason not to set NULL as the default value (security risk, possible data corruption...) then sure I will follow your advice.

Thank you for all your contributions and interest in this matter.

Bests,

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,305
Re: Field 'id_reporter' doesn't have a default value
« Reply #19 on: March 28, 2019, 06:14:40 PM »
Sadly, I don't have id_reporter field in smf_log_reported. :(

Offline albertlast

  • Development Contributor
  • Full Member
  • *
  • Posts: 589
Re: Field 'id_reporter' doesn't have a default value
« Reply #20 on: March 28, 2019, 06:15:05 PM »
What is the primary key at the moment in this table?

Well, apparently it worked for OP.  Will it break something else?
in the worst case the table got no pk atm,
than no index stuff is working(mysql use pk index as primary index for his other indexes) and since it got no pk,
any pk related call goes wild,
so yes it's hurt.

Offline albertlast

  • Development Contributor
  • Full Member
  • *
  • Posts: 589
Re: Field 'id_reporter' doesn't have a default value
« Reply #21 on: March 28, 2019, 06:18:00 PM »
in the setup file of 2.0 you find this column:
Code: [Select]
CREATE TABLE {$db_prefix}log_reported (
  id_report mediumint(8) unsigned NOT NULL auto_increment,
  id_msg int(10) unsigned NOT NULL default '0',
  id_topic mediumint(8) unsigned NOT NULL default '0',
  id_board smallint(5) unsigned NOT NULL default '0',
  id_member mediumint(8) unsigned NOT NULL default '0',
  membername varchar(255) NOT NULL default '',
  subject varchar(255) NOT NULL default '',
  body text NOT NULL,
  time_started int(10) NOT NULL default '0',
  time_updated int(10) NOT NULL default '0',
  num_reports mediumint(6) NOT NULL default '0',
  closed tinyint(3) NOT NULL default '0',
  ignore_all tinyint(3) NOT NULL default '0',
  PRIMARY KEY (id_report),
  KEY id_member (id_member),
  KEY id_topic (id_topic),
  KEY closed (closed),
  KEY time_started (time_started),
  KEY id_msg (id_msg)
) ENGINE=MyISAM;

2.1 is similiar:
Code: [Select]
CREATE TABLE {$db_prefix}log_reported (
id_report MEDIUMINT UNSIGNED AUTO_INCREMENT,
id_msg INT(10) UNSIGNED NOT NULL DEFAULT '0',
id_topic MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
id_board SMALLINT UNSIGNED NOT NULL DEFAULT '0',
id_member MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
membername VARCHAR(255) NOT NULL DEFAULT '',
subject VARCHAR(255) NOT NULL DEFAULT '',
body MEDIUMTEXT NOT NULL,
time_started INT(10) NOT NULL DEFAULT '0',
time_updated INT(10) NOT NULL DEFAULT '0',
num_reports MEDIUMINT NOT NULL DEFAULT '0',
closed TINYINT NOT NULL DEFAULT '0',
ignore_all TINYINT NOT NULL DEFAULT '0',
PRIMARY KEY (id_report),
INDEX idx_id_member (id_member),
INDEX idx_id_topic (id_topic),
INDEX idx_closed (closed),
INDEX idx_time_started (time_started),
INDEX idx_id_msg (id_msg)
) ENGINE={$engine};

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,305
Re: Field 'id_reporter' doesn't have a default value
« Reply #22 on: March 28, 2019, 06:35:24 PM »
Maybe I'm missing something, but original post displays error for id_reporter.  There is no id_reporter field in _log_reported, or in the code you posted.

I have recently upgraded from 2.0.15 to 2.1 RC1. The report funcion doesn't work. I get this error:
Code: [Select]
Field 'id_reporter' doesn't have a default value
File: /var/www/vhosts/videoedicion.org/httpdocs/foro/Sources/ReportToMod.php
Line: 303

Online shawnb61

  • Developer
  • SMF Hero
  • *
  • Posts: 1,433
    • sbulen on GitHub
Re: Field 'id_reporter' doesn't have a default value
« Reply #23 on: March 28, 2019, 06:39:00 PM »
Yes, I'd been thinking this column was added by a mod all this time.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Offline albertlast

  • Development Contributor
  • Full Member
  • *
  • Posts: 589
Re: Field 'id_reporter' doesn't have a default value
« Reply #24 on: March 28, 2019, 06:54:58 PM »
okay... than you can proceed with the default solution...

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,642
    • StoryBB/StoryBB on GitHub
Re: Field 'id_reporter' doesn't have a default value
« Reply #25 on: March 28, 2019, 07:01:31 PM »
Here was me thinking you'd checked the schema and it should be PK/AI :P (I don't remember enough of the schema any more, I have my own that's quite a bit different)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Online shawnb61

  • Developer
  • SMF Hero
  • *
  • Posts: 1,433
    • sbulen on GitHub
Re: Field 'id_reporter' doesn't have a default value
« Reply #26 on: March 28, 2019, 07:15:05 PM »
videoed -

It may help if you post the db structure for the table in question.  You can either export it from phpmyadmin or take a screenshot.

Thx,

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Offline videoed

  • Jr. Member
  • **
  • Posts: 174
  • Gender: Male
  • Ramón Cutanda
    • videoedicion.org
Re: Field 'id_reporter' doesn't have a default value
« Reply #27 on: March 29, 2019, 11:38:49 AM »
First of all, I really want to thank all the people involved in this thread. I REALLY APPRECIATE your dedication. It has been my fault all the time. I am really sorry. This is what finally made me realise what has been going on all of this time:

Maybe I'm missing something, but original post displays error for id_reporter.  There is no id_reporter field in _log_reported, or in the code you posted.

1. Before I moved to 2.1 RC1 I was using the mod you will find attached.

2. That mod added the "id_reporter" field described in this error.

3. That mod no longer works on SMF 2.1 RC1 and, when uninstalling, it DOES NOT REMOVE the added "id_reporter" field that triggers the error that initiated this thread.

When I recreated the table using the template from the original installer I solved the problem. But I have been facing several problems with my most needed mods after upgrading to SMF 2.1 RC1, so I have been installing/uninstalling mods frequently and in different order just to check if I could make them work. At some point, I must have tried to reinstall the "report mod" again, recreating the problem.
I am sorry for not having made that association any sooner and causing all this trouble. I really appreciate your interest in this matter.

All the best,

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,502
  • Gender: Male
    • Kindred-999 on GitHub
Re: Field 'id_reporter' doesn't have a default value
« Reply #28 on: March 29, 2019, 11:44:39 AM »
yes, traditionally, mods do not remove created tables or columns on uninstall -- unless the author has properly built the mod to give you the option (which most mod authors do not do) -- and even then, it does so only if you specifically tell it to do so.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.