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.
A PHP Warning is triggered if an empty array is passed to node_view_multiple().
Documentation says that node_view_multiple() accepts "An array of nodes as returned by node_load_multiple()."
So, node_view_multiple() should be able to use any node_load_multiple() result without any kind of
conditional statements... But node_load_multiple() could return an empty array, which is not correctly used in node_view_multiple(), resulting with the following PHP Warning :
Warning: uasort() expects parameter 1 to be array, null given in node_view_multiple() (line 2679 of /modules/node/node.module).
Comment | File | Size | Author |
---|---|---|---|
uasort-expects-parameter-1-to-be-array.patch | 558 bytes | geoffray | |
Comments
Comment #2
peter.walter CreditAttribution: peter.walter commentedYour patch looks sensible, but please can you explain how to reproduce the error.
Comment #3
geoffray CreditAttribution: geoffray commentedHere is how to reproduce the error :
Comment #4
geoffray CreditAttribution: geoffray commentedComment #5
jweowu CreditAttribution: jweowu at Catalyst IT commentedConfirming the bug and the solution.
We could alternatively bail out early when $nodes is empty, but as it is very little processing actually happens in this scenario with the current patch, so I'm in favour of just committing it.
Comment #6
PolHello,
Thanks for the bug report and patch.
I confirm the bug and the patch is fixing the issue.
Comment #7
PolComment #8
joseph.olstadBumping to 7.61, this didn't make it into 7.60
Comment #9
joseph.olstadComment #10
joseph.olstadComment #11
PolComment #12
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedWe need to check if this is present in D8 first
Comment #13
jweowu CreditAttribution: jweowu at Catalyst IT commentedUgh. That policy simply shouldn't apply across the border between Drupal 7 and Drupal 8. The two codebases bear almost no resemblance to one another.
Comment #14
PolHi,
It's not a matter of codebase, we know that 7 and 8 are completely different.
It's about features. Even if it's a kind of bug fix, we must first see if it needs to be fixed in 8 then backport to 7.
Comment #15
PolComment #16
PolThis issue cannot be reproduced in D8, it can go in D7.
Comment #17
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedComment #19
PolFixed! Thanks all.