summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorcatch <catch@35733.no-reply.drupal.org>2021-12-15 16:38:51 +0000
committercatch <catch@35733.no-reply.drupal.org>2021-12-15 16:38:51 +0000
commitd55c0cbd36efffbd5381d516bd6fe92a6933cad1 (patch)
treeb06c7173088625120001dd62bf014be5fc99ffd0
parentfd398939a8d2920359f09ec97721ce3d60e31fca (diff)
downloaddrupal-d55c0cbd36efffbd5381d516bd6fe92a6933cad1.tar.gz
drupal-d55c0cbd36efffbd5381d516bd6fe92a6933cad1.zip
Issue #3254403 by paulmckibben, ranjith_kumar_k_u, longwave, Lendude, cilefen: system_post_update_sort_all_config can exhaust PHP memory in 9.3.0
-rw-r--r--core/modules/system/system.post_update.php25
1 files changed, 22 insertions, 3 deletions
diff --git a/core/modules/system/system.post_update.php b/core/modules/system/system.post_update.php
index 0cc50521c1a4..7ddcda6476b2 100644
--- a/core/modules/system/system.post_update.php
+++ b/core/modules/system/system.post_update.php
@@ -5,6 +5,7 @@
* Post update functions for System.
*/
+use Drupal\Core\Site\Settings;
use Drupal\Core\Config\Entity\ConfigEntityUpdater;
use Drupal\Core\Entity\Display\EntityDisplayInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
@@ -208,9 +209,27 @@ function system_post_update_delete_authorize_settings() {
/**
* Sort all configuration according to its schema.
*/
-function system_post_update_sort_all_config() {
+function system_post_update_sort_all_config(&$sandbox) {
$factory = \Drupal::configFactory();
- foreach ($factory->listAll() as $name) {
- $factory->getEditable($name)->save();
+ $iteration_size = Settings::get('entity_update_batch_size', 50);
+
+ if (empty($sandbox['progress'])) {
+ $sandbox['progress'] = 0;
+ $sandbox['all_config_names'] = $factory->listAll();
+ $sandbox['max'] = count($sandbox['all_config_names']);
+ }
+
+ $start = $sandbox['progress'];
+ $end = min($sandbox['max'], $start + $iteration_size);
+ for ($i = $start; $i < $end; $i++) {
+ $factory->getEditable($sandbox['all_config_names'][$i])->save();
+ }
+
+ if ($sandbox['max'] > 0 && $end < $sandbox['max']) {
+ $sandbox['progress'] = $end;
+ $sandbox['#finished'] = ($end - 1) / $sandbox['max'];
+ }
+ else {
+ $sandbox['#finished'] = 1;
}
}