comparison core/modules/system/system.install @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children 12f9dff5fda9
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
16 use Drupal\Core\Database\Database; 16 use Drupal\Core\Database\Database;
17 use Drupal\Core\Entity\ContentEntityTypeInterface; 17 use Drupal\Core\Entity\ContentEntityTypeInterface;
18 use Drupal\Core\Entity\EntityTypeInterface; 18 use Drupal\Core\Entity\EntityTypeInterface;
19 use Drupal\Core\Entity\FieldableEntityInterface; 19 use Drupal\Core\Entity\FieldableEntityInterface;
20 use Drupal\Core\DrupalKernel; 20 use Drupal\Core\DrupalKernel;
21 use Drupal\Core\Extension\Extension;
21 use Drupal\Core\Field\BaseFieldDefinition; 22 use Drupal\Core\Field\BaseFieldDefinition;
22 use Drupal\Core\Site\Settings; 23 use Drupal\Core\Site\Settings;
23 use Drupal\Core\StreamWrapper\PrivateStream; 24 use Drupal\Core\StreamWrapper\PrivateStream;
24 use Drupal\Core\StreamWrapper\PublicStream; 25 use Drupal\Core\StreamWrapper\PublicStream;
25 use Drupal\system\SystemRequirements; 26 use Drupal\system\SystemRequirements;
49 $requirements['install_profile'] = [ 50 $requirements['install_profile'] = [
50 'title' => t('Installation profile'), 51 'title' => t('Installation profile'),
51 'value' => t('%profile_name (%profile-%version)', [ 52 'value' => t('%profile_name (%profile-%version)', [
52 '%profile_name' => $info['name'], 53 '%profile_name' => $info['name'],
53 '%profile' => $profile, 54 '%profile' => $profile,
54 '%version' => $info['version'] 55 '%version' => $info['version'],
55 ]), 56 ]),
56 'severity' => REQUIREMENT_INFO, 57 'severity' => REQUIREMENT_INFO,
57 'weight' => -9 58 'weight' => -9,
58 ]; 59 ];
59 } 60 }
60 61
61 // Warn if any experimental modules are installed. 62 // Warn if any experimental modules are installed.
62 $experimental = []; 63 $experimental = [];
75 ]; 76 ];
76 } 77 }
77 } 78 }
78 79
79 // Web server information. 80 // Web server information.
80 $software = \Drupal::request()->server->get('SERVER_SOFTWARE'); 81 $request_object = \Drupal::request();
82 $software = $request_object->server->get('SERVER_SOFTWARE');
81 $requirements['webserver'] = [ 83 $requirements['webserver'] = [
82 'title' => t('Web server'), 84 'title' => t('Web server'),
83 'value' => $software, 85 'value' => $software,
84 ]; 86 ];
85 87
86 // Tests clean URL support. 88 // Tests clean URL support.
87 if ($phase == 'install' && $install_state['interactive'] && !isset($_GET['rewrite']) && strpos($software, 'Apache') !== FALSE) { 89 if ($phase == 'install' && $install_state['interactive'] && !$request_object->query->has('rewrite') && strpos($software, 'Apache') !== FALSE) {
88 // If the Apache rewrite module is not enabled, Apache version must be >= 90 // If the Apache rewrite module is not enabled, Apache version must be >=
89 // 2.2.16 because of the FallbackResource directive in the root .htaccess 91 // 2.2.16 because of the FallbackResource directive in the root .htaccess
90 // file. Since the Apache version reported by the server is dependent on the 92 // file. Since the Apache version reported by the server is dependent on the
91 // ServerTokens setting in httpd.conf, we may not be able to determine if a 93 // ServerTokens setting in httpd.conf, we may not be able to determine if a
92 // given config is valid. Thus we are unable to use version_compare() as we 94 // given config is valid. Thus we are unable to use version_compare() as we
433 } 435 }
434 // Allow system administrators to disable permissions hardening for the site 436 // Allow system administrators to disable permissions hardening for the site
435 // directory. This allows additional files in the site directory to be 437 // directory. This allows additional files in the site directory to be
436 // updated when they are managed in a version control system. 438 // updated when they are managed in a version control system.
437 if (Settings::get('skip_permissions_hardening')) { 439 if (Settings::get('skip_permissions_hardening')) {
438 $conf_errors[] = t('Protection disabled'); 440 $error_value = t('Protection disabled');
439 // If permissions hardening is disabled, then only show a warning for a 441 // If permissions hardening is disabled, then only show a warning for a
440 // writable file, as a reminder, rather than an error. 442 // writable file, as a reminder, rather than an error.
441 $file_protection_severity = REQUIREMENT_WARNING; 443 $file_protection_severity = REQUIREMENT_WARNING;
442 } 444 }
443 else { 445 else {
446 $error_value = t('Not protected');
444 // In normal operation, writable files or directories are an error. 447 // In normal operation, writable files or directories are an error.
445 $file_protection_severity = REQUIREMENT_ERROR; 448 $file_protection_severity = REQUIREMENT_ERROR;
446 if (!drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir')) { 449 if (!drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir')) {
447 $conf_errors[] = t("The directory %file is not protected from modifications and poses a security risk. You must change the directory's permissions to be non-writable.", ['%file' => $site_path]); 450 $conf_errors[] = t("The directory %file is not protected from modifications and poses a security risk. You must change the directory's permissions to be non-writable.", ['%file' => $site_path]);
448 } 451 }
449 } 452 }
450 foreach (['settings.php', 'settings.local.php', 'services.yml'] as $conf_file) { 453 foreach (['settings.php', 'settings.local.php', 'services.yml'] as $conf_file) {
451 $full_path = $site_path . '/' . $conf_file; 454 $full_path = $site_path . '/' . $conf_file;
452 if (file_exists($full_path) && (Settings::get('skip_permissions_hardening') || !drupal_verify_install_file($full_path, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE))) { 455 if (file_exists($full_path) && !drupal_verify_install_file($full_path, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE, 'file', !Settings::get('skip_permissions_hardening'))) {
453 $conf_errors[] = t("The file %file is not protected from modifications and poses a security risk. You must change the file's permissions to be non-writable.", ['%file' => $full_path]); 456 $conf_errors[] = t("The file %file is not protected from modifications and poses a security risk. You must change the file's permissions to be non-writable.", ['%file' => $full_path]);
454 } 457 }
455 } 458 }
456 if (!empty($conf_errors)) { 459 if (!empty($conf_errors)) {
457 if (count($conf_errors) == 1) { 460 if (count($conf_errors) == 1) {
469 ], 472 ],
470 ], 473 ],
471 ]; 474 ];
472 } 475 }
473 $requirements['configuration_files'] = [ 476 $requirements['configuration_files'] = [
474 'value' => t('Not protected'), 477 'value' => $error_value,
475 'severity' => $file_protection_severity, 478 'severity' => $file_protection_severity,
476 'description' => $description, 479 'description' => $description,
477 ]; 480 ];
478 } 481 }
479 else { 482 else {
996 'title' => t('Limited date range'), 999 'title' => t('Limited date range'),
997 'value' => t('Your PHP installation has a limited date range.'), 1000 'value' => t('Your PHP installation has a limited date range.'),
998 'description' => t('You are running on a system where PHP is compiled or limited to using 32-bit integers. This will limit the range of dates and timestamps to the years 1901-2038. Read about the <a href=":url">limitations of 32-bit PHP</a>.', [':url' => 'https://www.drupal.org/docs/8/system-requirements/limitations-of-32-bit-php']), 1001 'description' => t('You are running on a system where PHP is compiled or limited to using 32-bit integers. This will limit the range of dates and timestamps to the years 1901-2038. Read about the <a href=":url">limitations of 32-bit PHP</a>.', [':url' => 'https://www.drupal.org/docs/8/system-requirements/limitations-of-32-bit-php']),
999 'severity' => REQUIREMENT_WARNING, 1002 'severity' => REQUIREMENT_WARNING,
1000 ]; 1003 ];
1004 }
1005
1006 // During installs from configuration don't support install profiles that
1007 // implement hook_install.
1008 if ($phase == 'install' && !empty($install_state['config_install_path'])) {
1009 $install_hook = $install_state['parameters']['profile'] . '_install';
1010 if (function_exists($install_hook)) {
1011 $requirements['config_install'] = [
1012 'title' => t('Configuration install'),
1013 'value' => $install_state['parameters']['profile'],
1014 'description' => t('The selected profile has a hook_install() implementation and therefore can not be installed from configuration.'),
1015 'severity' => REQUIREMENT_ERROR,
1016 ];
1017 }
1018 }
1019
1020 if ($phase === 'runtime') {
1021 $settings = Settings::getAll();
1022 if (array_key_exists('install_profile', $settings)) {
1023 // The following message is only informational because not all site owners
1024 // have access to edit their settings.php as it may be controlled by their
1025 // hosting provider.
1026 $requirements['install_profile_in_settings'] = [
1027 'title' => t('Install profile in settings'),
1028 'value' => t("Drupal 8 no longer uses the \$settings['install_profile'] value in settings.php and it can be removed."),
1029 'severity' => REQUIREMENT_INFO,
1030 ];
1031 }
1001 } 1032 }
1002 1033
1003 return $requirements; 1034 return $requirements;
1004 } 1035 }
1005 1036
1834 /** 1865 /**
1835 * Clear caches due to behavior change in DefaultPluginManager. 1866 * Clear caches due to behavior change in DefaultPluginManager.
1836 */ 1867 */
1837 function system_update_8201() { 1868 function system_update_8201() {
1838 // Empty update to cause a cache rebuild. 1869 // Empty update to cause a cache rebuild.
1870
1871 // Use hook_post_update_NAME() instead to clear the cache.
1872 // The use of hook_update_N() to clear the cache has been deprecated
1873 // see https://www.drupal.org/node/2960601 for more details.
1839 } 1874 }
1840 1875
1841 /** 1876 /**
1842 * Clear caches due to behavior change in MachineName element. 1877 * Clear caches due to behavior change in MachineName element.
1843 */ 1878 */
1844 function system_update_8202() { 1879 function system_update_8202() {
1845 // Empty update to cause a cache rebuild. 1880 // Empty update to cause a cache rebuild.
1881
1882 // Use hook_post_update_NAME() instead to clear the cache.The use
1883 // of hook_update_N to clear the cache has been deprecated see
1884 // https://www.drupal.org/node/2960601 for more details.
1846 } 1885 }
1847 1886
1848 /** 1887 /**
1849 * Add detailed cron logging configuration. 1888 * Add detailed cron logging configuration.
1850 */ 1889 */
2133 \Drupal::logger('system')->error('An existing "Default revision" field was found for the @entity_type_label entity type.', $variables); 2172 \Drupal::logger('system')->error('An existing "Default revision" field was found for the @entity_type_label entity type.', $variables);
2134 } 2173 }
2135 } 2174 }
2136 } 2175 }
2137 } 2176 }
2177
2178 /**
2179 * Fix missing install profile after updating to Drupal 8.6.9 with Drush 8.
2180 */
2181 function system_update_8601() {
2182 $extension_config = \Drupal::configFactory()->getEditable('core.extension');
2183 $install_profile = $extension_config->get('profile');
2184 if (!$install_profile) {
2185 // There's no install profile configured.
2186 return;
2187 }
2188 $modules = $extension_config->get('module');
2189 if (isset($modules[$install_profile])) {
2190 // The install profile is already in the installed module list.
2191 return;
2192 }
2193
2194 // Ensure the install profile is available.
2195 if (!\Drupal::service('extension.list.module')->exists($install_profile)) {
2196 return t('The %install_profile install profile configured in core.extension is not available.', ['%install_profile' => $install_profile]);
2197 }
2198
2199 // Add the install profile to the list of enabled modules.
2200 $modules[$install_profile] = 1000;
2201 $modules = module_config_sort($modules);
2202 $extension_config
2203 ->set('module', $modules)
2204 ->save(TRUE);
2205
2206 // Build a module list from the updated extension configuration.
2207 $current_module_filenames = \Drupal::moduleHandler()->getModuleList();
2208 $current_modules = array_fill_keys(array_keys($current_module_filenames), 0);
2209 $current_modules = module_config_sort(array_merge($current_modules, $extension_config->get('module')));
2210 $module_filenames = [];
2211 foreach ($current_modules as $name => $weight) {
2212 if (isset($current_module_filenames[$name])) {
2213 $module_filenames[$name] = $current_module_filenames[$name];
2214 }
2215 else {
2216 $module_path = \Drupal::service('extension.list.module')->getPath($name);
2217 $pathname = "$module_path/$name.info.yml";
2218 $filename = file_exists($module_path . "/$name.module") ? "$name.module" : NULL;
2219 $module_filenames[$name] = new Extension(\Drupal::root(), 'module', $pathname, $filename);
2220 }
2221 }
2222
2223 // Update the module handler list to contain the missing install profile.
2224 \Drupal::moduleHandler()->setModuleList($module_filenames);
2225 \Drupal::moduleHandler()->load($install_profile);
2226
2227 // Clear the static cache of the "extension.list.module" service to pick
2228 // up the new install profile correctly.
2229 \Drupal::service('extension.list.profile')->reset();
2230
2231 // Clear the static cache of the "extension.list.module" service to pick
2232 // up the new module, since it merges the installation status of modules
2233 // into its statically cached list.
2234 \Drupal::service('extension.list.module')->reset();
2235
2236 // Update the kernel to include the missing profile.
2237 \Drupal::service('kernel')->updateModules($module_filenames, $module_filenames);
2238
2239 return t('The %install_profile install profile has been added to the installed module list.', ['%install_profile' => $install_profile]);
2240 }