Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/system/system.install @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
9 use Drupal\Component\Utility\Environment; | 9 use Drupal\Component\Utility\Environment; |
10 use Drupal\Component\FileSystem\FileSystem; | 10 use Drupal\Component\FileSystem\FileSystem; |
11 use Drupal\Component\Utility\OpCodeCache; | 11 use Drupal\Component\Utility\OpCodeCache; |
12 use Drupal\Component\Utility\Unicode; | 12 use Drupal\Component\Utility\Unicode; |
13 use Drupal\Core\Cache\Cache; | 13 use Drupal\Core\Cache\Cache; |
14 use Drupal\Core\File\FileSystemInterface; | |
14 use Drupal\Core\Path\AliasStorage; | 15 use Drupal\Core\Path\AliasStorage; |
15 use Drupal\Core\Url; | 16 use Drupal\Core\Url; |
16 use Drupal\Core\Database\Database; | 17 use Drupal\Core\Database\Database; |
17 use Drupal\Core\Entity\ContentEntityTypeInterface; | 18 use Drupal\Core\Entity\ContentEntityTypeInterface; |
18 use Drupal\Core\Entity\EntityTypeInterface; | 19 use Drupal\Core\Entity\EntityTypeInterface; |
21 use Drupal\Core\Extension\Extension; | 22 use Drupal\Core\Extension\Extension; |
22 use Drupal\Core\Field\BaseFieldDefinition; | 23 use Drupal\Core\Field\BaseFieldDefinition; |
23 use Drupal\Core\Site\Settings; | 24 use Drupal\Core\Site\Settings; |
24 use Drupal\Core\StreamWrapper\PrivateStream; | 25 use Drupal\Core\StreamWrapper\PrivateStream; |
25 use Drupal\Core\StreamWrapper\PublicStream; | 26 use Drupal\Core\StreamWrapper\PublicStream; |
26 use Drupal\system\SystemRequirements; | |
27 use Symfony\Component\HttpFoundation\Request; | 27 use Symfony\Component\HttpFoundation\Request; |
28 | 28 |
29 /** | 29 /** |
30 * Implements hook_requirements(). | 30 * Implements hook_requirements(). |
31 */ | 31 */ |
143 if ($rewrite_error) { | 143 if ($rewrite_error) { |
144 $requirements['Apache version'] = [ | 144 $requirements['Apache version'] = [ |
145 'title' => t('Apache version'), | 145 'title' => t('Apache version'), |
146 'value' => $apache_version_string, | 146 'value' => $apache_version_string, |
147 'severity' => REQUIREMENT_ERROR, | 147 'severity' => REQUIREMENT_ERROR, |
148 'description' => t('The minimum version of Apache needed to run Drupal without mod_rewrite enabled is 2.2.16. See the <a href=":link">enabling clean URLs</a> page for more information on mod_rewrite.', [':link' => 'http://drupal.org/node/15365']), | 148 'description' => t('The minimum version of Apache needed to run Drupal without mod_rewrite enabled is 2.2.16. See the <a href=":link">enabling clean URLs</a> page for more information on mod_rewrite.', [':link' => 'http://drupal.org/docs/8/clean-urls-in-drupal-8']), |
149 ]; | 149 ]; |
150 } | 150 } |
151 | 151 |
152 if (!$rewrite_error && !$rewrite_warning) { | 152 if (!$rewrite_error && !$rewrite_warning) { |
153 $requirements['rewrite_module'] = [ | 153 $requirements['rewrite_module'] = [ |
154 'title' => t('Clean URLs'), | 154 'title' => t('Clean URLs'), |
155 'value' => t('Disabled'), | 155 'value' => t('Disabled'), |
156 'severity' => REQUIREMENT_WARNING, | 156 'severity' => REQUIREMENT_WARNING, |
157 'description' => t('Your server is capable of using clean URLs, but it is not enabled. Using clean URLs gives an improved user experience and is recommended. <a href=":link">Enable clean URLs</a>', [':link' => 'http://drupal.org/node/15365']), | 157 'description' => t('Your server is capable of using clean URLs, but it is not enabled. Using clean URLs gives an improved user experience and is recommended. <a href=":link">Enable clean URLs</a>', [':link' => 'http://drupal.org/docs/8/clean-urls-in-drupal-8']), |
158 ]; | 158 ]; |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 // Verify the user is running a supported PHP version. | 162 // Verify the user is running a supported PHP version. |
183 'description' => t('The phpinfo() function has been disabled for security reasons. To see your server\'s phpinfo() information, change your PHP settings or contact your server administrator. For more information, <a href=":phpinfo">Enabling and disabling phpinfo()</a> handbook page.', [':phpinfo' => 'https://www.drupal.org/node/243993']), | 183 'description' => t('The phpinfo() function has been disabled for security reasons. To see your server\'s phpinfo() information, change your PHP settings or contact your server administrator. For more information, <a href=":phpinfo">Enabling and disabling phpinfo()</a> handbook page.', [':phpinfo' => 'https://www.drupal.org/node/243993']), |
184 'severity' => REQUIREMENT_INFO, | 184 'severity' => REQUIREMENT_INFO, |
185 ]; | 185 ]; |
186 } | 186 } |
187 | 187 |
188 if (version_compare($phpversion, DRUPAL_MINIMUM_PHP) < 0) { | 188 // Check if the PHP version is below what Drupal supports. |
189 $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => DRUPAL_MINIMUM_PHP]); | 189 if (version_compare($phpversion, DRUPAL_MINIMUM_SUPPORTED_PHP) < 0) { |
190 $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version. It is recommended to upgrade to PHP version %recommended or higher for the best ongoing support. See <a href="http://php.net/supported-versions.php">PHP\'s version support documentation</a> and the <a href=":php_requirements">Drupal 8 PHP requirements handbook page</a> for more information.', | |
191 [ | |
192 '%version' => DRUPAL_MINIMUM_SUPPORTED_PHP, | |
193 '%recommended' => DRUPAL_RECOMMENDED_PHP, | |
194 ':php_requirements' => 'https://www.drupal.org/docs/8/system-requirements/php', | |
195 ] | |
196 ); | |
190 $requirements['php']['severity'] = REQUIREMENT_ERROR; | 197 $requirements['php']['severity'] = REQUIREMENT_ERROR; |
191 // If PHP is old, it's not safe to continue with the requirements check. | 198 |
192 return $requirements; | 199 // If the PHP version is also below the absolute minimum allowed, it's not |
193 } | 200 // safe to continue with the requirements check. |
194 if ((version_compare($phpversion, DRUPAL_RECOMMENDED_PHP) < 0) && ($phase === 'install' || $phase === 'runtime')) { | 201 if (version_compare($phpversion, DRUPAL_MINIMUM_PHP) < 0) { |
195 // Warn if still on PHP 5. If at least PHP 7.0, relax from "warning" to | 202 return $requirements; |
196 // "info", and show it at runtime only, to not scare users while installing. | 203 } |
197 if (version_compare($phpversion, '7.0') < 0) { | 204 // Otherwise downgrade the error to a warning during updates. Even if there |
198 $requirements['php']['description'] = t('Drupal will drop support for this version on March 6, 2019. Upgrade to PHP version %recommended or higher to ensure your site can receive updates and remain secure. See <a href="http://php.net/supported-versions.php">PHP\'s version support documentation</a> and the <a href=":php_requirements">Drupal 8 PHP requirements handbook page</a> for more information.', ['%recommended' => DRUPAL_RECOMMENDED_PHP, ':php_requirements' => 'https://www.drupal.org/docs/8/system-requirements/php']); | 205 // are some problems with the site's PHP version, it's still better for the |
206 // site to keep its Drupal codebase up to date. | |
207 elseif ($phase === 'update') { | |
199 $requirements['php']['severity'] = REQUIREMENT_WARNING; | 208 $requirements['php']['severity'] = REQUIREMENT_WARNING; |
200 } | 209 } |
201 else { | 210 // Since we allow sites with unsupported PHP versions to still run Drupal |
202 if ($phase === 'runtime') { | 211 // updates, we also need to be able to run tests with those PHP versions, |
203 $requirements['php']['description'] = t('It is recommended to upgrade to PHP version %recommended or higher for the best ongoing support. See <a href="http://php.net/supported-versions.php">PHP\'s version support documentation</a> and the <a href=":php_requirements">Drupal 8 PHP requirements handbook page</a> for more information.', ['%recommended' => DRUPAL_RECOMMENDED_PHP, ':php_requirements' => 'https://www.drupal.org/docs/8/system-requirements/php']); | 212 // which requires the ability to install test sites. Not all tests are |
204 $requirements['php']['severity'] = REQUIREMENT_INFO; | 213 // required to pass on these PHP versions, but we want to monitor which |
205 } | 214 // ones do and don't. |
206 } | 215 elseif ($phase === 'install' && drupal_valid_test_ua()) { |
207 } | 216 $requirements['php']['severity'] = REQUIREMENT_INFO; |
208 | 217 } |
209 // Suggest to update to at least 5.5.21 or 5.6.5 for disabling multiple | 218 } |
210 // statements. | 219 // For PHP versions that are still supported but no longer recommended, |
211 if (($phase === 'install' || \Drupal::database()->driver() === 'mysql') && !SystemRequirements::phpVersionWithPdoDisallowMultipleStatements($phpversion)) { | 220 // inform users of what's recommended, allowing them to take action before it |
212 $requirements['php_multiple_statement'] = [ | 221 // becomes urgent. |
213 'title' => t('PHP (multiple statement disabling)'), | 222 elseif ($phase === 'runtime' && version_compare($phpversion, DRUPAL_RECOMMENDED_PHP) < 0) { |
214 'value' => $phpversion_label, | 223 $requirements['php']['description'] = t('It is recommended to upgrade to PHP version %recommended or higher for the best ongoing support. See <a href="http://php.net/supported-versions.php">PHP\'s version support documentation</a> and the <a href=":php_requirements">Drupal 8 PHP requirements handbook page</a> for more information.', ['%recommended' => DRUPAL_RECOMMENDED_PHP, ':php_requirements' => 'https://www.drupal.org/docs/8/system-requirements/php']); |
215 'description' => t('PHP versions higher than 5.6.5 or 5.5.21 provide built-in SQL injection protection for mysql databases. It is recommended to update.'), | 224 $requirements['php']['severity'] = REQUIREMENT_INFO; |
216 'severity' => REQUIREMENT_INFO, | |
217 ]; | |
218 } | 225 } |
219 | 226 |
220 // Test for PHP extensions. | 227 // Test for PHP extensions. |
221 $requirements['php_extensions'] = [ | 228 $requirements['php_extensions'] = [ |
222 'title' => t('PHP extensions'), | 229 'title' => t('PHP extensions'), |
307 $open_basedir_paths = explode(PATH_SEPARATOR, $open_basedir); | 314 $open_basedir_paths = explode(PATH_SEPARATOR, $open_basedir); |
308 $open_basedir_blocks_urandom = !array_intersect(['/dev', '/dev/', '/dev/urandom'], $open_basedir_paths); | 315 $open_basedir_blocks_urandom = !array_intersect(['/dev', '/dev/', '/dev/urandom'], $open_basedir_paths); |
309 } | 316 } |
310 } | 317 } |
311 $args = [ | 318 $args = [ |
312 ':drupal-php' => 'https://www.drupal.org/docs/7/system-requirements/php#csprng', | 319 ':drupal-php' => 'https://www.drupal.org/docs/8/system-requirements/php-requirements', |
313 '%exception_message' => $e->getMessage(), | 320 '%exception_message' => $e->getMessage(), |
314 ]; | 321 ]; |
315 if ($open_basedir_blocks_urandom) { | 322 if ($open_basedir_blocks_urandom) { |
316 $requirements['php_random_bytes']['description'] = t('Drupal is unable to generate highly randomized numbers, which means certain security features like password reset URLs are not as secure as they should be. Instead, only a slow, less-secure fallback generator is available. The most likely cause is that open_basedir restrictions are in effect and /dev/urandom is not on the whitelist. See the <a href=":drupal-php">system requirements</a> page for more information. %exception_message', $args); | 323 $requirements['php_random_bytes']['description'] = t('Drupal is unable to generate highly randomized numbers, which means certain security features like password reset URLs are not as secure as they should be. Instead, only a slow, less-secure fallback generator is available. The most likely cause is that open_basedir restrictions are in effect and /dev/urandom is not on the whitelist. See the <a href=":drupal-php">system requirements</a> page for more information. %exception_message', $args); |
317 } | 324 } |
626 if (!empty($GLOBALS['config_directories'])) { | 633 if (!empty($GLOBALS['config_directories'])) { |
627 foreach (array_keys(array_filter($GLOBALS['config_directories'])) as $type) { | 634 foreach (array_keys(array_filter($GLOBALS['config_directories'])) as $type) { |
628 $directory = config_get_config_directory($type); | 635 $directory = config_get_config_directory($type); |
629 // If we're installing Drupal try and create the config sync directory. | 636 // If we're installing Drupal try and create the config sync directory. |
630 if (!is_dir($directory) && $phase == 'install') { | 637 if (!is_dir($directory) && $phase == 'install') { |
631 file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); | 638 \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS); |
632 } | 639 } |
633 if (!is_dir($directory)) { | 640 if (!is_dir($directory)) { |
634 if ($phase == 'install') { | 641 if ($phase == 'install') { |
635 $description = t('An automated attempt to create the directory %directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', ['%directory' => $directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']); | 642 $description = t('An automated attempt to create the directory %directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', ['%directory' => $directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']); |
636 } | 643 } |
663 foreach ($directories as $directory) { | 670 foreach ($directories as $directory) { |
664 if (!$directory) { | 671 if (!$directory) { |
665 continue; | 672 continue; |
666 } | 673 } |
667 if ($phase == 'install') { | 674 if ($phase == 'install') { |
668 file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); | 675 \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS); |
669 } | 676 } |
670 $is_writable = is_writable($directory); | 677 $is_writable = is_writable($directory); |
671 $is_directory = is_dir($directory); | 678 $is_directory = is_dir($directory); |
672 if (!$is_writable || !$is_directory) { | 679 if (!$is_writable || !$is_directory) { |
673 $description = ''; | 680 $description = ''; |
678 else { | 685 else { |
679 $error = t('The directory %directory is not writable.', ['%directory' => $directory]); | 686 $error = t('The directory %directory is not writable.', ['%directory' => $directory]); |
680 } | 687 } |
681 // The files directory requirement check is done only during install and runtime. | 688 // The files directory requirement check is done only during install and runtime. |
682 if ($phase == 'runtime') { | 689 if ($phase == 'runtime') { |
683 $description = t('You may need to set the correct directory at the <a href=":admin-file-system">file system settings page</a> or change the current directory\'s permissions so that it is writable.', [':admin-file-system' => \Drupal::url('system.file_system_settings')]); | 690 $description = t('You may need to set the correct directory at the <a href=":admin-file-system">file system settings page</a> or change the current directory\'s permissions so that it is writable.', [':admin-file-system' => Url::fromRoute('system.file_system_settings')->toString()]); |
684 } | 691 } |
685 elseif ($phase == 'install') { | 692 elseif ($phase == 'install') { |
686 // For the installer UI, we need different wording. 'value' will | 693 // For the installer UI, we need different wording. 'value' will |
687 // be treated as version, so provide none there. | 694 // be treated as version, so provide none there. |
688 $description = t('An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', [':handbook_url' => 'https://www.drupal.org/server-permissions']); | 695 $description = t('An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', [':handbook_url' => 'https://www.drupal.org/server-permissions']); |
742 } | 749 } |
743 | 750 |
744 if ($has_pending_updates) { | 751 if ($has_pending_updates) { |
745 $requirements['update']['severity'] = REQUIREMENT_ERROR; | 752 $requirements['update']['severity'] = REQUIREMENT_ERROR; |
746 $requirements['update']['value'] = t('Out of date'); | 753 $requirements['update']['value'] = t('Out of date'); |
747 $requirements['update']['description'] = t('Some modules have database schema updates to install. You should run the <a href=":update">database update script</a> immediately.', [':update' => \Drupal::url('system.db_update')]); | 754 $requirements['update']['description'] = t('Some modules have database schema updates to install. You should run the <a href=":update">database update script</a> immediately.', [':update' => Url::fromRoute('system.db_update')->toString()]); |
748 } | 755 } |
749 | 756 |
750 $requirements['entity_update'] = [ | 757 $requirements['entity_update'] = [ |
751 'title' => t('Entity/field definitions'), | 758 'title' => t('Entity/field definitions'), |
752 'value' => t('Up to date'), | 759 'value' => t('Up to date'), |
802 if (version_compare($php, PHP_VERSION, '>')) { | 809 if (version_compare($php, PHP_VERSION, '>')) { |
803 $requirements['php']['description'] .= t('@name requires at least PHP @version.', ['@name' => $name, '@version' => $php]); | 810 $requirements['php']['description'] .= t('@name requires at least PHP @version.', ['@name' => $name, '@version' => $php]); |
804 $requirements['php']['severity'] = REQUIREMENT_ERROR; | 811 $requirements['php']['severity'] = REQUIREMENT_ERROR; |
805 } | 812 } |
806 // Check the module's required modules. | 813 // Check the module's required modules. |
814 /** @var \Drupal\Core\Extension\Dependency $requirement */ | |
807 foreach ($file->requires as $requirement) { | 815 foreach ($file->requires as $requirement) { |
808 $required_module = $requirement['name']; | 816 $required_module = $requirement->getName(); |
809 // Check if the module exists. | 817 // Check if the module exists. |
810 if (!isset($files[$required_module])) { | 818 if (!isset($files[$required_module])) { |
811 $requirements["$module-$required_module"] = [ | 819 $requirements["$module-$required_module"] = [ |
812 'title' => t('Unresolved dependency'), | 820 'title' => t('Unresolved dependency'), |
813 'description' => t('@name requires this module.', ['@name' => $name]), | 821 'description' => t('@name requires this module.', ['@name' => $name]), |
818 } | 826 } |
819 // Check for an incompatible version. | 827 // Check for an incompatible version. |
820 $required_file = $files[$required_module]; | 828 $required_file = $files[$required_module]; |
821 $required_name = $required_file->info['name']; | 829 $required_name = $required_file->info['name']; |
822 $version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $required_file->info['version']); | 830 $version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $required_file->info['version']); |
823 $compatibility = drupal_check_incompatibility($requirement, $version); | 831 if (!$requirement->isCompatible($version)) { |
824 if ($compatibility) { | |
825 $compatibility = rtrim(substr($compatibility, 2), ')'); | |
826 $requirements["$module-$required_module"] = [ | 832 $requirements["$module-$required_module"] = [ |
827 'title' => t('Unresolved dependency'), | 833 'title' => t('Unresolved dependency'), |
828 'description' => t('@name requires this module and version. Currently using @required_name version @version', ['@name' => $name, '@required_name' => $required_name, '@version' => $version]), | 834 'description' => t('@name requires this module and version. Currently using @required_name version @version', ['@name' => $name, '@required_name' => $required_name, '@version' => $version]), |
829 'value' => t('@required_name (Version @compatibility required)', ['@required_name' => $required_name, '@compatibility' => $compatibility]), | 835 'value' => t('@required_name (Version @compatibility required)', ['@required_name' => $required_name, '@compatibility' => $requirement->getConstraintString()]), |
830 'severity' => REQUIREMENT_ERROR, | 836 'severity' => REQUIREMENT_ERROR, |
831 ]; | 837 ]; |
832 continue; | 838 continue; |
833 } | 839 } |
834 } | 840 } |
882 $requirements['update status'] = [ | 888 $requirements['update status'] = [ |
883 'value' => t('Not enabled'), | 889 'value' => t('Not enabled'), |
884 'severity' => REQUIREMENT_WARNING, | 890 'severity' => REQUIREMENT_WARNING, |
885 'description' => t('Update notifications are not enabled. It is <strong>highly recommended</strong> that you enable the Update Manager module from the <a href=":module">module administration page</a> in order to stay up-to-date on new releases. For more information, <a href=":update">Update status handbook page</a>.', [ | 891 'description' => t('Update notifications are not enabled. It is <strong>highly recommended</strong> that you enable the Update Manager module from the <a href=":module">module administration page</a> in order to stay up-to-date on new releases. For more information, <a href=":update">Update status handbook page</a>.', [ |
886 ':update' => 'https://www.drupal.org/documentation/modules/update', | 892 ':update' => 'https://www.drupal.org/documentation/modules/update', |
887 ':module' => \Drupal::url('system.modules_list'), | 893 ':module' => Url::fromRoute('system.modules_list')->toString(), |
888 ]), | 894 ]), |
889 ]; | 895 ]; |
890 } | 896 } |
891 else { | 897 else { |
892 $requirements['update status'] = [ | 898 $requirements['update status'] = [ |
911 $trusted_host_patterns = Settings::get('trusted_host_patterns'); | 917 $trusted_host_patterns = Settings::get('trusted_host_patterns'); |
912 if (empty($trusted_host_patterns)) { | 918 if (empty($trusted_host_patterns)) { |
913 $requirements['trusted_host_patterns'] = [ | 919 $requirements['trusted_host_patterns'] = [ |
914 'title' => t('Trusted Host Settings'), | 920 'title' => t('Trusted Host Settings'), |
915 'value' => t('Not enabled'), | 921 'value' => t('Not enabled'), |
916 'description' => t('The trusted_host_patterns setting is not configured in settings.php. This can lead to security vulnerabilities. It is <strong>highly recommended</strong> that you configure this. See <a href=":url">Protecting against HTTP HOST Header attacks</a> for more information.', [':url' => 'https://www.drupal.org/node/1992030']), | 922 'description' => t('The trusted_host_patterns setting is not configured in settings.php. This can lead to security vulnerabilities. It is <strong>highly recommended</strong> that you configure this. See <a href=":url">Protecting against HTTP HOST Header attacks</a> for more information.', [':url' => 'https://www.drupal.org/docs/8/install/trusted-host-settings']), |
917 'severity' => REQUIREMENT_ERROR, | 923 'severity' => REQUIREMENT_ERROR, |
918 ]; | 924 ]; |
919 } | 925 } |
920 else { | 926 else { |
921 $requirements['trusted_host_patterns'] = [ | 927 $requirements['trusted_host_patterns'] = [ |
1829 return; | 1835 return; |
1830 } | 1836 } |
1831 $theme_handler->refreshInfo(); | 1837 $theme_handler->refreshInfo(); |
1832 foreach ($theme_handler->listInfo() as $theme) { | 1838 foreach ($theme_handler->listInfo() as $theme) { |
1833 // We first check that a base theme is set because if it's set to false then | 1839 // We first check that a base theme is set because if it's set to false then |
1834 // it's unset in \Drupal\Core\Extension\ThemeHandler::rebuildThemeData(). | 1840 // it's unset in |
1841 // \Drupal\Core\Extension\ThemeExtensionList::createExtensionInfo(). | |
1835 if (isset($theme->info['base theme']) && $theme->info['base theme'] == 'stable') { | 1842 if (isset($theme->info['base theme']) && $theme->info['base theme'] == 'stable') { |
1836 $theme_handler->install(['stable']); | 1843 $theme_handler->install(['stable']); |
1837 return; | 1844 return; |
1838 } | 1845 } |
1839 } | 1846 } |
2236 // Update the kernel to include the missing profile. | 2243 // Update the kernel to include the missing profile. |
2237 \Drupal::service('kernel')->updateModules($module_filenames, $module_filenames); | 2244 \Drupal::service('kernel')->updateModules($module_filenames, $module_filenames); |
2238 | 2245 |
2239 return t('The %install_profile install profile has been added to the installed module list.', ['%install_profile' => $install_profile]); | 2246 return t('The %install_profile install profile has been added to the installed module list.', ['%install_profile' => $install_profile]); |
2240 } | 2247 } |
2248 | |
2249 /** | |
2250 * Remove the unused 'system.theme.data' from state. | |
2251 */ | |
2252 function system_update_8701() { | |
2253 // The system.theme.data key is no longer used in Drupal 8.7.x. | |
2254 \Drupal::state()->delete('system.theme.data'); | |
2255 } | |
2256 | |
2257 /** | |
2258 * Add the 'revision_translation_affected' entity key. | |
2259 */ | |
2260 function system_update_8702() { | |
2261 $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager(); | |
2262 | |
2263 // Get a list of revisionable and translatable entity types. | |
2264 /** @var \Drupal\Core\Entity\EntityTypeInterface[] $last_installed_definitions */ | |
2265 $last_installed_definitions = array_filter($entity_definition_update_manager->getEntityTypes(), function (EntityTypeInterface $entity_type) { | |
2266 return $entity_type->isRevisionable() && $entity_type->isTranslatable(); | |
2267 }); | |
2268 | |
2269 // Ensure that we don't use the cached in-code definitions to support sites | |
2270 // that might be updating from 8.3.x straight to 8.7.x. | |
2271 \Drupal::entityTypeManager()->useCaches(FALSE); | |
2272 $live_definitions = \Drupal::entityTypeManager()->getDefinitions(); | |
2273 | |
2274 // Update the 'revision_translation_affected' entity key of the last installed | |
2275 // definitions to use the value of the live (in-code) entity type definitions | |
2276 // in cases when the key has not been populated yet. | |
2277 foreach ($last_installed_definitions as $entity_type_id => $entity_type) { | |
2278 $revision_translation_affected_key = $live_definitions[$entity_type_id]->getKey('revision_translation_affected'); | |
2279 if (!$entity_type->hasKey('revision_translation_affected') && !empty($revision_translation_affected_key) && $entity_definition_update_manager->getFieldStorageDefinition($revision_translation_affected_key, $entity_type_id)) { | |
2280 $entity_keys = $entity_type->getKeys(); | |
2281 $entity_keys['revision_translation_affected'] = $revision_translation_affected_key; | |
2282 $entity_type->set('entity_keys', $entity_keys); | |
2283 $entity_definition_update_manager->updateEntityType($entity_type); | |
2284 } | |
2285 } | |
2286 \Drupal::entityTypeManager()->useCaches(TRUE); | |
2287 } |