There are major, reproducible problems with the FeedsSyndicationParser, but they different than the problems seen for the FeedsSimplePieParser.

For FeedsSimplePieParser, both HubMed feeds and Science feeds were missing timestamps, and required the patch setting the timestamp to the current time in order for them to be displayed. The correct data was stored in the feeds_data_syndication table when the timestamp was 0, but it did not display.

For FeedsSyndicationParser these two feed sources behave differently: HubMed feeds have timestamps, and display without needing a patch. However, Science feeds also have timestamps, but do not display. The correct feed node is created with the correct tite, there is no data stored in the feeds_data_syndication table.

This was consistent for two HubMed feeds (nodes 6 and 8) and two Science feeds (nodes 7 and 9)
The associated URLs used are: shown in the table below.
These results were seen with a completely virgin Managing News 1.0beta5, with Feeds alpha5

NID Timestamp URL
6 1257243592 http://www.hubmed.org/feeds/rss.cgi?q=cytoskeleton%20regulation
7 1257244177 http://www.sciencemag.org/rss/current.xml
8 1257244764 http://www.hubmed.org/feeds/rss.cgi?q=cancer%20regulation
9 1257244976 http://www.sciencemag.org/rss/twis.xml

Comments

velosol’s picture

I've come across similar behavior (feed nodes created, no feeds_data_syndication items created, even on forced import) in trying to get the common_syndication_parser to work with custom XML. Pseudo-debugging (first code block) pointed to simplexml_load_string() failing and upon investigation (second code block) found that my XML was not coming in completely (died around 30KB) and SimpleXML was complaining that it was missing close tags. I've gotten it to work by reducing the size of my XML file, but it's certainly not a long-term solution. I also checked it with both cURL and drupal_http_request(), PHP mem limit 128MB, exec_limit 180.

I understand that the two feeds you mention are similar in size, but this might be an area to investigate as a possible cause.

// Got a malformed XML.
  if ($xml === FALSE || is_null($xml)) {
    trigger_error("c_s_p_parse received bad XML, beginning:" . substr($string, 0, 20));
    return FALSE;
  }
  libxml_use_internal_errors(true); //Have SimpleXML store errors for retrieval by libxml_get_errors() .
  if (!defined('LIBXML_VERSION') || (version_compare(phpversion(), '5.1.0', '<'))) {
    @ $xml = simplexml_load_string($string, NULL);
  }
  else {
    @ $xml = simplexml_load_string($string, NULL);// LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NOCDATA); //Allow errors.
  }
  $errors = libxml_get_errors();
  foreach ($errors as $error) {
    $message = (string)$error->message;
    trigger_error("Error is: $message");
    }
mcaudy’s picture

@alex_b: please advise as to how to proceed.

@velosol: thanks for your comments and suggestions. I have taken a different approach:

When I use the FeedsSyndicationParser with the RSS feed from the journal Science, I get:

    "HTTP - 500 Internal Server Error
    The page you are attempting to load returned an error."

So, I looked in the Apache error_log file and found:

    [Thu Nov 05 03:12:43 2009] [error] [client ::1] PHP Fatal error: Cannot use object of type stdClass as array in /Library/WebServer/Documents/managingnews10b5v5/profiles/managingnews/modules/contrib/feeds/libraries/common_syndication_parser.inc on line 276, referer: http://localhost/managingnews10b5v5/node/add/feed

This error occurs at line 276 in the RDF parsing section,

    275 // Special handling for the title:
    276 $item['title'] = _parser_common_syndication_title($item['title'], $item['description']);

and is apparently due to the code trying to access the the $item object properties using array syntax

Also, googling for this PHP error gave several results that suggested that the problem can be corrected by changing from the array accessor syntax " [ ] ", to object accessor syntax: " -> ",

So, line 276 would become:

    276 $item->title = _parser_common_syndication_title($item->title, $item->description);

When I tried this, it worked, but this just kept correcting the immediate line of code, and the same error:

    PHP Fatal error: Cannot use object of type stdClass as array

would then show up in a subsequent line of code.

When all of these errors were corrected in the FeedsSyndicationParser file, a proper $parse_source was created for the RDF feed content, but this did not solve the problem, as the same error:

    PHP Fatal error: Cannot use object of type stdClass as array

then showed up in the FeedsDataProcessor.inc file at line 22:

When this was corrected, the same error

    PHP Fatal error: Cannot use object of type stdClass as array

then showed up in the FeedsParser.inc file on line 79

In addition, it was observed that these changes broke parsing for Nature articles, which had been parsing correctly before.

Note: I did see one claim when I googled for "PHP Fatal error: Cannot use object of type stdClass as array" that this is due to a bug in PHP, which has been fixed in a recent nightly build. However, it is not clear if this person knew what they were talking about, and I don't want to go this direction without more info.

alex_b: please advise as to how to proceed.

mathieu’s picture

Subscribe.

strr’s picture

Cannot use object of type stdClass as array in feeds/libraries/common_syndication_parser.inc on line 276

I got tons of this error.

Any news on that issue?

mrosas’s picture

subscribe

alex_b’s picture

Some of the format errors occurring on mappings are being addressed by #624088-30: Mapper: ImageField/FileField (formalize feed elements)

alarcombe’s picture

The 'Cannot use object of type stdClass as array' seem to be occurring because you have functions such as _parser_common_syndication_RDF10_item returning an object, but these objects are being referred to as arrays in the calling functions. eg in common_syndication_parser.inc line 263 assigns $item to be the return from a call to _parser_common_syndication_RDF10_item(), which is an object.

On line 276 and continuing throughout the rest of the function $item is being treated as an array, eg
$item['title'] = _parser_common_syndication_title($item['title'], $item['description']);

This seems badly b0rked - however it's my first time with this module - anyone have any further comments as to whether this is by design and what the best fix would be? Should they be objects or arrays? Will any decision break anything else?

velosol’s picture

Just a quick note re: #7 - SimpleXML is convoluted in it's use of objects and arrays as shown below. WRT what you wrote, I wouldn't be surprised if that is (part of) the problem. In fixing it just be aware of the gotchas as below.

If you had a node like:

<parent attrib="someAttrib">
   <firstChild>Some value</firstChild>
   <secondChild attrib="best">Some other value</secondChild>
</parent>

$parent = simplexml_load_string($raw, NULL);
To access 'some value' you'd use $thisIsSomevalue = $parent->firstChild. To access 'best' you'd use

$thisIsSecondChild = $parent->secondChild;
$thisIsAttribBest = $thisIsSecondChild['attrib'];

For 'someAttrib' you'd use $thisIsSomeAttrib = $parent['attrib'];

HTH.

bureado’s picture

I'm also getting errors such as:

Fatal error: Cannot use object of type stdClass as array in /srv/www/drupal/modules/feeds/libraries/common_syndication_parser.inc on line 276

when parsing feeds such as:

http://rss.gmane.org/gmane.linux.distributions.equinux.general

I assume all Gmane RSS feeds will fail using Feeds. Other feeds such as:

http://wiki.debian.org/RecentChanges?action=rss_rc&unique=1&ddiffs=1

fail with the same message. I'm using latest Drupal and Feeds modules.

bshelden’s picture

Issue tags: +ubuntu

I've run into this bug myself and I have a little more information.

I run into it when running on ubuntu 9.10 i386, but not on amd64. Same version of php (5.2.10.dfsg.1-2ubuntu6.4).

It's literally the same error
An error occurred. /ncceh/batch?id=10&op=do <br /> <b>Fatal error</b>: Cannot use object of type stdClass as array in <b>/var/www/ncceh/sites/all/modules/feeds/libraries/common_syndication_parser.inc</b> on line <b>276</b><br />
(That's how it appears when I add a new feed)

Also occurs when I manually compile apache (v2.2.14) and php (v5.2.13) on i386.

bshelden’s picture

Ok, a few code tweaks and it's working now:

--- common_syndication_parser.inc.orig	2010-01-28 11:57:54.000000000 -0800
+++ common_syndication_parser.inc	2010-03-01 17:09:55.423355608 -0800
@@ -272,6 +272,8 @@
       ),
     ));
 
+    $item = (array) $item;
+
     // Special handling for the title:
     $item['title'] = _parser_common_syndication_title($item['title'], $item['description']);
 
@@ -294,7 +296,9 @@
       // looks nicer in the mapper UI
       // @todo Revisit, not used with feedapi mapper anymore.
       $rdf_property = str_replace(':', '_', $rdf_property);
-      $item['rdf'][$rdf_property] = $rdf_value;
+      $item_rdf = (array) $item['rdf'];
+      $item_rdf[$rdf_property] = $rdf_value;
+      $item['rdf'] = (object) $item_rdf;
     }
 
     $parsed_source['items'][] = $item;

I have absolutely no idea why this runs on my amd64 box and not on i386...

anarcat’s picture

Status: Active » Needs work

Hey, would you look at that, a patch here! ;)

Please format the patch appropriately and change the issue status next time.

dave reid’s picture

Priority: Critical » Major

Not critical.

twistor’s picture

Assigned: mcaudy » Unassigned
Status: Needs work » Closed (fixed)
Issue tags: -ubuntu

This is an incredibly old issue. I just tested the science feed in question and it worked fine.

If someone still has a problem, please create a new issue.