cck installed on drupal 6.3/ 6.4. Present in both
Steps to reproduce
1. Create a new content type, leave "Title" field, but remove "Body" (no body field in content type)
2. I also created another field (any field type), but this is not essential.
3. Create a new node type of this content type -- this works ok.
4. Now edit this node type and check 'Create new revision' on 'Revision information'
-- On saving this the error appears
* warning: pg_query() [function.pg-query]: Query failed: ERROR: null value in column "body" violates not-null constraint in /home/erle/public_html/drupal-6.4/includes/database.pgsql.inc on line 138.
* user warning: query: INSERT INTO node_revisions (nid, uid, title, teaser, log, timestamp, format) VALUES (1, 1, 'test', '', '', 1219038910, 0) in /home/erle/public_html/drupal-6.4/includes/common.inc on line 3318.
** This only appears when a revision is checked, else it saves fine.
The problem seems to occur only when the body type is not used when the node type is created.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | nullbody.patch | 392 bytes | erle |
Comments
Comment #1
erle commentedwhile debugging I think i have tracked it down to this -- ( should this bug even be reported in cck ? )
includes/common.inc line:3329 (inside drupal_write_record)
without the revision flag set, this query is run:
UPDATE {node_revisions} SET nid = %d, uid = %d, title = '%s', teaser = '%s', timestamp = %d, format = %d WHERE vid = %dwith the revision flag, this query is run:
Now since the body field is stored as 'not null' the second query will obviously fail, and this is causing the error ( I think :) ).
Question now is, where should this be fixed, hmm.
Of course I can easily dump in a blank body field via an override and hide it, but that is not ideal.
Comment #2
yched commentedNode types / Body / Revisions are not CCK's business. This is a core issue.
Comment #3
damien tournoud commentedThis is a duplicate of #261258: Fix node_save() insertion logic.
Comment #4
erle commentedthe solution was to make a change in node.module.
When the node is revised (for the specific content type where body doesnt exist) , the node array doesn't have the 'body'. Patch attached.
---
(update)
Just got word this is a duplicate, I am attaching my fix for 6.x (6.4) for completion, though the other thread fixes other issues too. This is closed, I'm gonna be following that.
Thanks for the pointer, Damien
http://drupal.org/node/261258
#261258: Fix node_save() insertion logic.
Comment #5
damien tournoud commentedPlease comment on the other issue.