Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
config_enforce-3305740
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
config_enforce-3305740
Commits
e027fd1e
Commit
e027fd1e
authored
3 years ago
by
Derek Laventure
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3248592
: Importing configs doesn't handle inter-module dependencies properly
parent
2b2ccc92
No related branches found
Branches containing commit
Tags
5.1.0
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ConfigImporter.php
+45
-1
45 additions, 1 deletion
src/ConfigImporter.php
with
45 additions
and
1 deletion
src/ConfigImporter.php
+
45
−
1
View file @
e027fd1e
...
...
@@ -3,6 +3,7 @@
namespace
Drupal\config_enforce
;
use
Drupal\Core\Config\ConfigImporter
as
CoreConfigImporter
;
use
Drupal\Core\Config\ConfigException
;
use
Drupal\Core\Config\InstallStorage
;
use
Drupal\Core\Config\StorageComparer
;
use
Drupal\config\StorageReplaceDataWrapper
;
...
...
@@ -42,7 +43,7 @@ class ConfigImporter {
// @TODO log whether config has changed?
return
$this
->
getConfig
Import
er
(
$storage_comparer
)
->
import
()
;
return
$this
->
do
Import
(
$storage_comparer
);
}
protected
function
getDataFromConfigFiles
(
$filenames
)
{
...
...
@@ -70,6 +71,49 @@ class ConfigImporter {
return
$config_data
;
}
// Copied from submitForm() at /core/modules/config/src/Form/ConfigSync.php
protected
function
doImport
(
$storage_comparer
)
{
$config_importer
=
$this
->
getConfigImporter
(
$storage_comparer
);
if
(
$config_importer
->
alreadyImporting
())
{
$this
->
log
()
->
warning
(
'Another request may be synchronizing configuration already.'
);
}
else
{
try
{
// This is the contents of \Drupal\Core\Config\ConfigImporter::import.
// Copied here so we can log progress.
if
(
$config_importer
->
hasUnprocessedConfigurationChanges
())
{
$sync_steps
=
$config_importer
->
initialize
();
foreach
(
$sync_steps
as
$step
)
{
$context
=
[];
do
{
$config_importer
->
doSyncStep
(
$step
,
$context
);
if
(
isset
(
$context
[
'message'
]))
{
$this
->
log
()
->
notice
(
str_replace
(
'Synchronizing'
,
'Synchronized'
,
(
string
)
$context
[
'message'
]));
}
}
while
(
$context
[
'finished'
]
<
1
);
}
// Clear the cache of the active config storage.
\Drupal
::
service
(
'cache.config'
)
->
deleteAll
();
}
if
(
$config_importer
->
getErrors
())
{
throw
new
ConfigException
(
'Errors occurred during import'
);
}
else
{
$this
->
log
()
->
notice
(
'The configuration was imported successfully.'
);
}
}
catch
(
ConfigException
$e
)
{
// Return a negative result for UI purposes. We do not differentiate
// between an actual synchronization error and a failed lock, because
// concurrent synchronizations are an edge-case happening only when
// multiple developers or site builders attempt to do it without
// coordinating.
$message
=
'The import failed due to the following reasons:'
.
"
\n
"
;
$message
.
=
implode
(
"
\n
"
,
$config_importer
->
getErrors
());
watchdog_exception
(
'config_import'
,
$e
);
throw
new
\Exception
(
$message
);
}
}
}
/**
* Return an instantiated ConfigImporter.
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment