Issue #3318581 by andypost, alexpott: FIx \Drupal\Core\Config\ConfigImporter::doSyncStep() to accept callable

merge-requests/2560/merge
catch 2022-11-02 17:38:55 +00:00
parent cf3ae0f90d
commit fcf0932d6a
2 changed files with 3 additions and 3 deletions

View File

@ -507,13 +507,13 @@ class ConfigImporter {
* Exception thrown if the $sync_step can not be called.
*/
public function doSyncStep($sync_step, &$context) {
if (!is_array($sync_step) && method_exists($this, $sync_step)) {
if (is_string($sync_step) && method_exists($this, $sync_step)) {
\Drupal::service('config.installer')->setSyncing(TRUE);
$this->$sync_step($context);
}
elseif (is_callable($sync_step)) {
\Drupal::service('config.installer')->setSyncing(TRUE);
call_user_func_array($sync_step, [&$context, $this]);
$sync_step($context, $this);
}
else {
throw new \InvalidArgumentException('Invalid configuration synchronization step');

View File

@ -822,7 +822,7 @@ class ConfigImporterTest extends KernelTestBase {
public function testCustomStep() {
$this->assertFalse(\Drupal::isConfigSyncing(), 'Before an import \Drupal::isConfigSyncing() returns FALSE');
$context = [];
$this->configImporter()->doSyncStep([self::class, 'customStep'], $context);
$this->configImporter()->doSyncStep(self::customStep(...), $context);
$this->assertTrue($context['is_syncing'], 'Inside a custom step \Drupal::isConfigSyncing() returns TRUE');
$this->assertFalse(\Drupal::isConfigSyncing(), 'After an valid custom step \Drupal::isConfigSyncing() returns FALSE');
}