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

Issue fork ad_entity-3449170

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

miha.wagner created an issue. See original summary.

miha.wagner’s picture

Status: Active » Needs review
StatusFileSize
new1.02 KB

I've created a merge request and added patch that fixes the issue. Maybe it would be better still to check if the value is an array, but since it's defined in the schema to be a sequence I considered that too paranoid.

mxh’s picture

Thanks for the report and provided patch. I'm currently looking for an active maintainer for this project and already asked in #3419628: Add Drupal Gitlab CI template. In case someone is interested in taking maintainership, it would be great to reach out.