diff --git a/core/modules/system/src/Tests/Update/PathAliasUpdateTest.php b/core/modules/system/src/Tests/Update/PathAliasUpdateTest.php index 87156bc..d824ff9 100644 --- a/core/modules/system/src/Tests/Update/PathAliasUpdateTest.php +++ b/core/modules/system/src/Tests/Update/PathAliasUpdateTest.php @@ -10,7 +10,7 @@ use Drupal\Core\Language\LanguageInterface; /** - * Tests system_update_8012(). + * Tests system_post_update_path_alias_lowercase(). * * @group Update */ @@ -26,7 +26,7 @@ protected function setDatabaseDumpFiles() { } /** - * Ensures that the system_update_8012() runs as expected. + * Ensures that system_post_update_path_alias_lowercase() runs as expected. */ public function testUpdate() { $connection = \Drupal::database(); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index da34040..47f6dca 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1808,37 +1808,5 @@ function system_update_8011() { } /** - * Load and save all path aliases to make sure they are lower case. - */ -function system_update_8012(&$sandbox = NULL) { - // The path alias storage interface has no way to count or iterate over all - // aliases, so we have to fall back to SQL for this function. - /** @var \Drupal\Core\Path\AliasStorageInterface $alias_storage */ - $alias_storage = \Drupal::service('path.alias_storage'); - $connection = \Drupal::database(); - $schema = $connection->schema(); - if ($schema->tableExists('url_alias')) { - if (!isset($sandbox['current'])) { - $sandbox['current'] = 0; - $sandbox['max'] = $connection->query('SELECT COUNT(pid) FROM {url_alias}') - ->fetchField(); - } - $aliases = $connection->queryRange('SELECT pid, source, alias, langcode FROM {url_alias} ORDER BY pid ASC', $sandbox['current'], $sandbox['current'] + 50) - ->fetchAllAssoc('pid', PDO::FETCH_ASSOC); - - foreach ($aliases as $alias) { - $alias_storage->save($alias['source'], $alias['alias'], $alias['langcode'], $alias['pid']); - $sandbox['current']++; - } - - $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['current'] / $sandbox['max']); - return t('Path aliases converted'); - } - else { - return t('Path alias conversion skipped, because the {url_alias} table did not exist.'); - } -} - -/** * @} End of "addtogroup updates-8.0.0-beta". */ diff --git a/core/modules/system/system.post_update.php b/core/modules/system/system.post_update.php index 3a141ce..7dc74df 100644 --- a/core/modules/system/system.post_update.php +++ b/core/modules/system/system.post_update.php @@ -31,5 +31,37 @@ function system_post_update_fix_enforced_dependencies() { } /** + * Load and save all path aliases to make sure they are lower case. + */ +function system_post_update_path_alias_lowercase(&$sandbox = NULL) { + // The path alias storage interface has no way to count or iterate over all + // aliases, so we have to fall back to SQL for this function. + /** @var \Drupal\Core\Path\AliasStorageInterface $alias_storage */ + $alias_storage = \Drupal::service('path.alias_storage'); + $connection = \Drupal::database(); + $schema = $connection->schema(); + if ($schema->tableExists('url_alias')) { + if (!isset($sandbox['current'])) { + $sandbox['current'] = 0; + $sandbox['max'] = $connection->query('SELECT COUNT(pid) FROM {url_alias}') + ->fetchField(); + } + $aliases = $connection->queryRange('SELECT pid, source, alias, langcode FROM {url_alias} ORDER BY pid ASC', $sandbox['current'], $sandbox['current'] + 50) + ->fetchAllAssoc('pid', PDO::FETCH_ASSOC); + + foreach ($aliases as $alias) { + $alias_storage->save($alias['source'], $alias['alias'], $alias['langcode'], $alias['pid']); + $sandbox['current']++; + } + + $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['current'] / $sandbox['max']); + return t('Path aliases converted'); + } + else { + return t('Path alias conversion skipped, because the {url_alias} table did not exist.'); + } +} + +/** * @} End of "addtogroup updates-8.0.0-beta". */