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 was using the relatedcontent_get_nodes()
function and was getting the error when the function was passed a node that had no relatedcontent nodes.
warning: asort() expects parameter 1 to be array, null given in /Library/WebServer/Documents/staff-6.15/sites/all/modules/relatedcontent/relatedcontent.module on line 63.
I've made minor improvements to the relatedcontent_get_nodes() function and attached a patch. The improved code ensures that even if there are no relatedcontent nodes an empty array will be returned (instead of NULL).
Comment | File | Size | Author |
---|---|---|---|
#3 | relatedcontent-731878-relatedcontent_get_nodes_function_error-3.patch | 1015 bytes | dooug |
#1 | relatedcontent_731878_api_improvement_1.patch | 757 bytes | dooug |
Comments
Comment #1
dooug CreditAttribution: dooug commentedOops! Forgot to attach the patch. It patches the 6.x-1.x-dev version
Comment #2
dooug CreditAttribution: dooug commentedComment #3
dooug CreditAttribution: dooug commented(revisiting my old issues)
Re-rolled this patch properly. It seems to still be a valid improvement to the function
relatedcontent_get_nodes()
.