Node_delete() does not always delete the entry in the main content table. The problem occurs anytime the main content table (i.e. node_content_mytype) contains only nid and vid, which can happen if the type is new and does not yet have any fields, or if all fields in the content type are in separate tables because they are multiple value fields or are shared with another content type.
To reproduce:
1) Create a content type, add no fields to it, create a record (it will have only a title) and then try to delete it. -OR-
2) Create a content type, create a single field for it and make the field a multiple value field, add a record, then try to delete it. -OR-
3) Create a content type, add in a field that already exists in another table, add a record, then try to delete it.
In all the above cases, the node, node revisions, and any records in separate field tables will be removed, but an orphan record (with only a nid and vid) will remain in the node_content_mytype table.
The problem is that the content module delete function iterates through each field to delete that field from whatever table it exists in, but never goes back to make sure that records in the main table are deleted. If at least one of the fields exists in the main table, that record get deleted, otherwise it does not.
The attached patch adds another step to content_delete and content_delete_revision to make sure records in that table get removed, too.
| Comment | File | Size | Author |
|---|---|---|---|
| content.module_13.patch | 810 bytes | karens |
Comments
Comment #1
karens commentedShould be marked as patch.
Comment #2
karens commentedFix committed.
Comment #3
(not verified) commented