Running cron had been failing for 24 hours with a time limit exceeded message displayed in watchdog. Running cron from the command line resulted in this error message: (more or less, forgot to grab a copy)

Fatal error: Cannot access empty property in /www/home/public_html/default/modules/feedapi_mapper/mappers/feedapi_mapper_date.inc on line 117

Examining mappers/feedapi_mapper_date.inc line 116-118 reads:

  if (!isset($node->{$field_name})) {
    $node->$field_name = array($date->value);
  }

I believe it should be:

  if (!isset($node->{$field_name})) {
    $node->field_name = array($date->value);
  }

(eliminating the $ before field_name on line 117)

I believe it has been this line of code causing my cron run to fail routinely on perhaps badly formatted RSS entries, but instead of handling the error the entire cron run fails. In the past I would manually update every RSS feed until I got past the offending entry.

Making the change above allowed my cron to complete for the first time in 24 hours so I'm quite confident this little $ has been the cause of my consistently broken website. *crosses fingers*

Since I have had this problem many times I am curious if others have experienced it. I do believe the code structure used worked in PHP4, but is no longer workable with PHP5.

CommentFileSizeAuthor
#4 543544_empty_property.patch766 bytesAron Novak
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

apaderno’s picture

Title: "Cannot access empty property" causes cron failure (solved?) » "Cannot access empty property" causes cron failure
Status: Needs review » Active
Aron Novak’s picture

Which version of PHP do you use? I tried out lots of constructs and it seems that in PHP5, $foo->$bar is still valid. I use PHP 5.2.6.

apaderno’s picture

  if (!isset($node->{$field_name})) {
    $node->field_name = array($date->value);
  }

is different from

  if (!isset($node->{$field_name})) {
    $node->$field_name = array($date->value);
  }

The first block would always set the property field_name, which is not what the code is supposed to do.
As far as I can see, $foo->$bar has been always a valid syntax, in PHP (PHP4, or PHP5).

Aron Novak’s picture

Status: Active » Needs review
FileSize
766 bytes

Can you test that this patch helps or not?

Aron Novak’s picture

Priority: Normal » Critical

This may affect FeedAPI mapper 2.0 beta 1. At least this patch does not hurt

apaderno’s picture

Version: 6.x-1.0 » 6.x-2.x-dev
Issue summary: View changes
Status: Needs review » Closed (outdated)

I am closing this issue because is for a branch that is now not supported. Only branches compatible with Drupal 7, Drupal 9, or Drupal 10 are now supported.