diff 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
line wrap: on
line diff
--- a/core/modules/system/system.install	Thu Feb 28 13:11:55 2019 +0000
+++ b/core/modules/system/system.install	Thu May 09 15:34:47 2019 +0100
@@ -11,6 +11,7 @@
 use Drupal\Component\Utility\OpCodeCache;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Cache\Cache;
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\Core\Path\AliasStorage;
 use Drupal\Core\Url;
 use Drupal\Core\Database\Database;
@@ -23,7 +24,6 @@
 use Drupal\Core\Site\Settings;
 use Drupal\Core\StreamWrapper\PrivateStream;
 use Drupal\Core\StreamWrapper\PublicStream;
-use Drupal\system\SystemRequirements;
 use Symfony\Component\HttpFoundation\Request;
 
 /**
@@ -145,7 +145,7 @@
         'title' => t('Apache version'),
         'value' => $apache_version_string,
         'severity' => REQUIREMENT_ERROR,
-        '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']),
+        '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']),
       ];
     }
 
@@ -154,7 +154,7 @@
         'title' => t('Clean URLs'),
         'value' => t('Disabled'),
         'severity' => REQUIREMENT_WARNING,
-        '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']),
+        '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']),
       ];
     }
   }
@@ -185,36 +185,43 @@
     ];
   }
 
-  if (version_compare($phpversion, DRUPAL_MINIMUM_PHP) < 0) {
-    $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => DRUPAL_MINIMUM_PHP]);
+  // Check if the PHP version is below what Drupal supports.
+  if (version_compare($phpversion, DRUPAL_MINIMUM_SUPPORTED_PHP) < 0) {
+    $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.',
+      [
+        '%version' => DRUPAL_MINIMUM_SUPPORTED_PHP,
+        '%recommended' => DRUPAL_RECOMMENDED_PHP,
+        ':php_requirements' => 'https://www.drupal.org/docs/8/system-requirements/php',
+      ]
+    );
     $requirements['php']['severity'] = REQUIREMENT_ERROR;
-    // If PHP is old, it's not safe to continue with the requirements check.
-    return $requirements;
-  }
-  if ((version_compare($phpversion, DRUPAL_RECOMMENDED_PHP) < 0) && ($phase === 'install' || $phase === 'runtime')) {
-    // Warn if still on PHP 5. If at least PHP 7.0, relax from "warning" to
-    // "info", and show it at runtime only, to not scare users while installing.
-    if (version_compare($phpversion, '7.0') < 0) {
-      $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']);
+
+    // If the PHP version is also below the absolute minimum allowed, it's not
+    // safe to continue with the requirements check.
+    if (version_compare($phpversion, DRUPAL_MINIMUM_PHP) < 0) {
+      return $requirements;
+    }
+    // Otherwise downgrade the error to a warning during updates. Even if there
+    // are some problems with the site's PHP version, it's still better for the
+    // site to keep its Drupal codebase up to date.
+    elseif ($phase === 'update') {
       $requirements['php']['severity'] = REQUIREMENT_WARNING;
     }
-    else {
-      if ($phase === 'runtime') {
-        $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']);
-        $requirements['php']['severity'] = REQUIREMENT_INFO;
-      }
+    // Since we allow sites with unsupported PHP versions to still run Drupal
+    // updates, we also need to be able to run tests with those PHP versions,
+    // which requires the ability to install test sites. Not all tests are
+    // required to pass on these PHP versions, but we want to monitor which
+    // ones do and don't.
+    elseif ($phase === 'install' && drupal_valid_test_ua()) {
+      $requirements['php']['severity'] = REQUIREMENT_INFO;
     }
   }
-
-  // Suggest to update to at least 5.5.21 or 5.6.5 for disabling multiple
-  // statements.
-  if (($phase === 'install' || \Drupal::database()->driver() === 'mysql') && !SystemRequirements::phpVersionWithPdoDisallowMultipleStatements($phpversion)) {
-    $requirements['php_multiple_statement'] = [
-      'title' => t('PHP (multiple statement disabling)'),
-      'value' => $phpversion_label,
-      '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.'),
-      'severity' => REQUIREMENT_INFO,
-    ];
+  // For PHP versions that are still supported but no longer recommended,
+  // inform users of what's recommended, allowing them to take action before it
+  // becomes urgent.
+  elseif ($phase === 'runtime' && version_compare($phpversion, DRUPAL_RECOMMENDED_PHP) < 0) {
+    $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']);
+    $requirements['php']['severity'] = REQUIREMENT_INFO;
   }
 
   // Test for PHP extensions.
@@ -309,7 +316,7 @@
         }
       }
       $args = [
-        ':drupal-php' => 'https://www.drupal.org/docs/7/system-requirements/php#csprng',
+        ':drupal-php' => 'https://www.drupal.org/docs/8/system-requirements/php-requirements',
         '%exception_message' => $e->getMessage(),
       ];
       if ($open_basedir_blocks_urandom) {
@@ -628,7 +635,7 @@
       $directory = config_get_config_directory($type);
       // If we're installing Drupal try and create the config sync directory.
       if (!is_dir($directory) && $phase == 'install') {
-        file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+        \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
       }
       if (!is_dir($directory)) {
         if ($phase == 'install') {
@@ -665,7 +672,7 @@
       continue;
     }
     if ($phase == 'install') {
-      file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+      \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
     }
     $is_writable = is_writable($directory);
     $is_directory = is_dir($directory);
@@ -680,7 +687,7 @@
       }
       // The files directory requirement check is done only during install and runtime.
       if ($phase == 'runtime') {
-        $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')]);
+        $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()]);
       }
       elseif ($phase == 'install') {
         // For the installer UI, we need different wording. 'value' will
@@ -744,7 +751,7 @@
     if ($has_pending_updates) {
       $requirements['update']['severity'] = REQUIREMENT_ERROR;
       $requirements['update']['value'] = t('Out of date');
-      $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')]);
+      $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()]);
     }
 
     $requirements['entity_update'] = [
@@ -804,8 +811,9 @@
         $requirements['php']['severity'] = REQUIREMENT_ERROR;
       }
       // Check the module's required modules.
+      /** @var \Drupal\Core\Extension\Dependency $requirement */
       foreach ($file->requires as $requirement) {
-        $required_module = $requirement['name'];
+        $required_module = $requirement->getName();
         // Check if the module exists.
         if (!isset($files[$required_module])) {
           $requirements["$module-$required_module"] = [
@@ -820,13 +828,11 @@
         $required_file = $files[$required_module];
         $required_name = $required_file->info['name'];
         $version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $required_file->info['version']);
-        $compatibility = drupal_check_incompatibility($requirement, $version);
-        if ($compatibility) {
-          $compatibility = rtrim(substr($compatibility, 2), ')');
+        if (!$requirement->isCompatible($version)) {
           $requirements["$module-$required_module"] = [
             'title' => t('Unresolved dependency'),
             'description' => t('@name requires this module and version. Currently using @required_name version @version', ['@name' => $name, '@required_name' => $required_name, '@version' => $version]),
-            'value' => t('@required_name (Version @compatibility required)', ['@required_name' => $required_name, '@compatibility' => $compatibility]),
+            'value' => t('@required_name (Version @compatibility required)', ['@required_name' => $required_name, '@compatibility' => $requirement->getConstraintString()]),
             'severity' => REQUIREMENT_ERROR,
           ];
           continue;
@@ -884,7 +890,7 @@
         'severity' => REQUIREMENT_WARNING,
         '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>.', [
           ':update' => 'https://www.drupal.org/documentation/modules/update',
-          ':module' => \Drupal::url('system.modules_list'),
+          ':module' => Url::fromRoute('system.modules_list')->toString(),
         ]),
       ];
     }
@@ -913,7 +919,7 @@
       $requirements['trusted_host_patterns'] = [
         'title' => t('Trusted Host Settings'),
         'value' => t('Not enabled'),
-        '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']),
+        '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']),
         'severity' => REQUIREMENT_ERROR,
       ];
     }
@@ -1831,7 +1837,8 @@
   $theme_handler->refreshInfo();
   foreach ($theme_handler->listInfo() as $theme) {
     // We first check that a base theme is set because if it's set to false then
-    // it's unset in \Drupal\Core\Extension\ThemeHandler::rebuildThemeData().
+    // it's unset in
+    // \Drupal\Core\Extension\ThemeExtensionList::createExtensionInfo().
     if (isset($theme->info['base theme']) && $theme->info['base theme'] == 'stable') {
       $theme_handler->install(['stable']);
       return;
@@ -2238,3 +2245,43 @@
 
   return t('The %install_profile install profile has been added to the installed module list.', ['%install_profile' => $install_profile]);
 }
+
+/**
+ * Remove the unused 'system.theme.data' from state.
+ */
+function system_update_8701() {
+  // The system.theme.data key is no longer used in Drupal 8.7.x.
+  \Drupal::state()->delete('system.theme.data');
+}
+
+/**
+ * Add the 'revision_translation_affected' entity key.
+ */
+function system_update_8702() {
+  $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
+
+  // Get a list of revisionable and translatable entity types.
+  /** @var \Drupal\Core\Entity\EntityTypeInterface[] $last_installed_definitions */
+  $last_installed_definitions = array_filter($entity_definition_update_manager->getEntityTypes(), function (EntityTypeInterface $entity_type) {
+    return $entity_type->isRevisionable() && $entity_type->isTranslatable();
+  });
+
+  // Ensure that we don't use the cached in-code definitions to support sites
+  // that might be updating from 8.3.x straight to 8.7.x.
+  \Drupal::entityTypeManager()->useCaches(FALSE);
+  $live_definitions = \Drupal::entityTypeManager()->getDefinitions();
+
+  // Update the 'revision_translation_affected' entity key of the last installed
+  // definitions to use the value of the live (in-code) entity type definitions
+  // in cases when the key has not been populated yet.
+  foreach ($last_installed_definitions as $entity_type_id => $entity_type) {
+    $revision_translation_affected_key = $live_definitions[$entity_type_id]->getKey('revision_translation_affected');
+    if (!$entity_type->hasKey('revision_translation_affected') && !empty($revision_translation_affected_key) && $entity_definition_update_manager->getFieldStorageDefinition($revision_translation_affected_key, $entity_type_id)) {
+      $entity_keys = $entity_type->getKeys();
+      $entity_keys['revision_translation_affected'] = $revision_translation_affected_key;
+      $entity_type->set('entity_keys', $entity_keys);
+      $entity_definition_update_manager->updateEntityType($entity_type);
+    }
+  }
+  \Drupal::entityTypeManager()->useCaches(TRUE);
+}