This seems to be related to several other posts:

Some of these are feature requests, but it seems to me that Views does not handle Aggregator categories correctly and this is a bug.
My use case is as follows: I want to be able to inject multiple feeds with items uncategorised, but then allow the site editor to affect certain feed items to the category "Published". I then create a View which will display feed items, filtered on the "Published" category.
My situation is as follows:

  1. I have two feeds
  2. There is one category "Published" which is affected to neither feed automatically
  3. I have successfully injected items for both feeds
  4. I have successfully affect several items from both to the category "Published
  5. I have created a View which displays all the feed items correctly

The problems start when I try to filter on category. Having added the Aggregator category "Published" as a filter, the View now displays nothing.
Having gone through and checked the SQL, it seems to me that the SQL being generated is wrong. Here is what is generated:

SELECT aggregator_item.title AS aggregator_item_title, aggregator_item.link AS aggregator_item_link, aggregator_item.author AS aggregator_item_author, aggregator_item.timestamp AS aggregator_item_timestamp, aggregator_item.description AS aggregator_item_description, aggregator_feed.title AS aggregator_feed_title, aggregator_feed.link AS aggregator_feed_link
FROM 
{aggregator_item} aggregator_item
LEFT JOIN {aggregator_category_feed} aggregator_category_feed ON aggregator_item.fid = aggregator_category_feed.fid
LEFT JOIN {aggregator_category} aggregator_category ON aggregator_category_feed.cid = aggregator_category.cid
LEFT JOIN {aggregator_feed} aggregator_feed ON aggregator_item.fid = aggregator_feed.fid
WHERE (( (aggregator_category.cid IN  ('1')) ))
LIMIT 10 OFFSET 0

The problem that immediately springs to mind here is that there is no join on aggregator_category_item, which is the table that contains the item/category mapping! So it hardly seems surprising that it does not work.
You get a correct result with this SQL:

SELECT aggregator_item.title AS aggregator_item_title, aggregator_item.link AS aggregator_item_link, aggregator_item.author AS aggregator_item_author, aggregator_item.timestamp AS aggregator_item_timestamp, aggregator_item.description AS aggregator_item_description, aggregator_feed.title AS aggregator_feed_title, aggregator_feed.link AS aggregator_feed_link
FROM aggregator_item
LEFT JOIN aggregator_category_item ON aggregator_item.iid = aggregator_category_item.iid
LEFT JOIN aggregator_category ON aggregator_category_item.cid = aggregator_category.cid
LEFT JOIN aggregator_feed ON aggregator_item.fid = aggregator_feed.fid
WHERE (( (aggregator_category.cid IN  ('1')) ))

This is a big showstopper for me and I would be very grateful if this could get fixed...

Comments

martink’s picture

Title: Aggregator categories do not function correctly » Aggregator categories do not function correctly as filters or content

To all of which I will just add, that the categories do not appear to display properly either since the display is empty.
I thought it might be helpful to attach the View itself, with display and filter:

$view = new view();
$view->name = 'revue_de_presse';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'aggregator_item';
$view->human_name = 'Revue de Presse';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Revue de Presse';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['use_more_text'] = 'plus';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Appliquer';
$handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'Réinitialiser';
$handler->display->display_options['exposed_form']['options']['exposed_sorts_label'] = 'Trier par';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['pager']['options']['expose']['items_per_page_label'] = 'Éléments par page';
$handler->display->display_options['pager']['options']['expose']['items_per_page_options_all_label'] = '- Tout -';
$handler->display->display_options['pager']['options']['expose']['offset_label'] = 'Décalage';
$handler->display->display_options['pager']['options']['tags']['first'] = '« premier';
$handler->display->display_options['pager']['options']['tags']['previous'] = '‹ précédent';
$handler->display->display_options['pager']['options']['tags']['next'] = 'suivant ›';
$handler->display->display_options['pager']['options']['tags']['last'] = 'dernier »';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Champ: Agrégateur : Titre */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'aggregator_item';
$handler->display->display_options['fields']['title']['field'] = 'title';
/* Champ: Agrégateur : Auteur */
$handler->display->display_options['fields']['author']['id'] = 'author';
$handler->display->display_options['fields']['author']['table'] = 'aggregator_item';
$handler->display->display_options['fields']['author']['field'] = 'author';
/* Champ: Agrégateur : Horodatage */
$handler->display->display_options['fields']['timestamp']['id'] = 'timestamp';
$handler->display->display_options['fields']['timestamp']['table'] = 'aggregator_item';
$handler->display->display_options['fields']['timestamp']['field'] = 'timestamp';
$handler->display->display_options['fields']['timestamp']['label'] = 'Publié (ou aggrégé)';
$handler->display->display_options['fields']['timestamp']['date_format'] = 'jour_et_date';
/* Champ: Agrégateur : Corps */
$handler->display->display_options['fields']['description']['id'] = 'description';
$handler->display->display_options['fields']['description']['table'] = 'aggregator_item';
$handler->display->display_options['fields']['description']['field'] = 'description';
$handler->display->display_options['fields']['description']['label'] = '';
$handler->display->display_options['fields']['description']['element_label_colon'] = FALSE;
/* Champ: Flux d'agrégateur : Titre */
$handler->display->display_options['fields']['title_1']['id'] = 'title_1';
$handler->display->display_options['fields']['title_1']['table'] = 'aggregator_feed';
$handler->display->display_options['fields']['title_1']['field'] = 'title';
/* Champ: Catégorie d'agrégateur : Catégorie */
$handler->display->display_options['fields']['title_2']['id'] = 'title_2';
$handler->display->display_options['fields']['title_2']['table'] = 'aggregator_category';
$handler->display->display_options['fields']['title_2']['field'] = 'title';
/* Critère de tri: Agrégateur : Horodatage */
$handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['table'] = 'aggregator_item';
$handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['order'] = 'DESC';
$handler->display->display_options['sorts']['timestamp']['granularity'] = 'day';
/* Critère de filtrage: Catégorie d'agrégateur : Identifiant de catégorie */
$handler->display->display_options['filters']['cid']['id'] = 'cid';
$handler->display->display_options['filters']['cid']['table'] = 'aggregator_category';
$handler->display->display_options['filters']['cid']['field'] = 'cid';
$handler->display->display_options['filters']['cid']['value'] = array(
  1 => '1',
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'revue-de-presse';
$handler->display->display_options['menu']['type'] = 'normal';
$handler->display->display_options['menu']['title'] = 'Revue de Presse';
$handler->display->display_options['menu']['weight'] = '0';
$handler->display->display_options['menu']['name'] = 'main-menu';
$handler->display->display_options['menu']['context'] = 0;
$translatables['revue_de_presse'] = array(
  t('Master'),
  t('Revue de Presse'),
  t('plus'),
  t('Appliquer'),
  t('Réinitialiser'),
  t('Trier par'),
  t('Asc'),
  t('Desc'),
  t('Éléments par page'),
  t('- Tout -'),
  t('Décalage'),
  t('« premier'),
  t('‹ précédent'),
  t('suivant ›'),
  t('dernier »'),
  t('Titre'),
  t('Auteur'),
  t('Publié (ou aggrégé)'),
  t('Catégorie'),
  t('Page'),
);

martink’s picture

StatusFileSize
new546 bytes

There are days like that, when you can't resist a debug problem. I know nothing about how Views is coded, but the problem seemed pretty localised and looking at aggregator.views.inc I realised that the problem must lie in the definition of the path defined between the aggregator_category and the aggregator_item tables. In fact as it stands there is none.
So I propose the enclosed patch. It seems to work for me, but I am very uncertain about creating patches so would be very happy if the Views bug squad could look it over and incorporate it in Views.

martin.knapp’s picture

Any chance of someone testing and including this patch?

martin.knapp’s picture

Bump?

martin.knapp’s picture

Issue summary: View changes

Added more detail on the incorrect SQL

josaku’s picture

Issue summary: View changes
StatusFileSize
new1.18 KB

I have the same problem with 7.x-3.7 and #2 works for me. Thanks.
However, the original patch is not in the unified format hence I uploaded the same in the unified format.

circuscowboy’s picture

Version: 7.x-3.6 » 7.x-3.x-dev
Status: Active » Reviewed & tested by the community
StatusFileSize
new1.61 KB

I have reviewed this patch and it works fine. The patch was not formatted correctly to apply on views so I have re-roled it so it should be fine to patch on dev or 7.x-3.7

dawehner’s picture

+++ b/modules/aggregator.views.inc
@@ -324,19 +324,33 @@ function aggregator_views_data() {
   $data['aggregator_category_feed']['table']['join'] = array(
-    'aggregator_item' => array(
+    'aggregator_feed' => array(
       'left_field' => 'fid',
       'field' => 'fid',
     ),
   );
 

So So I mean I in general totally agree that these changes are the right thing to do, but on the other hand this change could have been made less destructive. Can't you just add the aggregator_feed mapping on top of the existing one?

colan’s picture

We've recently switched our testing from the old qa.drupal.org to DrupalCI. Because of a bug in the new system, #2623840: Views (D7) patches not being tested, older patches must be re-uploaded. On re-uploading the patch, please set the status to "Needs Review" so that the test bot will add it to its queue.

If all tests pass, change the Status back to "Reviewed & tested by the community". We'll most likely commit the patch immediately without having to go through another round of peer review.

We apologize for the trouble, and appreciate your patience.

damienmckenna’s picture

Status: Reviewed & tested by the community » Needs work

Putting back to "needs work" per dawehner's comment #8.