TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 169 of /var/www/html/web/modules/composer/cas/cas.module)

Created on 31 October 2022, over 2 years ago
Updated 26 March 2025, 11 days ago

Problem/Motivation

On Ajax loads of certain pages and content items, sometimes an ajax error occurs which seriously slows down the front-end. I have found this especially when opening the media library.

It yields the following error: "An AJAX HTTP error occurred.\nHTTP Result Code: 200\nDebugging information follows.\nPath: /user/170563/edit?ajax_form=1\nStatusText: OK\nResponseText: TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 169 of /var/www/html/web/modules/composer/cas/cas.module)."

Steps to reproduce

Install the CAS module, and then click on a field that loads the media library via Ajax.

Proposed resolution

The fix is quite simple. Based on code found here πŸ› TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 580 of modules/contrib/gin_lb/gin_lb.module) Fixed , all that we need to do is change the line 169. It is currently written as:
if (in_array('::save', $form_state->getTriggeringElement()['#submit'])) {
The following change to this line fixes the problem:
if (!empty($form_state->getTriggeringElement()['#submit']) && in_array('::save', $form_state->getTriggeringElement()['#submit'])) {

πŸ› Bug report
Status

Needs review

Version

3.0

Component

CAS

Created by

πŸ‡ΊπŸ‡ΈUnited States paramnida

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