Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.
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
Comment | File | Size | Author |
---|---|---|---|
#3 | 3449170-setting-a-custom-slot-crashes.patch | 1.02 KB | miha.wagner |
Issue fork ad_entity-3449170
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
Comment #3
miha.wagner CreditAttribution: miha.wagner as a volunteer commentedI'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.
Comment #4
mxhThanks 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.