Setting a custom slot in global settings makes the edit form crash

Created on 22 May 2024, 8 months ago
Updated 23 May 2024, 8 months ago

Problem/Motivation

When setting a custom slot for AdTech Factory v2 types on /admin/structure/ad_entity/global-settings and saving, editing an ad entity crashes the page with the following error:

TypeError: array_column(): Argument #1 ($array) must be of type array, null given in array_column() (line 459 of modules/contrib/ad_entity/modules/ad_entity_adtech_v2/src/Plugin/ad_entity/AdType/AdtechType.php). 

In that file we have on line: 459

$all_slots = array_column($custom_slot['slots'], 'name') ?? array_column($custom_slot, 'name');

The null coalescing operator does not work there since $custom_slot['slots'] is not defined and passing null instead of an array to array_column causes the above exception.

Steps to reproduce

  • Set a custom slot for adtech factory v2 on global settings page
  • Try to edit an already existing ad entity that uses adtech factory v2

Proposed resolution

Change the code to use the null coalescing operator before passing the array to the array_column function, maybe even check if it's set just to be sure.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇸🇮Slovenia miha.wagner

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024