Download & Extend

feedapi_eparser_type_plugin overwrite namespace plugins data in $item->options elements

Project:FeedAPI Extensible Parser
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:postponed

Issue Summary

Checking the code I found that using rss20 type plugin (eparse_type_rss20.inc) called by feedapi_eparser.plugins.inc overwrite data gathered by other namespace plugins.

That's what happen:

file: feedapi_eparser.plugins.inc
line 327:

<?php
    $this
->parsed_source->items = array();
    foreach (
$this->get_items() as $xml_item) {
     
$item = new stdClass();
      foreach (
$this->namespace_plugins as $plugin) {
        if(
is_object($plugin)) $plugin->parse_item($xml_item, $item);
      }

     
$this->parse_item($xml_item, $item);

     
$this->parsed_source->items[] = $item;
    }
?>

foreach loop parse the feed using custom plugins which add data to the $item class.

After this the $item is used by $this->parse_item (line 53 on eparse_type_rss20.inc) and at the end of the method:

<?php
    $item
->options = $data;
?>

This reset options data set by previous namespace plugins.

The problem is that feedapi.module merge from secondary parser in the feed items only the options!

file feedapi.module - function _feedapi_call_parsers($feed, $parsers, $settings) - line 1003

<?php
 
// Call the turned on parsers, create a union of returned options
 
$parsers_secondary = is_array($parsers_secondary) ? $parsers_secondary : array();
  foreach (
$parsers_secondary as $parser) {
   
$feed_ext = module_invoke($parser, 'feedapi_feed', 'parse', $feed, FALSE);
   
$feed->options = (object) ((array) $feed->options + (array) $feed_ext->options);
   
// Merge items' options
   
if (is_array($feed_ext->items)) {
      foreach (
$feed_ext->items as $key => $item) {
       
$feed->items[$key]->options = (object) ((array) $feed->items[$key]->options + (array) $item->options);
      }
    }
  }
?>

So either we have to change eparse_type_rss20.inc to merge with already set values in $item->options or
change feedapi_eparser.plugins.inc and merge there the option from namespace plugin and type plugin.

Comments

#1

I did run into this while creating this module. In fact its part of the reason I created the module. The options property doesn't have any system for managing data from different sources. FeedAPI just merges it together and hopes for the best.

This modules gets around that by allowing plugins to add data directly to the object in its own namespaced property on the object. This allows many plugins to coexist very easily.

At this point I'm not terribly keen on changing this behavior since its more of a feature than a bug. It does require that eparser be a primary parser to use it so I do understand the limitations that imposes.

If someone is willing to try to convince me of a better options I'm willing to listen. No releases have been made so nothing about the module is set in stone yet.

#2

Another note, this line exists purely for compatibility reasons.

<?php
    $item
->options = $data;
?>

I tried to make the Extensible Parser behave as much like the common parser and simplepie parser. If I remember correctly, some things expect certain data to be in the options property so its not really as optional as its name implies.

#3

Status:active» postponed

This isn't something that's going to be dealt with before the 1.0 release.

nobody click here