Download & Extend

Cannot use Aggregator IID in Contextual Filter

Project:Drupal core
Version:8.x-dev
Component:aggregator.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:patch (to be ported)
Issue tags:Needs backport to D8

Issue Summary

When attempting to use the Contextual filter to select a specific Aggregator item, I get the following error:

Notice: Undefined index: highlighted in include() (line 109 of .../sites/all/themes/crcom/page.tpl.php).
Warning: Illegal offset type in SelectQuery->fields() (line 1330 of .../includes/database/select.inc).
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM aggregator_item aggregator_item WHERE (iid IN ('45'))' at line 1: SELECT FROM {aggregator_item} aggregator_item WHERE (iid IN (:db_condition_placeholder_0)) ; Array ( [:db_condition_placeholder_0] => 45 ) in views_handler_argument_aggregator_iid->title_query() (line 17 of .../sites/all/modules/views/modules/aggregator/views_handler_argument_aggregator_iid.inc).

It seems to be a problem with a lack of a table alias in the SQL query in the handler file (primarily because the fields() member is being invoked on the query object) and can be resolved by adding a table alias (e.g. 'i') like so:

    $result = db_select('aggregator_item', 'i')
      ->condition('iid', $this->value, 'IN')
      ->fields('i', array('title'))
      ->execute();

Comments

#1

This issue seems to be fixable. It would be really great if you could create a real patch, so it's much easier to realize what you try to do.

#2

Status:active» postponed (maintainer needs more info)

Also a way to reproduce the problem would be really handy

#3

Status:postponed (maintainer needs more info)» closed (cannot reproduce)

#4

Status:closed (cannot reproduce)» active

Easily reproduced this issue.
See the two attached screenshots.

  1. Create a View of Aggregator Items
  2. Create a Contextual Filter (formerly known as Arguments in Drupal 6) that filters Aggregator: Item ID

Contextual Filter Settings:

WHEN THE FILTER VALUE IS NOT IN THE URL:

Display all results for the specified field

AttachmentSizeStatusTest resultOperations
20130123-views-aggregator-settings.jpg270.11 KBIgnored: Check issue status.NoneNone
20130123-error-views-aggregator.jpg151.86 KBIgnored: Check issue status.NoneNone

#5

Status:active» needs review

Here is a patch for it, so it would be cool if you could try it out.

AttachmentSizeStatusTest resultOperations
views-1294056-5.patch815 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 1,603 pass(es).View details | Re-test

#6

@dawehner Thank you. Tested and it works!

#7

Status:needs review» reviewed & tested by the community

So this seems to be RTBC.

#8

Project:Views» Drupal core
Version:7.x-3.x-dev» 8.x-dev
Component:Miscellaneous» aggregator.module
Status:reviewed & tested by the community» patch (to be ported)

Thanks for testing the patch! Committed and pushed to 7.x-3.x