When you are creating a new revision, if you leave log field empty then MySQL5 gives error about log field and you cannot access that node again. We need to handle this like we do for new nodes.

CommentFileSizeAuthor
create_new_revision_mysql5.patch917 byteserdemkose

Comments

dries’s picture

Can someone reproduce this?

Zen’s picture

Priority: Critical » Normal

Cannot reproduce with PHP 5 & MySQL 5. Please make sure that you have a clean install of HEAD.

-K

erdemkose’s picture

I may be missing something so please take a look at the video.

http://erdemkose.com/files/drupal6revisionbug.htm

webchick’s picture

Priority: Normal » Critical

Um. Wow. Yeah, I'd call that critical. ;)

Video shows a clean install using MySQLi from HEAD checked out of CVS. A page is created with two revisions, each with an empty log message (the "Create new revision" checkbox is checked manually for revision 2).

On the second revision, the error pops up:

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, 'revision 2', 'revision 1....)

And the page, which would normally be the node, says "Access denied." Upon clicking back to the home page, there's simply "n/a" and dozens of notices about there being undefined properties. Um. Oops. ;)

Using PHP 5.1.6, MySQL 5.0.26, Apache 2.0.59 on Win32.

Now, with that all said, I could not duplicate this on PHP 5.1.4, MySQL 5.0.19, and Apache 2.0.55 on Mac OS X (MAMP). :(

erdemkose’s picture

Title: Create new revision fails - No default value for log field » Create new revision fails - No default value for log field - MySQL Strict Mode

I think I should explicitly say that this is about SQL Mode of MySQL. My installation has Strict mode On, if your mysql server runs in normal mode then you won't get the same errors.

Please run "SELECT @@sql_mode" query on your mysql server and if it doesn't return one of the "TRADITIONAL, STRICT_TRANS_TABLES, or STRICT_ALL_TABLES" modes then it means strict mode is not enabled on your server.

I will quit assuming MySQL5 means MySQL Strict Mode. I am sorry for wasting your time. Can you retry with Strict mode On? If it cannot be reproduced again then I will search the reason in my mind :)

Zen’s picture

Title: Create new revision fails - No default value for log field - MySQL Strict Mode » Create new revision fails - No default value for log field

Maybe it's Windows specific?

The following works for me:

CREATE TABLE test (
  a tinyint(3) unsigned NOT NULL auto_increment,
  b longtext NOT NULL,
  PRIMARY KEY  (a)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

INSERT INTO test (a, b) VALUES (1, '');
INSERT INTO test (a) VALUES (2);

erdemkose, could you please test the above?

My specifics: Apache/2.0.55 (Ubuntu) DAV/2 SVN/1.3.2 PHP/5.1.6 + MySQL 5.0.24a.

Also, the code for D5 is pretty much the same. Could you please also try replicating this on D5?

As for the patch, if it is needed, it might be cleaner to just initialise the log field via the two arrays above the block of code in the patch in #1.

Cheers,
-K

Zen’s picture

Title: Create new revision fails - No default value for log field » Create new revision fails - No default value for log field - MySQL Strict Mode

Cross-post.

Zen’s picture

This appears to be a duplicate of http://drupal.org/node/100850 which seems to have partially fixed the issue.

-K

erdemkose’s picture

Yeah, I know this bug exists in Drupal 5, too. It may exists in 4.7.x, but I thought that we should backport the fix.

I searched the active issues but not the closed ones. Yes, if it was active then mine would be a duplicate of it. Can you reproduce the bug in strict mode? Does the patch fix it?

erdemkose’s picture

Status: Needs review » Closed (duplicate)
erdemkose’s picture

Status: Closed (duplicate) » Closed (fixed)
kristen pol’s picture

I'm confused. The posts about this issue say that it is fixed with these patches. I see drupal 5 patches, but nothing for drupal 6. I see this problem on a wamp installation but not on my linux machine, but it appears that the linux mysql is not using strict and the wamp mysql is.

So, is the solution to this issue to *not* run strict? That doesn't seem like a good solution.

I just tried to modify my column to have a default value of '' and got this:

BLOB/TEXT column 'log' can't have a default value

So, either I can allow null or turn off strict or ???

damien tournoud’s picture

kristen pol’s picture

Thanks! But, it appears to be a patch for drupal 6.4 (?). I just updated to 6.10. Will I need to replicate the changes? Why didn't this get into the drupal 6 after this issue has been floating around for years? I'll dig into it right now... thanks again.

....

I just started comparing the patch against 6.10 and some of the code is in there... perhaps all of it. It's hard to compare. Perhaps I will just turn off strict and not worry about it.

....

We turned of strict and it's fine. I'm too tired to figure out how to patch it.