array_shift() expects parameter 1 to be array, null given in /var/www/likwid/test/www/sites/all/modules/contrib/feeds/includes/FeedsBatch.inc on line 110.
PHP 5.3 is quite intolerant with non initialized variables, and such things, but it forces developers to use some good practices.
This is how I would fix it (file FeedsBatch.inc, line 104):
/**
* @return
* Next available item or NULL if there is none. Every returned item is
* removed from the internal array.
*/
public function shiftItem() {
if (! empty($this->items)) {
return array_shift($this->items);
}
return NULL;
}
Comments
Comment #1
alex_b commentedThanks for reporting, needs to be fixed in head. Critical for next release.
Comment #2
Will White commentedHere's a patch for another solution that sets the
itemsproperty toarray()ifNULLis passed to the setter. Not sure which approach is better.Comment #3
Will White commentedForgot the patch!
Comment #4
Will White commentedUpdated patch that ensures the parser does not set the items property to NULL. Added documentation to setItems() method about how $items must be an array.
Comment #5
pounardKeep NULL, this is better, because the PHPdoc say so. If people started to write code based on this implementation, keep it. Changing the NULL return to an empty array is changing the API signature, you should avoid.
EDIT: Except if you consider you are in early development stage, and accept to break the API for course, this is your code.
Comment #6
alex_b commented#5:
Will did #5 actually according to my advice, I prefer making the API tighter at this point rather than feeling bound to the current doc. That's why we're in alpha mode: the rough API is laid out and stable, small changes to API are OK. Refactor over legacy creep.
In this particular case I'd say we should be clear in what's expected from parsers and keep sanitation to an absolute minimum, it's just going to be code that we need to maintain.
Comment #7
pounard@alex_b No problems, this was a suggestion, agree with you then. Hope it will be stable one day:)
Comment #8
alex_b commented#7: I owe everybody a road map (and I also owe you a response to functioning tests, still on my backlog :) - in the meantime I've started to tag beta critical issues as "beta blocker" http://drupal.org/project/issues/search/feeds?text=&assigned=&submitted=...
This is RTBC.
Comment #9
alex_b commentedCommitted, thank you for detailed report and repeated patch rolling.