Problem/Motivation
There is a PHP 8 deprecation message in uc_cart_block_view():
Deprecated function: Automatic conversion of false to array is deprecated in uc_cart_block_view() (line 338 in /sites/all/modules/ubercart/uc_cart/uc_cart.module).
The problematic code - see the $items variable:
$items = FALSE;
...
if ($product_count) {
...
foreach (element_children($display_items['uc_cart_item']) as $key) {
...
if (count(element_children($display_item))) {
$items[] = array(
'nid' => $display_item['nid']['#value'],
'qty' => theme('uc_qty', array('qty' => $display_item['qty']['#default_value'])),
'title' => $display_item['title']['#markup'],
'price' => $display_item['#total'],
'desc' => isset($display_item['description']['#markup']) ? $display_item['description']['#markup'] : FALSE,
);
...
}
}
}
Steps to reproduce
Proposed resolution
Change the $items variable to array.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
poker10 commentedAttached patch should fix the problem.
Comment #3
poker10 commentedComment #5
tr commentedThis fix was put into the D8 version of Ubercart 9 years ago (tomorrow) by commit eebd551993e12 (no associated issue). I don't know why that wasn't backported at the time. I mention this because the general rule is to put fixes into the highest version first, then backport those fixes if necessary. If D7 is going to get fixes like this I want to be sure that the same fix goes into D8, or if D8 already has the fix I want to be sure that the D7 fix is done in the same way. This patch does make the same change as was already made in the 8.x-4.x branch.
Committed. Thanks.
Comment #7
anaconda777 commentedI have this error still with PHP 8.1
PHP 8.0 does not create the error anymore with the patch.