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.

CommentFileSizeAuthor
#4 nullbody.patch392 byteserle

Comments

erle’s picture

while 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 = %d

with the revision flag, this query is run:

INSERT INTO {node_revisions} (nid, uid, title, teaser, log, timestamp, format) VALUES (%d, %d, '%s', '%s', '%s', %d, %d)

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.

yched’s picture

Project: Content Construction Kit (CCK) » Drupal core
Version: 6.x-2.0-rc6 » 6.4
Component: CCK in core » node.module

Node types / Body / Revisions are not CCK's business. This is a core issue.

damien tournoud’s picture

Status: Active » Closed (duplicate)
erle’s picture

Component: node.module » node system
Assigned: Unassigned » erle
Priority: Normal » Critical
Status: Closed (duplicate) » Closed (fixed)
StatusFileSize
new392 bytes

the 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.

damien tournoud’s picture

Status: Closed (fixed) » Closed (duplicate)

Please comment on the other issue.