Getting this warning when running `drush cim` in Drupal 9 ... seems this line in content_lock.module is evaluating to NULL:

$types = \Drupal::configFactory()->get('content_lock.settings')->get('types');

[warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install content_lock.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install datalayer.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install libraries.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install queue_ui.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install update.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install views_ui.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install admin_toolbar_search.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install feeds.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install feeds_ex.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install tamper.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install feeds_tamper.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install migrate_source_csv.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install migrate_source_ui.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install remote_stream_wrapper.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install d8unsw_cs.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install d8unsw_cs_utilities.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install d8unsw_cs_buildings_rooms.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install d8unsw_cs_events.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install d8unsw_cs_newsroom_news.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
 [notice] Synchronized extensions: install d8unsw_cs_resgate_utilities.
 [warning] array_filter() expects parameter 1 to be array, null given content_lock.module:238
 [warning] Invalid argument supplied for foreach() content_lock.module:238
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

jaydee1818 created an issue. See original summary.

mohit.bansal623 made their first commit to this issue’s fork.

mohit.bansal623’s picture

Status: Active » Needs review

Please review the merge request.

jaydee1818’s picture

Status: Needs review » Active
StatusFileSize
new1.97 KB

This patch performs checks before executing foreach.

mohit.bansal623’s picture

Status: Active » Needs review

@jaydee Moving it to Needs review as the merge request is already created and passed.

jaydee1818’s picture

StatusFileSize
new3.06 KB

No worries - looks good. I just made a slight change to check that $definition is set. I also need a patch for my project, so here it is.

jcisio’s picture

Status: Needs review » Needs work

I'm not sure if it is a bug. I think you updated to the latest version, but did not export the new config, instead you imported the old config (or maybe empty one).

This patch simply hides a bug (and potentially makes it worse).

capysara’s picture

I'm having the same issue. Everything was fine on my local, all my config was exported, no errors, but then I deployed to my dev environment and hit the errors listed above.

Update: I was able to use the patch successfully. It applied cleanly and allowed me to deploy code without any database errors. I'm not sure if this is the best way to address the issue (if there are deeper issues), but checking the settings for the entity type first seems harmless.

donquixote’s picture

I'm not sure if it is a bug. I think you updated to the latest version, but did not export the new config, instead you imported the old config (or maybe empty one).

The site should not completely crash if some config is not as expected or incomplete.
I don't even think we have an update hook that would introduce the 'types' setting.
I can't even go to a config page that would fix the problem.

harivenuv’s picture

Thanks for patch, #7 worked

idebr’s picture

Version: 8.x-2.2 » 8.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new439 bytes

Attached patch adds a type hint when loading the $types variable. This is harmless for 'correct' configuration, but will prevent 'invalid' configuration from triggering PHP errors.

saschaeggi’s picture

#7 worked for me

sime’s picture

Number 12 is a should be $types = (array) ... instead of (array) $types = ...

Edit: Oh i see it's a hint.

yovanny.gomez.oyola’s picture

StatusFileSize
new439 bytes

I'm agree whit @sime. Path number 12 does not work for me with PHP 8.1.

I add the patch with the adjustment.

smustgrave’s picture

Tried replicating in D10 but I'm not getting an errors or warning when running drush cim. Anyone still experiencing this?

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)

astonvictor made their first commit to this issue’s fork.

astonvictor’s picture

Version: 8.x-2.x-dev » 3.x-dev
astonvictor’s picture

Status: Postponed (maintainer needs more info) » Fixed

I was not able to reproduce it with 8.x and 3.x branches. Seems like there was a custom code that cleared values in the config.
anyway, added a simple fix.

thanks all for the support

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.