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

CommentFileSizeAuthor
#2 3324072-2.patch360 bytespoker10

Comments

poker10 created an issue. See original summary.

poker10’s picture

Status: Active » Needs review
StatusFileSize
new360 bytes

Attached patch should fix the problem.

poker10’s picture

Issue summary: View changes

  • TR committed 483c0f6 on 7.x-3.x
    Issue #3324072 by poker10: Deprecated function: Automatic conversion of...
tr’s picture

Status: Needs review » Fixed

This 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

anaconda777’s picture

I have this error still with PHP 8.1
PHP 8.0 does not create the error anymore with the patch.