diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 9ede033..4788bfc 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -21,7 +21,7 @@ /** * Minimum supported version of PHP. * - * @deprecated in Drupal 8.5.0, will be removed before Drupal 9.0.0. Use + * @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. Use * \Drupal\Core\Requirements::DRUPAL_MINIMUM_PHP instead. * * @see https://www.drupal.org/node/2909361 @@ -44,7 +44,7 @@ * contributed modules to be installed prior to hitting the limit. However, * 40M is the target for the Standard installation profile. * - * @deprecated in Drupal 8.5.0, will be removed before Drupal 9.0.0. Use + * @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. Use * \Drupal\Core\Requirements::DRUPAL_MINIMUM_PHP_MEMORY_LIMIT instead. * * @see https://www.drupal.org/node/2909361 diff --git a/core/includes/install.inc b/core/includes/install.inc index 3529d51..2ae164c 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -11,6 +11,7 @@ use Drupal\Component\Utility\OpCodeCache; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Extension\ExtensionDiscovery; +use Drupal\Core\Requirements; use Drupal\Core\Site\Settings; /** @@ -1080,7 +1081,7 @@ function install_profile_info($profile, $langcode = 'en') { 'description' => '', 'version' => NULL, 'hidden' => FALSE, - 'php' => DRUPAL_MINIMUM_PHP, + 'php' => Requirements::MINIMUM_PHP, ]; $profile_file = drupal_get_path('profile', $profile) . "/$profile.info.yml"; $info = \Drupal::service('info_parser')->parse($profile_file); diff --git a/core/install.php b/core/install.php index c88ffee..dad65da 100644 --- a/core/install.php +++ b/core/install.php @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\OpCodeCache; +use Drupal\Core\Requirements; // Change the directory to the Drupal root. chdir('..'); @@ -21,11 +22,10 @@ */ define('MAINTENANCE_MODE', 'install'); -// Exit early if running an incompatible PHP version to avoid fatal errors. -// The minimum version is specified explicitly, as DRUPAL_MINIMUM_PHP is not -// yet available. It is defined in bootstrap.inc, but it is not possible to -// load that file yet as it would cause a fatal error on older versions of PHP. -if (version_compare(PHP_VERSION, '5.5.9') < 0) { +// Checking minimum PHP version to avoid fatal errors. +// The minimum version is specified in the Drupal\Core\Requirements interface +require_once $root_path . '/core/lib/Drupal/Core/Requirements.php'; +if (version_compare(PHP_VERSION, Requirements::MINIMUM_PHP) < 0) { print 'Your PHP installation is too old. Drupal requires at least PHP 5.5.9. See the system requirements page for more information.'; exit; } diff --git a/core/lib/Drupal/Core/Extension/module.api.php b/core/lib/Drupal/Core/Extension/module.api.php index 45355cc..77b9eb2 100644 --- a/core/lib/Drupal/Core/Extension/module.api.php +++ b/core/lib/Drupal/Core/Extension/module.api.php @@ -6,6 +6,7 @@ */ use Drupal\Core\Database\Database; +use Drupal\Core\Requirements; use Drupal\Core\Url; use Drupal\Core\Utility\UpdateException; @@ -942,8 +943,8 @@ function hook_requirements($phase) { 'title' => t('PHP'), 'value' => ($phase == 'runtime') ? \Drupal::l(phpversion(), new Url('system.php')) : phpversion(), ]; - 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]); + if (version_compare(phpversion(), Requirements::MINIMUM_PHP) < 0) { + $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => Requirements::MINIMUM_PHP]); $requirements['php']['severity'] = REQUIREMENT_ERROR; } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 0fd4b26..9b04fe0 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -19,6 +19,7 @@ use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\DrupalKernel; use Drupal\Core\Field\BaseFieldDefinition; +use Drupal\Core\Requirements; use Drupal\Core\Site\Settings; use Drupal\Core\StreamWrapper\PrivateStream; use Drupal\Core\StreamWrapper\PublicStream; @@ -183,8 +184,8 @@ function system_requirements($phase) { ]; } - 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]); + if (version_compare($phpversion, Requirements::MINIMUM_PHP) < 0) { + $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => Requirements::MINIMUM_PHP]); $requirements['php']['severity'] = REQUIREMENT_ERROR; // If PHP is old, it's not safe to continue with the requirements check. return $requirements; @@ -376,16 +377,16 @@ function system_requirements($phase) { 'value' => $memory_limit == -1 ? t('-1 (Unlimited)') : $memory_limit, ]; - if (!Environment::checkMemoryLimit(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) { + if (!Environment::checkMemoryLimit(Requirements::MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) { $description = []; if ($phase == 'install') { - $description['phase'] = t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', ['%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT]); + $description['phase'] = t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', ['%memory_minimum_limit' => Requirements::MINIMUM_PHP_MEMORY_LIMIT]); } elseif ($phase == 'update') { - $description['phase'] = t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', ['%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT]); + $description['phase'] = t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', ['%memory_minimum_limit' => Requirements::MINIMUM_PHP_MEMORY_LIMIT]); } elseif ($phase == 'runtime') { - $description['phase'] = t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', ['%memory_limit' => $memory_limit, '%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT]); + $description['phase'] = t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', ['%memory_limit' => $memory_limit, '%memory_minimum_limit' => Requirements::MINIMUM_PHP_MEMORY_LIMIT]); } if (!empty($description['phase'])) { diff --git a/core/modules/system/system.module b/core/modules/system/system.module index e38e8dd..d845b6e 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -10,6 +10,7 @@ use Drupal\Core\Asset\AttachedAssetsInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Queue\QueueGarbageCollectionInterface; +use Drupal\Core\Requirements; use Drupal\Core\Database\Query\AlterableInterface; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ExtensionDiscovery; @@ -1033,7 +1034,7 @@ function _system_rebuild_module_data() { 'description' => '', 'package' => 'Other', 'version' => NULL, - 'php' => DRUPAL_MINIMUM_PHP, + 'php' => Requirements::MINIMUM_PHP, ]; // Read info files for each module. diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php index 36ba1d6..780b33c 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php @@ -361,3 +361,22 @@ protected function systemListReset() { } } + +if (!defined('DRUPAL_EXTENSION_NAME_MAX_LENGTH')) { + define('DRUPAL_EXTENSION_NAME_MAX_LENGTH', 50); +} +if (!defined('DRUPAL_PHP_FUNCTION_PATTERN')) { + define('DRUPAL_PHP_FUNCTION_PATTERN', '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'); +} + +/** + * Minimum supported version of PHP. + * + * @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. Use + * \Drupal\Core\Requirements::MINIMUM_PHP instead. + * + * @see https://www.drupal.org/node/2909361 + */ + if (!defined('DRUPAL_MINIMUM_PHP')) { + define('DRUPAL_MINIMUM_PHP', '5.3.10'); + }