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

catch’s picture

Status: Active » Needs review
StatusFileSize
new3.57 KB

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

Status: Needs review » Needs work

The last submitted patch failed testing.

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new3.66 KB

Hmm.

Frando’s picture

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

cburschka’s picture

Status: Needs review » Needs work

Should it be done that way?

Otherwise, set back to NR.

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new1.59 KB

Here'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.

Status: Needs review » Needs work

The last submitted patch, entity_revisions.patch, failed testing.

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new2 KB

Fixed uid breakage.

cburschka’s picture

Two more code style suggestions, and this looks good to go.

+++ modules/node/node.module	1 Mar 2010 05:12:17 -0000
@@ -3604,4 +3604,15 @@ class NodeController extends DrupalDefau
+    // Ensure that uid is taken from the {node} table
+    // alias timestamp to revision_timestamp and add revision_uid.

A comma after "table" could make the comment clearer, since it lists three actions ("a, b and c" rather than "a b and c").

+++ modules/node/node.module	1 Mar 2010 05:12:17 -0000
@@ -3604,4 +3604,15 @@ class NodeController extends DrupalDefau
+    unset($fields['timestamp']);
+    $fields['uid']['table'] = 'base';
+    $this->query->addField('revision', 'timestamp', 'revision_timestamp');

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!

cburschka’s picture

Status: Needs review » Needs work
catch’s picture

Status: Needs work » Needs review
StatusFileSize
new2 KB

Works for me, re-rolled with those changes.

catch’s picture

#11: entity_revisions.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, entity_revisions.patch, failed testing.

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new2 KB

Re-rolled.

Status: Needs review » Needs work

The last submitted patch, cleanupcontroller.patch, failed testing.

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new2.08 KB
pasqualle’s picture

subscribe

chx’s picture

Status: Needs review » Reviewed & tested by the community

This better get in otherwise when you try to create a revisioned entity you will be forced to have 'timestamp'... nasty.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.