Properly apply cache metadata

Created on 28 September 2022, over 2 years ago
Updated 24 October 2024, 6 months ago

Problem/Motivation

/user/login gives an error when you cleared all caches and visit it anonymously. The following error is triggered:

The website encountered an unexpected error. Please try again later.
TypeError: array_merge(): Argument #1 must be of type array, null given in array_merge() (line 224 of modules/contrib/cas/cas.module).
array_merge() (Line: 224)
cas_form_user_login_form_alter() (Line: 562)

Steps to reproduce

Run a website with the cas module on php 8.1, clear caches and go to /user/login.

Proposed resolution

Make sure you don't put null into the array_merge function, but an empty array.

Replace the following code in cas.module on line 224:

// Cached form must be busted if we alter CAS settings.
  $form['#cache']['tags'] = array_merge($form['#cache']['tags'], $config->getCacheTags());

with

// Cached form must be busted if we alter CAS settings.
  $form['#cache']['tags'] = array_merge($form['#cache']['tags'] ?? [], $config->getCacheTags());
πŸ› Bug report
Status

Needs review

Version

3.0

Component

CAS

Created by

πŸ‡³πŸ‡±Netherlands Krilo_89

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