Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#2 | feeds-hash-item-2787941-2.patch | 811 bytes | MegaChriz |
|
Comments
Comment #2
MegaChriz CreditAttribution: MegaChriz at WebCoo commented$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 inFeedsProcessor::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:
The attached patch adds type hinting for the
FeedsProcessor::hash()
method.Comment #3
vakulrai CreditAttribution: vakulrai as a volunteer and at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commentedI reviewed and applied the patch submitted by #2 and seems to be working fine.
Comment #4
MegaChriz CreditAttribution: MegaChriz at WebCoo commented@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.
Comment #5
jukka792 CreditAttribution: jukka792 as a volunteer commentedSimilar 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).
Comment #6
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedSo 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.