One of the followups from entity loading was moving the node specific stuff out of entity.inc into NodeController - this is the code hunk:
if ($this->revisionKey) {
// Add all fields from the {entity_revision} table.
$entity_revision_fields = drupal_map_assoc(drupal_schema_fields_sql($this->revisionTable));
// The id field is provided by entity, so remove it.
unset($entity_revision_fields[$this->idKey]);
// Change timestamp to revision_timestamp, and revision uid to
// revision_uid before adding them to the query.
// TODO: This is node specific and has to be moved into NodeController.
unset($entity_revision_fields['timestamp']);
$this->query->addField('revision', 'timestamp', 'revision_timestamp');
unset($entity_revision_fields['uid']);
$this->query->addField('revision', 'uid', 'revision_uid');
This needs to go into NodeController ->buildQuery().
Comments
Comment #1
catchThis might be a bit of a sledgehammer, but on first look, there didn't seem to be an obvious way to remove fields from a query object, so just copied the whole of buildQuery for now.
Comment #3
catchHmm.
Comment #4
Frando commentedI think you should be able to remove fields by modifying the query's raw field property by reference. So
$fields =& $this->query->getFields();and then altering $fields as needed.Comment #5
cburschkaShould it be done that way?
Otherwise, set back to NR.
Comment #6
catchHere's a patch using the method from #4. Much more concise doing it this way, not entirely sure about modifying the field array directly like that. Untested apart from clicking a couple of times.
This issue causes SQL errors if you create an entity with revision support which doesn't have {myentity_revision}.timestamp and {myentity_revision.uid} fields. So it's somewhat critical in the sense that it's broken, but not sure who's doing that apart from me last night.
Comment #8
catchFixed uid breakage.
Comment #9
cburschkaTwo more code style suggestions, and this looks good to go.
A comma after "table" could make the comment clearer, since it lists three actions ("a, b and c" rather than "a b and c").
Does the code have to make the uid table change between deleting the old timestamp field and adding the new one? If it's avoidable, then arranging the actions in the same order as the comment describes them (first the uid table, then delete and re-add timestamp, then add revision_uid) would make it more readable.
140 critical left. Go review some!
Comment #10
cburschkaComment #11
catchWorks for me, re-rolled with those changes.
Comment #13
catch#11: entity_revisions.patch queued for re-testing.
Comment #15
catchRe-rolled.
Comment #17
catchComment #19
pasquallesubscribe
Comment #20
chx commentedThis better get in otherwise when you try to create a revisioned entity you will be forced to have 'timestamp'... nasty.
Comment #21
dries commentedCommitted to CVS HEAD. Thanks.