Problem/Motivation

ConfigManager::getConfigDependencyManager() has this:

    $data = array_map(function ($config) {
      $data = $config->get();
      if (isset($data['uuid'])) {
        return $data;
      }
      return FALSE;
    }, $this->configFactory->loadMultiple($this->activeStorage->listAll()));
    $dependency_manager->setData(array_filter($data));

If I'm reading this correctly, we're doing this:

1. Load all the config
2. Make this into an array where some of the values will be FALSE
3. Filter that

The $data array is not used again after this.

Why not combine both into a single array_filter() with a callback?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3623643

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

joachim created an issue. See original summary.

joachim’s picture

Issue summary: View changes
leandro713’s picture

I would like to work on this.

An array_filter() callback can filter the Config objects, but it
cannot also transform them into configuration data arrays. I propose
replacing the current array_map() and array_filter() combination
with a single foreach that only adds configuration containing a UUID,
while preserving the original configuration names as array keys.

joachim’s picture

> but it cannot also transform them into configuration data arrays

Ah! That was what I missed!

leandro713’s picture

Status: Active » Needs review

The merge request replaces the

 array_map() 

and

array_filter()

combination with a single iteration, while preserving the configuration
names as array keys.

Only configuration data containing a non-null UUID is passed to the
dependency manager.

Tests performed:

- ConfigDependencyTest
- PHPCS for ConfigManager.php

No new test was added because this is an internal refactoring covered
by the existing dependency tests.

leandro713’s picture

The pipeline failure is caused by the unrelated Nightwatch
jQueryUIPositionShimTest. This merge request only changes
ConfigManager.php.

Could someone with the required permissions retry
the failed Nightwatch job?