Closed (duplicate)
Project:
Drupal core
Version:
7.x-dev
Component:
node system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
15 Apr 2009 at 17:12 UTC
Updated:
5 Dec 2013 at 11:02 UTC
Jump to comment: Most recent
Comments
Comment #1
yched commentedNot related to CCK: CCK doesn't handle the node body 'field' or revision creation.
Comment #2
jbeall commentedI'm having this same problem. It may not be CCK's "fault" but it is (at least in my case) *related* to CCK.
I created a new content type, with a whole bunch of custom fields via CCK, and I got rid of the body field. When creating a content type, it says "To omit the body field for this content type, remove any text and leave this field blank." "Great!" I thought, that's just what I want. We don't have any particular field for this content type that is the "body," -- all of the fields, arranged together, form a "body" for the node, but there's no separate body field.
But, now that I'm trying to do revisioning in this scenario, I can't save any additional revisions because, as the original poster noted, it's trying to insert a row into the node_revisions table without a value for body, and that field doesn't have a default value. Not only that, since it's a LONGTEXT column, it *can't* have a default value. Trying to set a default value results in a MySQL error, "#1101 - BLOB/TEXT column 'body' can't have a default value."
So this needs to be fixed in code. When a a new row is inserted into the node_revisions row, if there's no body value, it still needs to insert an empty string in order to make the SQL work.
So I think this is a revisioning module issue...?
-Josh
Comment #3
jbeall commentedOk, after some digging I think I found the solution. It's a one-liner, I hope we can get this into the next release of Drupal.
modules/node/node.install needs this (starting on line 213):
'body' => array(
'description' => 'The body of this version.',
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'default' => ''),
It was this:
'body' => array(
'description' => 'The body of this version.',
'type' => 'text',
'not null' => TRUE,
'size' => 'big'),
You can see that I added a "default" key with the value of an empty string. This seems to be all that was necessary.
I've manually patched my installation of Drupal, but I don't want to have to keep doing that every time a new release of Drupal comes out...
Comment #4
eric_a commentedThe node_save() function sets undefined teaser, body and log properties to the empty string in order to allow for an INSERT into the node_revision(s) table with it's corresponding non-nullable collumns.
*It does this when saving new nodes, but not when saving new revisions.*
Scenarios are possible where a new revision has to be saved for a node object with an undefined body, teaser and or log.
The logic in node_save() needs to be fixed if the above analysis is correct.
The solution in #3 tricks drupal_write_record() into setting default values even if default values cannot exist in the actual database schema. @jbeall: it is as ugly as it is quick! ;-) Brilliant for those who need an immediate fix.
Comment #5
damien tournoud commentedThis looks like a duplicate of #261258: Fix node_save() insertion logic.
Comment #6
JvE commented