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
Comments
Comment #2
joachim commentedComment #3
leandro713 commentedI 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.
Comment #4
joachim commented> but it cannot also transform them into configuration data arrays
Ah! That was what I missed!
Comment #6
leandro713 commentedThe merge request replaces the
and
combination with a single iteration, while preserving the configuration
names as array keys.
Only configuration data containing a non-null
UUIDis passed to thedependency 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.
Comment #7
leandro713 commentedThe 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?