Closed (fixed)
Project:
Drupal core
Version:
6.9
Component:
node system
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
1 Dec 2006 at 18:03 UTC
Updated:
18 Feb 2009 at 12:45 UTC
Jump to comment: Most recent file
After the installation, at the very first page added i receive this message:
user warning: Field 'log' doesn't have a default value query: INSERT INTO node_revisions (nid, vid, title, body, teaser, timestamp, uid, format) VALUES (1, 1, 'ertert', 'terterter\r\ntertert', 'terterter\r\ntertert', 1164995568, 1, 1) in C:\www\drupal-5\includes\database.mysql.inc on line 167.
And the resource does not show anymore.
The field log should be set NULL or an empty string should be set as default value in the insert sql string.
Mysql 5.0.21
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | node_revision_log_default_6x.patch.txt | 1.18 KB | dww |
| #30 | revisions_empty_log_edit.patch.txt | 921 bytes | dww |
| #19 | revisions_empty_log_for_mysql5_strict.patch_0.txt | 871 bytes | webchick |
| #9 | revisions_empty_log_for_mysql5_strict.patch.txt | 1.24 KB | dww |
Comments
Comment #1
serval-1 commentedIs it possible you are running MySQL 5 in strict mode?
See http://drupal.org/node/43316 for more info.
Comment #2
Jo Wouters commentedIs there a reason why not all columns have a default value ?
I can write a patch to add default values..
Comment #3
pwolanin commentedseems the right thing to make it strict-mode compatible if it's not hard to do.
Comment #4
ChrisKennedy commentedThis error is caused by running MySQL 5 in strict mode.
BLOB/TEXT fields cannot have default values (see http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html).
Inserting a blank string seems to mess up the revision log, so maybe we should insert a NULL instead.
Comment #5
webchickThat comment is referring to a crazy bug dww found:
- If revisions are turned off for a node type...
- And there was a pre-existing revision log....
- And you edit the node and submit it again, leaving the message blank...
- Then, the existing message in database gets overwritten with a blank value.
So we need some way to have that NOT happen, but also fix this problem for strict mode compliance.
Comment #6
pwolanin commented@webchick - the behavior you describe actually sounds correct. If I edit a node and put no log message, why would the old message still be relevant?
Comment #7
webchickBecause chances are you didn't erase the node log message, but rather just left it alone (it defaults to blank).
Maybe the solution is if the node has revisions turned off, then make the log message default to whatever is the log message in the database; else default to nothing (since it's really bloody annoying when you're using the node revisions system as intended and you need to erase the old log message before inputting a new one as you had to do in 4.6), and get rid of that extra logic in the SQL building stuff.
Comment #8
webernet commentedWhat would happen if we always appended a space to the end of the log field every time it gets saved?
Comment #9
dww*sigh* using the previously entered log message by default is a bug: http://drupal.org/node/39124
how's this?
Comment #10
webernet commentedMakes sense to me. Tested it and it appears to be working properly.
Hopefully someone can test it under strict mode to confirm it fixes the warning.
Comment #11
dwwthe old title made it seem like we were talking about the UI, in which case we're back to http://drupal.org/node/39124. just want to make it clear the bug here is at the SQL layer...
Comment #12
Chill35 commentedI have that bug on my system.
Description of my testing server : Windows XP, SP 2, Apache 2.0.59, PHP 5.1.4, MySQL 5.0.
I installed the beta 2 version from scratch. With a new database.
When I publish content, such as a "page", I get this message :
user warning: Field 'log' doesn't have a default value query: INSERT INTO node_revisions (nid, vid, title, body, teaser, timestamp, uid, format) VALUES (2, 2, 'Hello', 'blabla', 'blabla', 1165305156, 1, 1) in F:\htdocs\drupal-5.0-beta2\includes\database.mysql.inc on line 167.
Why is that a NEW bug ?
I have verion 5 beta 1 and version 4.7.4 working perfectly with mySQL set up the way it is now. Only beta 2 won't work.
How do I know if I am using MySQL in strict mode ? What is "strict mode" ?
It's not the only issue I have.
When I install beta 2 I get tons of warning messages. Then when I close the browser and reopen drupal I get the Welcome screen and I am able to register my admin and start off - but when I add content it does not work, as stated.
Comment #13
Chill35 commentedWhen I install I get this page of warnings (although the installation is said to be succesful) :
Comment #14
heine commented@Chill35: please open a seperate bug report for:
Thanks.
Comment #15
Chill35 commentedOk I did, Heine : http://drupal.org/node/101421
Tanks.
Comment #16
Chill35 commenteddww,
I am not sure if I DO run Mysql strict or not, do not know how to check that.
I installed the patch and it solved the problem. I am now able to create content that displays. (And no warning message when I create said content.)
Thanks.
I changed the status to RTBC, please change it back if you feel it needs more reviewing.
Comment #17
dries commentedI find it strange that we have to use this technique. At other places in the code, this doesn't appear to be a problem. I wonder why that is.
When $revisions_table_values['log'] is empty, $revisions_table_types['log'] = "'%s'" should become $revisions_table_types['log'] = "''" which appears to be valid SQL, not?
Comment #18
webchickDries: The reason this is a problem here is that currently, appending log to the SQL string is in a conditional because of the bug described @ #5. We only want to add log to the SQL query when there's something to save.
However, new nodes when inserted always need to insert a value to get around strict mode compliance. Hence the addition of the $node->is_new check.
Comment #19
webchickOh hold on. Do you mean just this?
Could someone affected by this bug try this patch?
Comment #20
dwwif that works for php5, even better. i've noticed that some of the code i used to generate causes warnings/errors on php5 (my test sites are all php4), and i don't have a mysql5/strict test site, either. so, i was just coding extra defensively, since i was basically operating in the dark. ;) but, if that's all bloat, and webchick's more simple patch (with the same basic logic: always include 'log' in the SQL if it's a new entry) causes no warnings, all the better.
thanks,
-derek
Comment #21
dwwi guess we should bump this back to needs review, pending confirmation that the smaller patch still works in all configurations.
Comment #22
drewish commented+1, this clears the issue up for me on PHP5.2
Comment #23
webernet commentedTested under strict mode - works for me as well.
FYI - Here's some info on how to activate/deactivate MySQL strict mode.
Comment #24
webchickHey thanks for that, webernet!
Would you mind putting that in the handbook somewhere? Maybe in the setting up a test environment page?
Comment #25
heine commentedComment #26
dries commentedCommitted to CVS. Thanks.
Comment #27
(not verified) commentedComment #28
litwol commentedi would like to open this issue again.
i just updated mysql from 4.1 to 5.0.27 and i began getting error messages becuase my sql mode is STRICT_TRANS_TABLES
the issue was easily fixed by making log to default to 'null' if nothing is passed.
the issue should be looked into more thoroughly because i see drupal has tendencies to store only the information that it is being passed, so without default values in the DB it will then fail. having drupal 'discover' which fields it must provide will allow it to populate some default fields.
Comment #29
dwwok, after clarification in IRC, this is indeed a bug. there's 1 case in the logic in node.module we missed: empty log message, new revision, editing an existing node. easy fix. patch coming momentarily, stay tuned.
Comment #30
dwwthis should fix it. applies cleanly to DRUPAL-5 and with offset to HEAD.
Comment #31
litwol commented+1, i tested it on my site and everything worked great: RTBC
Comment #32
litwol commented+1, i tested it on my site and everything worked great: RTBC
Comment #33
dries commentedCommitted to CVS HEAD. Needs to go into DRUPAL-5, Neil.
Comment #34
dwwoh, and while we're on the topic... ;) how about we sync the mysql and pgsql schemas in this regard and give log a default off '' on mysql, just like we've had on pgsql since at least 4.7.x (that's as far back as i cared to check)? patch for HEAD (6.x) only, since a schema change is obviously out of the question for 5.x.
@drumm: patch #30 is for DRUPAL-5
@dries: how about this one for HEAD?
thanks folks,
-derek
Comment #35
webchick@dww, because afaik you can't give default values to TEXT fields: http://dev.mysql.com/doc/refman/5.1/en/blob.html
"BLOB and TEXT columns cannot have DEFAULT values."
Comment #36
dwwweird, when i ran my proposed update, mysql didn't give any warnings or errors at all. :( *sigh* alas. oh well, i guess forget about #34 then, and we should leave all the code to specify log in the query corrrectly.
so, all we need here is #30 committed to DRUPAL-5.
thanks,
-derek
Comment #37
drummCommitted to 5.
Comment #38
(not verified) commentedComment #39
provinciadicuneo commentedI have the same problem on my "team editors." I solved this problem, when allowed to "administer nodes" for this role (my "team editor") on admin/ user/permissions.
This does not allow me to create hidden pages for the role "team editor". Indeed, the group "team editor" shows all the pages.
Someone knows how can I fix it?