I am using feeds module with cron for periodic nodes update and i found this warning in the CRON report

Warning: array_intersect_key(): Argument #1 is not an array in FeedsProcessor->hash()

This warning is coming when the Arugemnt#1 of the hash() function is not an Array.
there is not check for the parameter type and this function is trying to run regardless of the type of the parameter.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

thomas salah created an issue. See original summary.

MegaChriz’s picture

Status: Active » Needs review
Issue tags: -bug
FileSize
811 bytes

$item should always be an array. Which parser are you using? It seems like that the parser is not returning the data in the right format when $parser_result->shiftItem() is executed in FeedsProcessor::process().

It could also be helpful to see your full Feeds importer configuration + a sample source file. Can you bundle the configuration you have in a feature module and provide a sample source file?

The feature module should ideally contain the following:

  • Your Feeds importer
  • Feeds Tamper configuration
  • The content type selected on the processor
  • Field bases of fields used on your content type
  • Field instances of your content type
  • Strongarm variables belonging to your content type (install the Strongarm module to make them available).
  • Eventually other exportable configuration that is related.

The attached patch adds type hinting for the FeedsProcessor::hash() method.

vakulrai’s picture

I reviewed and applied the patch submitted by #2 and seems to be working fine.

MegaChriz’s picture

Status: Needs review » Postponed (maintainer needs more info)

@vakulrai
Yes, the patch will work fine when using Feeds alone. The question is though, what the patch might break. According to the reported issue, sometimes an item is passed that is not an array. This could be a bug in the parser that is used, but it is also possible that there are valid cases for an item to not be an array and in that case the provided patch would introduce a backwards compatibility break. So before further action can be taken upon this issue, I need to see first how exactly the provided issue occurred. It looks like that thomas salah would be the only person who could tell us this.

jukka792’s picture

Similar issues here, getting when running cron:

Warning: array_intersect_key(): Argument #1 is not an array in function FeedsProcessor->hash() (line 1298 file ...FeedsProcessor.inc)

Haven't tried the #2 patch yet, but I can provide information if needed.

I can't see any differences between the JSON data which is working and which throws this error, all looks valid.

My Feeds (7.x-2.0-beta4) importer settings are:
Attach to content type: custom content type
periodic import: as often as possible
Fetcher: HTTP Fetcher
Parser: JSONPath parser
JSONPath parser: Context: $.[]
expressions: $.addresses[1].language
etc.
Processor: Self Node processor
Self Node processor settings: Do not insert new nodes
Update existing nodes: Update existing nodes
Skip hash check: unchecked

Tried to fix this by
-disabled feeds tamper module: didn't help.

More errors came when:
-Reduced the amount of mapped fields from 5 to 1 from /admin/structure/feeds/import_name/mapping
caused huge amount of errors like this:
Notice: Undefined index: jsonpath_parser:2 in FeedsJSONPathParser->parse() (line 90 of ../sites/all/modules/feeds_jsonpath_parser/FeedsJSONPathParser.inc).

EDIT:
applied the patch #2 and when running cron gives this error:
Recoverable fatal error: Argument 1 passed to FeedsProcessor::hash() must be of the type array, null given, called in /htdocs/sites/all/modules/feeds_selfnode_processor/FeedsSelfNodeProcessor.inc on line 29 and defined in FeedsProcessor->hash() (line 1296 of /apps/drupal/htdocs/sites/all/modules/feeds/plugins/FeedsProcessor.inc).

MegaChriz’s picture

So this sounds like this is an issue with Feeds Self Node Processor. When an import yields no results, Feeds Self Node Processor is trying to process an empty item?

https://cgit.drupalcode.org/feeds_selfnode_processor/tree/FeedsSelfNodeP...
$item = $parser_result->shiftItem();
If the parser result does not contain any items, $item is null. Feeds Self Node Processor should stop there.

If I'm right that that is the issue, this issue should be moved over to the Feeds Self Node Processor project.