Site gone Wonky when enabling "Create New Revision" on Page Content Type

spjsche - January 5, 2007 - 22:16
Project:Drupal
Version:5.1
Component:other
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

I have the following =>

Drupal 5.0-RC-1
Configuration file Protected
Cron maintenance tasks Last run 2 hours 30 min ago
You can run cron manually.
Database schema Up to date
File system Writable (private download method)
GD library bundled (2.0.28 compatible)
MySQL database 5.0.22
PHP 5.2.0
Unicode library PHP Mbstring Extension
Web server Apache/2.2.3 (Win32) mod_ssl/2.2.3 OpenSSL/0.9.8d mod_auth_sspi/1.0.4 PHP/5.2.0

My testing for porting my 4.7.3 site to 5.0 (when it is released) has been going well, but, I have just enabled "Create New Revision" for the Page content type, and now I get this PHP error whenever I try to submit an existing edited Page.

The error is =>

Field 'log' doesn't have a default value query: INSERT INTO node_revisions (nid, vid, title, body, teaser, timestamp, uid, format) VALUES (113, 116, 'Revision Test 1', 'Testing revisions 1\r\nI have added a new line.', 'Testing revisions 1\r\nI have added a new line.', 1168029617, 1, 2) in D:\Web-AMP\Apache2\htdocs\drupalv5\includes\database.mysql.inc on line 167.

Now whenever I try to view that node it just displays the original "Welcome to your new Drupal website!" page.
I have disabled the "Create New Revision" for the Page content type, and have tried to delete the relevant node, but to no avail.

I have tried to search for an answer, but I have had no success.

I can restore from my backup, but I will leave it for a while just incase you need any further info.

#1

m3avrck - January 5, 2007 - 23:12

I cannot reproduce this on the last 5.x build.

#2

RobRoy - January 5, 2007 - 23:16

Looks like the MySQL STRICT mode bug which has been fixed in the 5.x-dev version. Please test with that version or wait for the next release.

#3

spjsche - January 6, 2007 - 00:07

Thanks for the response, I will download the dev version and reply accordingly.

#4

spjsche - January 6, 2007 - 02:02

Just installed a vanilla version of the 5.x Dev release.
All goes well, until I try to enable the locale, search, throttle and upload modules, I proceed to do an update.php from the modules page, and I get the following error displayed.

An HTTP error 401 occured. update.php?op=do_update.

and the logs report =>

reset() [function.reset]: Passed variable is not an array or object in D:\Web-AMP\Apache2\htdocs\drupalv5\update.php on line 521.

This has never happened before now.

#5

spjsche - January 6, 2007 - 14:29

I have just reverted to 5.x rc1, and the above does not happen.

#6

spjsche - January 6, 2007 - 14:31

Sorry, I was not explicit enough.

By above, I mean.

An HTTP error 401 occured. update.php?op=do_update.

and the logs report =>

reset() [function.reset]: Passed variable is not an array or object in D:\Web-AMP\Apache2\htdocs\drupalv5\update.php on line 521.

#7

larrychu - February 21, 2007 - 00:53

I'm getting this error on a clean drupal 5.1 install with:
Apache 2.2
PHP 5.2
MySQL 5.0.27

Details of the 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, 2, 'test', 'test', 'test', 1172018726, 1, 1) in C:\tools\Apache2.2\htdocs\drupal-5.1\includes\database.mysql.inc on line 172.

Steps to reproduce:
-Install drupal 5.1, create database, configure drupal, create user #1
-Create a page, check the "create new revision" checkbox before submitting
-Edit the page, check the "create new revision" checkbox before submitting
-Error appears, page is gone.

The log column is conspicuously missing from the insert statement, and does not have a default value (in the create table statement).

#8

larrychu - February 21, 2007 - 00:56
Version:5.0-rc1» 5.1

This is happening on 5.1.

#9

larrychu - February 21, 2007 - 06:52
Status:active» needs review

All this is caused by the update to {node} table vid column and a failed insert of corresponding {node_revision} row.

Since the log column does not have a default value, it should always be inserted during an insert.

in node.module:

  if (!empty($node->log) || $node->is_new) {
    // Only store the log message if there's something to store; this prevents
    // existing log messages from being unintentionally overwritten by a blank
    // message. A new revision will have an empty log message (or $node->log).
    $revisions_table_values['log'] = $node->log;
    $revisions_table_types['log'] = "'%s'";
  }

When $node->log is empty, the $revisions_table_types['log'] will never get a value, thus it will never get inserted. I think you need to write a value all the time so it should have additional logic in an else block like this:
  else {
    $revisions_table_values['log'] = ''; // empty string value
    $revisions_table_types['log'] = "'%s'";
  }

I tested this with a page node.

#10

larrychu - February 23, 2007 - 20:11

Here is the patch against head. I'm not actually able to confirm whether it works in head which is why I will also attach a patch against 5.1 after this.

AttachmentSizeStatusTest resultOperations
node_module_head.patch621 bytesIgnoredNoneNone

#11

larrychu - February 23, 2007 - 20:12

Here is the patch against 5.1

AttachmentSizeStatusTest resultOperations
node_module_51.patch632 bytesIgnoredNoneNone

#12

larrychu - February 23, 2007 - 20:34

Sorry, my previous patch wasn't from root. Here is a patch from root against HEAD.

AttachmentSizeStatusTest resultOperations
node_module_head_1.patch846 bytesIgnoredNoneNone

#13

drumm - March 7, 2007 - 03:45
Status:needs review» needs work

Can we remove the if statement and always do

<?php
    $revisions_table_values
['log'] = $node->log;
   
$revisions_table_types['log'] = "'%s'";
?>

and modify the comment. It seems like an irrelevant holdover from before we refactored the revisions system.

#14

terrencewood - March 11, 2007 - 21:35

Why not just modify the node_revisions table to accept null values for the log column?

#15

lsabug - July 16, 2007 - 17:08

Should I apply this patch to my 5.1 version? It's still coming up as an issue using Firefox and IE.

 
 

Drupal is a registered trademark of Dries Buytaert.