Hi,

Just installed agg2 on a fresh 4.7 install.

Was having problems getting the autotaxonomy mini-module working.

I've created some feeds with rss feeds that I know have category tags (some of the same feeds are also running on a 4.6 site with agg2 and autotaxonomy, and everything is working fine) but nothing seems to get generated for taxonomy terms when i update the feed on the 4.7 install.

Does autotaxonomy work with the cvs version of agg2 on 4.7?

Thanks for any advice or tips

Comments

Christoph C. Cemper’s picture

I'm interested in this one, too... any comments?

colorado’s picture

Heyho,

I haven't been able to get Agg2 from cvs to work on my fresh 4.7.0 install. What Agg2 version are you using - did you patch it? If so, with what patch(es)? And with what combination of options in the settings?

(Currently the feeds themselves appear to be working properly (giving no error messages), but refreshing the feed always generates "0 new items" (I have the same feed working perfectly on a patched 4.6.5 installation.)

Thanks!

voidberg’s picture

Same problem happens to me too. The same thing occurs after patching taxonomy module.

Christoph C. Cemper’s picture

I have mixed results...

I get one feed with 0 results,
then the other one works fine...

took the normal 4.7 dist and the latest agg2 module

however I get A LOT of "duplicate-key" errors for the term_node table when updating

christoph

mlh-1’s picture

Category: support » bug
Status: Active » Reviewed & tested by the community

In aggregator2_autotaxonomy.module On line 30
Change
if($node->type == 'aggregator2-item' && isset($node->rss_item_data)) {
to
if($node->type == 'aggregator2_item' && isset($node->rss_item_data)) {

That should fix the issue.

budda’s picture

Assigned: Unassigned » budda
Status: Reviewed & tested by the community » Fixed

Change committed thanks!

sillygwailo’s picture

Status: Fixed » Active

I updated to the latest CVS version (which has the aggregator2-item => aggregator2_item fix) and still can't get categories in items' <category> elements to apply correctly to aggregator2 items.

sillygwailo’s picture

Priority: Normal » Critical
budda’s picture

Are the category terms getting created correctly in your taxonomy now though?

sillygwailo’s picture

The best I can tell is that aggregator2_autotaxonomy.module works correctly (that is, based one some print_r debugging I did, aggregator2_autotaxnomy would identify the categories from the RSS feed and put them into an array), it's just that once aggregator2.module gets a hold of it, it will only apply the category that comes as from the setting in the feed item node, not the tags in the RSS feed.

Christoph C. Cemper’s picture

agree with Richard

agentrickard’s picture

I'm trying to track this problem as well. Here's what I have so far.

Using CVS of aggregator2 and aggregator2_autotaxonomy on fresh 4.7.2 install.

In line 76-78 of aggregator2_autotaxonomny.module we have this line:

                $term = taxonomy_save_term($term);
                $node->taxonomy[] = $term['tid'];
                $cat_names[$category_name][0]->tid = $term['tid'];

The intent here is to save a new term (if needed) and use the $term var to set the taxonomy for the node to be saved.

But http://api.drupal.org/api/4.7/function/taxonomy_save_term taxonomy_save_term does not return a $term object. It only returns a $status message. So the $term['tid'] is never set.

I think we have to grab the $term data by name in order for this function to work.

                taxonomy_save_term($term);
                $term = taxonomy_get_term_by_name($term['name']);                
                $node->taxonomy[] = $term['tid'];
                $cat_names[$category_name][0]->tid = $term['tid'];

Will explore more.

agentrickard’s picture

I think I'm near a solution, but may be off base. It looks like the module is having trouble with changes to taxonomy_node_save() in 4.7 -- specifically formatting of the $node->taxonomy variable.

Hopefully this is helpful.

Before I go on, two apologies.

1) I haven't tested this thoroughly. Only for my setup.
a) I am inserting tags into feed items using a 4.7 free-tagging vocabulary.
b) I want to insert both the feed tags and the items category tags for each item

2) I haven't rolled a patch because I haven't learned CVS.

Here's what I changed.

aggregator2.module function aggregator2_parse_items() line 1985

     //   $edit->taxonomy = $feed->feed_item_taxonomy;
        $terms = module_invoke('taxonomy', 'node_get_terms', $edit->fid, 'tid');
        foreach ($terms as $tid => $term) {
          if ($term->tid) {
            $edit->taxonomy[$tid] = $term;
          }
        }     

This gives us the taxonomy object in the same format as for saveing feeds.

Aggregator2_autotaxonomy.module function aggregator2_autotaxonomy_nodeapi(), line 47.

      case 'insert':
      case 'update':
      // The aggregator2 module uses hook_prepare, so we need to account for it      
      case 'prepare':

Lines 69:

              // Create a new category term
              if (count($cat_names[$category_name]) == 0) {
                $term = array();
                $term['name'] = $category_name;
                $term['description'] = t('Auto generated by aggregator2 autotaxonomy');
                $term['vid'] = $vocab;
                $term['weight'] = 0;
                // broken
                //$term = taxonomy_save_term($term);
                taxonomy_save_term($term); 
                $terms = taxonomy_get_term_by_name($term['name']);     
                foreach ($terms as $term) {
                  $node->taxonomy[$term->tid] = $term;                
                }

Line 80:

              else {
                // Use the existing category term in the database
                if (!in_array($cat_names[$category_name][0]->tid, $node->taxonomy)) {
                  $terms = taxonomy_get_term_by_name($cat_names[$category_name][0]->name);
                  foreach ($terms as $term) {
                    $node->taxonomy[$term->tid] = $term;                
                  }                  

And here's what I get as a $node-taxonomy object on save:

    [taxonomy] => Array
        (
            [14] => stdClass Object
                (
                    [tid] => 14
                    [vid] => 1
                    [name] => celebrities
                    [description] => 
                    [weight] => 0
                )
        )

This works for new node creation. Seems to work also when editing an existing node.

agentrickard’s picture

One additional change.

Line 64 of aggregator2_autotaxonomy():

            $category_name = trim($category_name);
            if ($category_name != '') {

The current code: if (trim($category_name) != '') does not actually trim() the variable, which I think is necessary.

sillygwailo’s picture

StatusFileSize
new3.26 KB

I'm attaching a patch made from the above code. I tested it and it updated old feed items along with keeping the taxonomy terms for new items. A couple of bugs remain, as far as I can tell

  • the feed's taxonomy terrm does not seem to be applied (that is, in the feed node itself, if you choose a taxonomy term, that term is not applied to feed items)
  • if you choose "Apply changes to already existing items after feed is re-edited" when editing the feed node, you lose all the taxonomy terrm info for the feed items

This gets us closer to fixing this issue, Ken.

sillygwailo’s picture

Another issue with the patch is that on the updated feed items, it dupilcates some tags if you're using free-tagging.

agentrickard’s picture

StatusFileSize
new7.39 KB

Here's a copy of the module as I have it in production right now. It fixes the duplication issues.

Again, sorry for the lack of a proper patch.

agentrickard’s picture

StatusFileSize
new7.39 KB

Soory. That last copy still has some debugging statements in it.

agentrickard’s picture

StatusFileSize
new7.17 KB

OK. Progress. I added a routine to kill duplicate taxonomy terms that were showing up. I'm still not sure where they were coming from. I think aggregator2 is putting them in.

Anyway, I have this version running, error-free at http://www.rubybaboon.com/

agentrickard’s picture

StatusFileSize
new7.63 KB

Alright one more time. After the last patch, the assigned item_taxonomy from the aggregator2_feed table wasn't getting saved. So I forced it into the aggregator2_autotaxonomy module.

Maybe not the best solution but I think it's working. (Again).