we have code in node_filter_form() to deal with a 'term' filter:

    if ($type == 'term') {
      // Load term name from DB rather than search and parse options array.
      $value = module_invoke('taxonomy', 'term_load', $value);
      $value = $value->name;
    }

and later on in the same foreach():

   $t_args = array('%property' => $filters[$type]['title'], '%value' => $value);

problem is that node_filters(), which sets the $filters variable, can never return a $type = 'term' key for that array. so if any other code happens to set a 'term' filter, we'll get notices at that point.

we also handle the 'term' filter elsewhere, but again, if it was ever set, we'd get notices on the node admin screen.

is this code left over from D6? i think we should be killing it.

CommentFileSizeAuthor
#6 1180722-6-dead-code.patch712 bytestr
#2 node.filter.patch1.51 KBAnonymous (not verified)

Comments

tr’s picture

Version: 7.x-dev » 8.x-dev

Same code is in D8 - needs to be fixed there first.

Anonymous’s picture

Version: 8.x-dev » 7.x-dev
Status: Active » Needs review
StatusFileSize
new1.51 KB

here's a D7 patch that a) takes out the dead code and b) allows modules to hook into the 'admin/content' form without nasty cut-and-paste hackery, as they would be forced to do now.

Anonymous’s picture

Assigned: » Unassigned
tr’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work
Issue tags: +Needs backport to D7

Needs to go into D8 first.

Also, your patch does more than just remove the dead code - it adds a drupal_alter(). That's an API change and something that should definitely be discussed - I suggest doing that in a separate issue and confining this issue to removing dead code.

dawehner’s picture

Version: 8.0.x-dev » 7.x-dev
Issue summary: View changes

That page no longer exists like that, but is rather using a view.

tr’s picture

Priority: Normal » Minor
Status: Needs work » Needs review
Issue tags: -Needs backport to D7
StatusFileSize
new712 bytes

The original patch makes three changes:

  1. Removes dead code from node_build_filter_query()
  2. Removes dead code from node_filter_form()
  3. Adds a new hook

#3 is clearly out of scope of this issue, as pointed out in comment 4.
#2 is no longer an issue in D8, as pointed out in comment 5.
#1 is no longer an issue in D7 because it was done by #262498: Error in content administration using taxonomy filter about four months after this issue was opened.

What we're left with is just "Removes dead code from node_filter_form()", and only in D7 not in D8.

After looking at the code, it is clear #2 is still needed in D7. node_filters() returns "List node administration filters that can be applied." but specifically it does not return a 'term' filter. Filter names taken from this list are stored in a $_SESSION variable, and this variable is used by node_filter_form() to execute code conditionally in a switch statement depending on the filter name. Because 'term' is not a defined filter name, the case: that checks for the 'term' filter will never be executed.

Here is an updated patch. Moved to 'minor' because there is no danger of this dead code making it into D8 anymore and because it can't really do much harm since it doesn't run.

avpaderno’s picture

Status: Needs review » Reviewed & tested by the community

The patch still applies and the analysis done in the previous comment is correct.

avpaderno’s picture

Title: remove dead code from node_filter_form() and elsewhere » Remove dead code from node_filter_form()

  • poker10 committed e1fe0eb6 on 7.x
    Issue #1180722 by TR: Remove dead code from node_filter_form()
    
poker10’s picture

Status: Reviewed & tested by the community » Fixed

Taxonomy node filter was removed in #693362: taxonomy_form_all() is dangerous and it seems like this was left here unintentionally.

I have done a quick search on the Drupal codebase via Gitlab a it seems like no contrib module is setting the $_SESSION['node_overview_filter'] variable, which should be the only way how term could end up here. Therefore I think this is safe to remove.

Committed, thanks all!

Status: Fixed » Closed (fixed)

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