Trying to access array offset on value of type null in template_preprocess_dc_ajax_shopping_cart_teaser() after updating to php7.4

Created on 6 December 2020, almost 4 years ago
Updated 29 November 2023, 12 months ago

Problem/Motivation

My logs are packed with thousands of these:

Notice: Trying to access array offset on value of type null in template_preprocess_dc_ajax_shopping_cart_teaser() (line 612 of /var/www/html/sites/all/modules/dc_ajax_add_cart/dc_ajax_add_cart.module)

It looks like this is caused when new users visit the site for the first time and have nothing in their cart.

Steps to reproduce

Add nothing to your cart and then load the page as a new session (in a private window or whatever).

Proposed resolution

Check if that object is null and default to 0 when setting product_price_total? Not sure if this would cause any other problems.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇳🇿New Zealand fraserthompson Dunedin, New Zealand

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024