SUMMARY

The 'upload' table has a 'skip base' attribute in its 'Upload: Node' relationship definition. This attribute is to prevent the relationship (or whatever it's attached to) from showing when only a 'node' table, for example, is linked in the view. Incidentally, this 'skip base' feature could be a handy one: it could probably solve another issue: "All terms" field shouldn't show for "term"-type views.

Unfortnately, this 'skip base' feature doesn't work. Steps to reproduce:

- Start a new view, of type 'node'.
- Make sure the 'upload' module is enabled.
- Click the 'Add relationship' button. You'll see 'Upload: Node' in the list. Bad.

SOLUTION

The function that utilizes this 'skip base' is views_fetch_fields(). It has three bugs, which the attached patch fixes:

  1. It assumed the 'skip base' slot is in the field, not the definition, level. I changed it to look in both levels. (Sorry for code redundancy: I suspect any other way wouldn't have saved many bytes, if at all.)
  2. The 'foreach' loop was using a '$base' variable, thereby overwriting the '$base' variable which is the function parameter.
  3. The skipped table name(s) wasn't actually inspected later. I changed that to a hash lookup.
  4. (Not required.) In upload.views.inc, I added 'node_revisions' to the 'skip base' list: If the base table is node_revisions, one already has access to everything in a node, so there's no need for this extra node relationship.
CommentFileSizeAuthor
skip_base.diff2.34 KBmooffie

Comments

merlinofchaos’s picture

Status: Needs review » Fixed

Committed. Sorry about losing track of this one.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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