Add null protector to PreferredCodeService

Created on 6 October 2022, about 2 years ago
Updated 18 September 2024, 2 months ago

Problem/Motivation

When there are no available cores in the subscription, or the core id is not in the list of possible search core ids, a warning is thrown for passing null value to the foreach at line 152 of PreferredCodeService ([warning] foreach() argument must be of type array|object, null given inPreferredCoreService.php:152). This is not a problem for the possible cores, as the event receives an empty array for the constructor, however the getAvailableCores() method can return NULL when there is no subscription data provided (possibly when it can't connect to Acquia Cloud?)

Steps to reproduce

Proposed resolution

Update line 149 of PreferredCoreService to $available_cores = $this->getAvailableCores() ?? []; to handle cases when there is a NULL returned from getAvailableCores(). (We could change the return value to an empty array, but it could be confusing as we wouldn't know if the client could connect to Acquia Cloud, or there are just no available cores.)

Remaining tasks

User interface changes

-

API changes

-

Data model changes

-

📌 Task
Status

Fixed

Version

3.1

Component

Code

Created by

🇭🇺Hungary balintpekker Budapest, Hungary

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

Merge Requests

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