2004-02-25 22:20:09 +00:00
<?php
2006-07-13 13:14:25 +00:00
2009-05-13 19:42:18 +00:00
/**
* @file
* Install, update and uninstall functions for the system module.
*/
2013-07-09 18:57:20 +00:00
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
use Drupal\Component\FileSystem\FileSystem as FileSystemComponent;
2013-06-06 08:08:39 +00:00
use Drupal\Component\Utility\Crypt;
2014-05-23 19:25:52 +00:00
use Drupal\Component\Utility\Environment;
2016-08-01 11:42:23 +00:00
use Drupal\Component\Utility\OpCodeCache;
2017-06-22 11:52:57 +00:00
use Drupal\Component\Utility\Unicode;
2013-06-06 08:08:39 +00:00
use Drupal\Core\Database\Database;
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
use Drupal\Core\DrupalKernel;
use Drupal\Core\File\FileSystemInterface;
2014-04-25 19:13:44 +00:00
use Drupal\Core\Site\Settings;
2014-12-14 13:01:24 +00:00
use Drupal\Core\StreamWrapper\PrivateStream;
2013-08-22 01:11:07 +00:00
use Drupal\Core\StreamWrapper\PublicStream;
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
2015-06-09 12:15:19 +00:00
use Symfony\Component\HttpFoundation\Request;
2009-05-13 19:42:18 +00:00
2006-09-01 08:44:53 +00:00
/**
2013-08-13 15:01:10 +00:00
* Implements hook_requirements().
2006-09-01 08:44:53 +00:00
*/
function system_requirements($phase) {
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
global $install_state;
2017-03-04 01:20:24 +00:00
$requirements = [];
2006-09-01 08:44:53 +00:00
// Report Drupal version
if ($phase == 'runtime') {
2017-03-04 01:20:24 +00:00
$requirements['drupal'] = [
2013-06-17 13:35:07 +00:00
'title' => t('Drupal'),
2013-09-16 03:58:06 +00:00
'value' => \Drupal::VERSION,
2006-10-29 15:13:01 +00:00
'severity' => REQUIREMENT_INFO,
'weight' => -10,
2017-03-04 01:20:24 +00:00
];
2009-08-21 07:50:08 +00:00
2012-10-05 16:11:15 +00:00
// Display the currently active installation profile, if the site
// is not running the default installation profile.
2019-07-22 08:31:06 +00:00
$profile = \Drupal::installProfile();
2010-01-05 18:00:14 +00:00
if ($profile != 'standard') {
2019-10-07 13:46:33 +00:00
$info = \Drupal::service('extension.list.module')->getExtensionInfo($profile);
2017-03-04 01:20:24 +00:00
$requirements['install_profile'] = [
2013-06-17 13:35:07 +00:00
'title' => t('Installation profile'),
2017-03-04 01:20:24 +00:00
'value' => t('%profile_name (%profile-%version)', [
2009-08-21 07:50:08 +00:00
'%profile_name' => $info['name'],
'%profile' => $profile,
2018-05-11 09:40:33 +00:00
'%version' => $info['version'],
2017-03-04 01:20:24 +00:00
]),
2009-08-21 07:50:08 +00:00
'severity' => REQUIREMENT_INFO,
2018-05-11 09:40:33 +00:00
'weight' => -9,
2017-03-04 01:20:24 +00:00
];
2009-08-24 00:14:23 +00:00
}
2015-09-01 11:29:24 +00:00
// Warn if any experimental modules are installed.
2019-10-09 23:29:39 +00:00
$experimental_modules = [];
2015-09-10 19:40:41 +00:00
$enabled_modules = \Drupal::moduleHandler()->getModuleList();
2015-09-01 11:29:24 +00:00
foreach ($enabled_modules as $module => $data) {
2019-10-07 13:46:33 +00:00
$info = \Drupal::service('extension.list.module')->getExtensionInfo($module);
2017-05-22 10:03:29 +00:00
if (isset($info['package']) && $info['package'] === 'Core (Experimental)') {
2019-10-09 23:29:39 +00:00
$experimental_modules[$module] = $info['name'];
2015-09-01 11:29:24 +00:00
}
}
2019-10-09 23:29:39 +00:00
if (!empty($experimental_modules)) {
$requirements['experimental_modules'] = [
2015-09-01 11:29:24 +00:00
'title' => t('Experimental modules enabled'),
2019-10-09 23:29:39 +00:00
'value' => t('Experimental modules found: %module_list. <a href=":url">Experimental modules</a> are provided for testing purposes only. Use at your own risk.', ['%module_list' => implode(', ', $experimental_modules), ':url' => 'https://www.drupal.org/core/experimental']),
'severity' => REQUIREMENT_WARNING,
];
}
// Warn if any experimental themes are installed.
$experimental_themes = [];
$installed_themes = \Drupal::service('theme_handler')->listInfo();
foreach ($installed_themes as $theme => $data) {
if (isset($data->info['experimental']) && $data->info['experimental']) {
$experimental_themes[$theme] = $data->info['name'];
}
}
if (!empty($experimental_themes)) {
$requirements['experimental_themes'] = [
'title' => t('Experimental themes enabled'),
'value' => t('Experimental themes found: %theme_list. Experimental themes are provided for testing purposes only. Use at your own risk.', ['%theme_list' => implode(', ', $experimental_themes)]),
2015-09-01 11:29:24 +00:00
'severity' => REQUIREMENT_WARNING,
2017-03-04 01:20:24 +00:00
];
2015-09-01 11:29:24 +00:00
}
2006-09-01 08:44:53 +00:00
}
2008-01-30 20:30:35 +00:00
// Web server information.
2018-04-06 11:59:26 +00:00
$request_object = \Drupal::request();
$software = $request_object->server->get('SERVER_SOFTWARE');
2017-03-04 01:20:24 +00:00
$requirements['webserver'] = [
2013-06-17 13:35:07 +00:00
'title' => t('Web server'),
2006-10-29 15:13:01 +00:00
'value' => $software,
2017-03-04 01:20:24 +00:00
];
2006-09-01 08:44:53 +00:00
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
// Tests clean URL support.
2018-04-06 11:59:26 +00:00
if ($phase == 'install' && $install_state['interactive'] && !$request_object->query->has('rewrite') && strpos($software, 'Apache') !== FALSE) {
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
// If the Apache rewrite module is not enabled, Apache version must be >=
// 2.2.16 because of the FallbackResource directive in the root .htaccess
// file. Since the Apache version reported by the server is dependent on the
// ServerTokens setting in httpd.conf, we may not be able to determine if a
// given config is valid. Thus we are unable to use version_compare() as we
// need have three possible outcomes: the version of Apache is greater than
// 2.2.16, is less than 2.2.16, or cannot be determined accurately. In the
// first case, we encourage the use of mod_rewrite; in the second case, we
// raise an error regarding the minimum Apache version; in the third case,
// we raise a warning that the current version of Apache may not be
// supported.
$rewrite_warning = FALSE;
$rewrite_error = FALSE;
$apache_version_string = 'Apache';
// Determine the Apache version number: major, minor and revision.
if (preg_match('/Apache\/(\d+)\.?(\d+)?\.?(\d+)?/', $software, $matches)) {
$apache_version_string = $matches[0];
// Major version number
if ($matches[1] < 2) {
$rewrite_error = TRUE;
}
2015-11-28 15:50:23 +00:00
elseif ($matches[1] == 2) {
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
if (!isset($matches[2])) {
$rewrite_warning = TRUE;
}
2015-11-28 15:50:23 +00:00
elseif ($matches[2] < 2) {
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
$rewrite_error = TRUE;
}
2015-11-28 15:50:23 +00:00
elseif ($matches[2] == 2) {
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
if (!isset($matches[3])) {
$rewrite_warning = TRUE;
}
2015-11-28 15:50:23 +00:00
elseif ($matches[3] < 16) {
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
$rewrite_error = TRUE;
}
}
}
}
else {
$rewrite_warning = TRUE;
}
if ($rewrite_warning) {
2017-03-04 14:02:01 +00:00
$requirements['apache_version'] = [
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
'title' => t('Apache version'),
'value' => $apache_version_string,
'severity' => REQUIREMENT_WARNING,
2017-03-04 01:20:24 +00:00
'description' => t('Due to the settings for ServerTokens in httpd.conf, it is impossible to accurately determine the version of Apache running on this server. The reported value is @reported, to run Drupal without mod_rewrite, a minimum version of 2.2.16 is needed.', ['@reported' => $apache_version_string]),
];
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
}
if ($rewrite_error) {
2017-03-04 14:02:01 +00:00
$requirements['Apache version'] = [
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
'title' => t('Apache version'),
'value' => $apache_version_string,
'severity' => REQUIREMENT_ERROR,
2018-11-28 11:48:58 +00:00
'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']),
2017-03-04 01:20:24 +00:00
];
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
}
if (!$rewrite_error && !$rewrite_warning) {
2017-03-04 14:02:01 +00:00
$requirements['rewrite_module'] = [
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
'title' => t('Clean URLs'),
'value' => t('Disabled'),
'severity' => REQUIREMENT_WARNING,
2018-11-28 11:48:58 +00:00
'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']),
2017-03-04 01:20:24 +00:00
];
Issue #2382513 by mikeker, chris_hall_hu_cheng, joachim, joelpittet, alexpott, YesCT, quietone, mikeker, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com: Regression fix: allow Drupal 8 to work without Apache mod_rewrite
2015-07-28 08:52:04 +00:00
}
}
Issue #2670966 by xjm, Crell, claudiu.cristea, alexpott, timmillwood, rakesh.gectcr, catch, dawehner, David_Rothstein, hchonov, martin107, tstoeckler, andypost, cilefen, RobLoach, Fabianx, salvis, hussainweb, JeroenT, larowlan, pfrenssen, daffie, webchick, wturrell: Warn users of old PHP versions
2017-12-03 05:03:36 +00:00
// Verify the user is running a supported PHP version.
// If the site is running a recommended version of PHP, just display it
// as an informational message on the status report. This will be overridden
// with an error or warning if the site is running older PHP versions for
// which Drupal has already or will soon drop support.
2015-04-08 21:06:00 +00:00
$phpversion = $phpversion_label = phpversion();
2009-10-05 04:34:04 +00:00
if (function_exists('phpinfo')) {
2015-04-08 21:06:00 +00:00
if ($phase === 'runtime') {
Issue #2570355 by Sutharsan, stefan.r, kgoel, josephdpurcell, joelpittet, justAChris, dawehner, pfrenssen, pwolanin, David_Rothstein, catch: Replace remaining !placeholder and @placeholder with :placeholder for URLs
2015-09-22 06:16:37 +00:00
$phpversion_label = t('@phpversion (<a href=":url">more information</a>)', ['@phpversion' => $phpversion, ':url' => (new Url('system.php'))->toString()]);
2015-04-08 21:06:00 +00:00
}
2017-03-04 01:20:24 +00:00
$requirements['php'] = [
2013-06-17 13:35:07 +00:00
'title' => t('PHP'),
2015-04-08 21:06:00 +00:00
'value' => $phpversion_label,
2017-03-04 01:20:24 +00:00
];
2009-10-05 04:34:04 +00:00
}
else {
Issue #2670966 by xjm, Crell, claudiu.cristea, alexpott, timmillwood, rakesh.gectcr, catch, dawehner, David_Rothstein, hchonov, martin107, tstoeckler, andypost, cilefen, RobLoach, Fabianx, salvis, hussainweb, JeroenT, larowlan, pfrenssen, daffie, webchick, wturrell: Warn users of old PHP versions
2017-12-03 05:03:36 +00:00
// @todo Revisit whether this description makes sense in
// https://www.drupal.org/project/drupal/issues/2927318.
2017-03-04 01:20:24 +00:00
$requirements['php'] = [
2013-06-17 13:35:07 +00:00
'title' => t('PHP'),
2015-04-08 21:06:00 +00:00
'value' => $phpversion_label,
2017-03-04 01:20:24 +00:00
'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']),
2009-10-05 04:34:04 +00:00
'severity' => REQUIREMENT_INFO,
2017-03-04 01:20:24 +00:00
];
2009-10-05 04:34:04 +00:00
}
2019-03-29 07:19:57 +00:00
// 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',
]
);
2006-09-01 08:44:53 +00:00
$requirements['php']['severity'] = REQUIREMENT_ERROR;
2019-03-29 07:19:57 +00:00
// 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') {
2018-02-01 21:27:25 +00:00
$requirements['php']['severity'] = REQUIREMENT_WARNING;
}
2019-03-29 07:19:57 +00:00
// 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;
2018-02-01 21:27:25 +00:00
}
Issue #2670966 by xjm, Crell, claudiu.cristea, alexpott, timmillwood, rakesh.gectcr, catch, dawehner, David_Rothstein, hchonov, martin107, tstoeckler, andypost, cilefen, RobLoach, Fabianx, salvis, hussainweb, JeroenT, larowlan, pfrenssen, daffie, webchick, wturrell: Warn users of old PHP versions
2017-12-03 05:03:36 +00:00
}
2019-03-29 07:19:57 +00:00
// 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;
2015-04-01 09:11:54 +00:00
}
2010-02-26 06:39:13 +00:00
// Test for PHP extensions.
2017-03-04 01:20:24 +00:00
$requirements['php_extensions'] = [
2013-06-17 13:35:07 +00:00
'title' => t('PHP extensions'),
2017-03-04 01:20:24 +00:00
];
2010-02-26 06:39:13 +00:00
2017-03-04 01:20:24 +00:00
$missing_extensions = [];
$required_extensions = [
2010-02-26 06:39:13 +00:00
'date',
'dom',
'filter',
'gd',
'hash',
'json',
'pcre',
'pdo',
'session',
'SimpleXML',
'SPL',
2012-06-14 02:48:09 +00:00
'tokenizer',
2010-02-26 06:39:13 +00:00
'xml',
2017-03-04 01:20:24 +00:00
];
2010-02-26 06:39:13 +00:00
foreach ($required_extensions as $extension) {
if (!extension_loaded($extension)) {
$missing_extensions[] = $extension;
}
}
if (!empty($missing_extensions)) {
2017-03-04 01:20:24 +00:00
$description = t('Drupal requires you to enable the PHP extensions in the following list (see the <a href=":system_requirements">system requirements page</a> for more information):', [
Issue #2570355 by Sutharsan, stefan.r, kgoel, josephdpurcell, joelpittet, justAChris, dawehner, pfrenssen, pwolanin, David_Rothstein, catch: Replace remaining !placeholder and @placeholder with :placeholder for URLs
2015-09-22 06:16:37 +00:00
':system_requirements' => 'https://www.drupal.org/requirements',
2017-03-04 01:20:24 +00:00
]);
2010-02-26 06:39:13 +00:00
2014-11-10 13:34:31 +00:00
// We use twig inline_template to avoid twig's autoescape.
2017-03-04 01:20:24 +00:00
$description = [
2014-11-10 13:34:31 +00:00
'#type' => 'inline_template',
'#template' => '{{ description }}{{ missing_extensions }}',
2017-03-04 01:20:24 +00:00
'#context' => [
2014-11-10 13:34:31 +00:00
'description' => $description,
2017-03-04 01:20:24 +00:00
'missing_extensions' => [
2014-11-10 13:34:31 +00:00
'#theme' => 'item_list',
'#items' => $missing_extensions,
2017-03-04 01:20:24 +00:00
],
],
];
2010-02-26 06:39:13 +00:00
2013-06-17 13:35:07 +00:00
$requirements['php_extensions']['value'] = t('Disabled');
2010-02-26 06:39:13 +00:00
$requirements['php_extensions']['severity'] = REQUIREMENT_ERROR;
$requirements['php_extensions']['description'] = $description;
2010-01-09 22:01:42 +00:00
}
else {
2013-06-17 13:35:07 +00:00
$requirements['php_extensions']['value'] = t('Enabled');
2015-09-10 19:55:55 +00:00
}
if ($phase == 'install' || $phase == 'runtime') {
// Check to see if OPcache is installed.
2016-08-01 11:42:23 +00:00
if (!OpCodeCache::isEnabled()) {
2017-03-04 01:20:24 +00:00
$requirements['php_opcache'] = [
2015-09-10 19:55:55 +00:00
'value' => t('Not enabled'),
'severity' => REQUIREMENT_WARNING,
2016-01-05 14:31:39 +00:00
'description' => t('PHP OPcode caching can improve your site\'s performance considerably. It is <strong>highly recommended</strong> to have <a href="http://php.net/manual/opcache.installation.php" target="_blank">OPcache</a> installed on your server.'),
2017-03-04 01:20:24 +00:00
];
2015-09-10 19:55:55 +00:00
}
else {
$requirements['php_opcache']['value'] = t('Enabled');
}
$requirements['php_opcache']['title'] = t('PHP OPcode caching');
2010-01-09 22:01:42 +00:00
}
2008-01-21 20:04:35 +00:00
Issue #2763787 by pwolanin, nerdstein, rlhawk, YesCT, slasher13, tuutti, alexpott, therealssj, TravisCarden, dawehner, maximpodorov, klausi, catch, talhaparacha, Eric_A: Upgrade random_compat to latest version
2016-10-26 19:30:28 +00:00
if ($phase != 'update') {
// Test whether we have a good source of random bytes.
2017-03-04 01:20:24 +00:00
$requirements['php_random_bytes'] = [
Issue #2763787 by pwolanin, nerdstein, rlhawk, YesCT, slasher13, tuutti, alexpott, therealssj, TravisCarden, dawehner, maximpodorov, klausi, catch, talhaparacha, Eric_A: Upgrade random_compat to latest version
2016-10-26 19:30:28 +00:00
'title' => t('Random number generation'),
2017-03-04 01:20:24 +00:00
];
Issue #2763787 by pwolanin, nerdstein, rlhawk, YesCT, slasher13, tuutti, alexpott, therealssj, TravisCarden, dawehner, maximpodorov, klausi, catch, talhaparacha, Eric_A: Upgrade random_compat to latest version
2016-10-26 19:30:28 +00:00
try {
$bytes = random_bytes(10);
if (strlen($bytes) != 10) {
2017-03-04 01:20:24 +00:00
throw new \Exception(t('Tried to generate 10 random bytes, generated @count', ['@count' => strlen($bytes)]));
Issue #2763787 by pwolanin, nerdstein, rlhawk, YesCT, slasher13, tuutti, alexpott, therealssj, TravisCarden, dawehner, maximpodorov, klausi, catch, talhaparacha, Eric_A: Upgrade random_compat to latest version
2016-10-26 19:30:28 +00:00
}
$requirements['php_random_bytes']['value'] = t('Successful');
}
catch (\Exception $e) {
// If /dev/urandom is not available on a UNIX-like system, check whether
// open_basedir restrictions are the cause.
$open_basedir_blocks_urandom = FALSE;
if (DIRECTORY_SEPARATOR === '/' && !@is_readable('/dev/urandom')) {
$open_basedir = ini_get('open_basedir');
if ($open_basedir) {
$open_basedir_paths = explode(PATH_SEPARATOR, $open_basedir);
2017-03-04 01:20:24 +00:00
$open_basedir_blocks_urandom = !array_intersect(['/dev', '/dev/', '/dev/urandom'], $open_basedir_paths);
Issue #2763787 by pwolanin, nerdstein, rlhawk, YesCT, slasher13, tuutti, alexpott, therealssj, TravisCarden, dawehner, maximpodorov, klausi, catch, talhaparacha, Eric_A: Upgrade random_compat to latest version
2016-10-26 19:30:28 +00:00
}
}
2017-03-04 01:20:24 +00:00
$args = [
2018-11-28 11:48:58 +00:00
':drupal-php' => 'https://www.drupal.org/docs/8/system-requirements/php-requirements',
Issue #2763787 by pwolanin, nerdstein, rlhawk, YesCT, slasher13, tuutti, alexpott, therealssj, TravisCarden, dawehner, maximpodorov, klausi, catch, talhaparacha, Eric_A: Upgrade random_compat to latest version
2016-10-26 19:30:28 +00:00
'%exception_message' => $e->getMessage(),
2017-03-04 01:20:24 +00:00
];
Issue #2763787 by pwolanin, nerdstein, rlhawk, YesCT, slasher13, tuutti, alexpott, therealssj, TravisCarden, dawehner, maximpodorov, klausi, catch, talhaparacha, Eric_A: Upgrade random_compat to latest version
2016-10-26 19:30:28 +00:00
if ($open_basedir_blocks_urandom) {
$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);
}
else {
$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. See the <a href=":drupal-php">system requirements</a> page for more information. %exception_message', $args);
}
$requirements['php_random_bytes']['value'] = t('Less secure');
$requirements['php_random_bytes']['severity'] = REQUIREMENT_ERROR;
}
}
2010-07-31 12:29:31 +00:00
if ($phase == 'install' || $phase == 'update') {
// Test for PDO (database).
2017-03-04 01:20:24 +00:00
$requirements['database_extensions'] = [
2013-06-17 13:35:07 +00:00
'title' => t('Database support'),
2017-03-04 01:20:24 +00:00
];
2010-02-26 06:39:13 +00:00
2010-10-12 02:50:03 +00:00
// Make sure PDO is available.
2010-07-31 12:29:31 +00:00
$database_ok = extension_loaded('pdo');
2010-10-12 02:50:03 +00:00
if (!$database_ok) {
2017-03-04 01:20:24 +00:00
$pdo_message = t('Your web server does not appear to support PDO (PHP Data Objects). Ask your hosting provider if they support the native PDO extension. See the <a href=":link">system requirements</a> page for more information.', [
Issue #2570355 by Sutharsan, stefan.r, kgoel, josephdpurcell, joelpittet, justAChris, dawehner, pfrenssen, pwolanin, David_Rothstein, catch: Replace remaining !placeholder and @placeholder with :placeholder for URLs
2015-09-22 06:16:37 +00:00
':link' => 'https://www.drupal.org/requirements/pdo',
2017-03-04 01:20:24 +00:00
]);
2010-10-12 02:50:03 +00:00
}
else {
// Make sure at least one supported database driver exists.
2010-07-31 12:29:31 +00:00
$drivers = drupal_detect_database_types();
2010-10-12 02:50:03 +00:00
if (empty($drivers)) {
$database_ok = FALSE;
2017-03-04 01:20:24 +00:00
$pdo_message = t('Your web server does not appear to support any common PDO database extensions. Check with your hosting provider to see if they support PDO (PHP Data Objects) and offer any databases that <a href=":drupal-databases">Drupal supports</a>.', [
2016-10-13 23:50:48 +00:00
':drupal-databases' => 'https://www.drupal.org/requirements/database',
2017-03-04 01:20:24 +00:00
]);
2010-10-12 02:50:03 +00:00
}
// Make sure the native PDO extension is available, not the older PEAR
// version. (See install_verify_pdo() for details.)
if (!defined('PDO::ATTR_DEFAULT_FETCH_MODE')) {
$database_ok = FALSE;
2017-03-04 01:20:24 +00:00
$pdo_message = t('Your web server seems to have the wrong version of PDO installed. Drupal requires the PDO extension from PHP core. This system has the older PECL version. See the <a href=":link">system requirements</a> page for more information.', [
Issue #2570355 by Sutharsan, stefan.r, kgoel, josephdpurcell, joelpittet, justAChris, dawehner, pfrenssen, pwolanin, David_Rothstein, catch: Replace remaining !placeholder and @placeholder with :placeholder for URLs
2015-09-22 06:16:37 +00:00
':link' => 'https://www.drupal.org/requirements/pdo#pecl',
2017-03-04 01:20:24 +00:00
]);
2010-10-12 02:50:03 +00:00
}
2010-07-31 12:29:31 +00:00
}
2010-02-26 06:39:13 +00:00
2010-07-31 12:29:31 +00:00
if (!$database_ok) {
2013-06-17 13:35:07 +00:00
$requirements['database_extensions']['value'] = t('Disabled');
2010-07-31 12:29:31 +00:00
$requirements['database_extensions']['severity'] = REQUIREMENT_ERROR;
2010-10-12 02:50:03 +00:00
$requirements['database_extensions']['description'] = $pdo_message;
2010-07-31 12:29:31 +00:00
}
else {
2013-06-17 13:35:07 +00:00
$requirements['database_extensions']['value'] = t('Enabled');
2010-07-31 12:29:31 +00:00
}
2010-02-10 10:38:53 +00:00
}
2010-11-29 06:42:53 +00:00
else {
// Database information.
2011-12-28 19:08:26 +00:00
$class = Database::getConnection()->getDriverClass('Install\\Tasks');
2010-11-29 06:42:53 +00:00
$tasks = new $class();
2017-03-04 01:20:24 +00:00
$requirements['database_system'] = [
2013-06-17 13:35:07 +00:00
'title' => t('Database system'),
2010-11-29 06:42:53 +00:00
'value' => $tasks->name(),
2017-03-04 01:20:24 +00:00
];
$requirements['database_system_version'] = [
2013-06-17 13:35:07 +00:00
'title' => t('Database system version'),
2010-11-29 06:42:53 +00:00
'value' => Database::getConnection()->version(),
2017-03-04 01:20:24 +00:00
];
2010-11-29 06:42:53 +00:00
}
2010-02-10 10:38:53 +00:00
2008-01-04 17:19:04 +00:00
// Test PHP memory_limit
2008-01-08 21:22:28 +00:00
$memory_limit = ini_get('memory_limit');
2017-03-04 01:20:24 +00:00
$requirements['php_memory_limit'] = [
2013-06-17 13:35:07 +00:00
'title' => t('PHP memory limit'),
2009-02-25 13:33:53 +00:00
'value' => $memory_limit == -1 ? t('-1 (Unlimited)') : $memory_limit,
2017-03-04 01:20:24 +00:00
];
2008-01-07 15:31:50 +00:00
2014-05-23 19:25:52 +00:00
if (!Environment::checkMemoryLimit(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) {
2017-03-04 01:20:24 +00:00
$description = [];
2008-01-08 21:22:28 +00:00
if ($phase == 'install') {
2017-03-04 01:20:24 +00:00
$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]);
2008-01-16 10:37:43 +00:00
}
elseif ($phase == 'update') {
2017-03-04 01:20:24 +00:00
$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]);
2008-01-04 17:19:04 +00:00
}
2008-01-08 21:22:28 +00:00
elseif ($phase == 'runtime') {
2017-03-04 01:20:24 +00:00
$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]);
2008-01-04 17:19:04 +00:00
}
2008-01-10 22:04:32 +00:00
2014-11-10 13:34:31 +00:00
if (!empty($description['phase'])) {
2008-01-08 21:22:28 +00:00
if ($php_ini_path = get_cfg_var('cfg_file_path')) {
2017-03-04 01:20:24 +00:00
$description['memory'] = t('Increase the memory limit by editing the memory_limit parameter in the file %configuration-file and then restart your web server (or contact your system administrator or hosting provider for assistance).', ['%configuration-file' => $php_ini_path]);
2008-01-08 21:22:28 +00:00
}
else {
2014-11-10 13:34:31 +00:00
$description['memory'] = t('Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.');
2008-01-08 21:22:28 +00:00
}
2008-01-10 22:04:32 +00:00
2017-03-04 01:20:24 +00:00
$handbook_link = t('For more information, see the online handbook entry for <a href=":memory-limit">increasing the PHP memory limit</a>.', [':memory-limit' => 'https://www.drupal.org/node/207036']);
2014-11-10 13:34:31 +00:00
2017-03-04 01:20:24 +00:00
$description = [
2014-11-10 13:34:31 +00:00
'#type' => 'inline_template',
'#template' => '{{ description_phase }} {{ description_memory }} {{ handbook }}',
2017-03-04 01:20:24 +00:00
'#context' => [
2014-11-10 13:34:31 +00:00
'description_phase' => $description['phase'],
'description_memory' => $description['memory'],
'handbook' => $handbook_link,
2017-03-04 01:20:24 +00:00
],
];
2014-11-10 13:34:31 +00:00
$requirements['php_memory_limit']['description'] = $description;
2008-01-16 10:37:43 +00:00
$requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING;
2008-01-08 21:22:28 +00:00
}
2008-01-07 15:31:50 +00:00
}
2008-01-10 22:04:32 +00:00
2012-06-05 05:51:41 +00:00
// Test configuration files and directory for writability.
2006-09-01 08:44:53 +00:00
if ($phase == 'runtime') {
2017-03-04 01:20:24 +00:00
$conf_errors = [];
2015-06-09 12:15:19 +00:00
// Find the site path. Kernel service is not always available at this point,
// but is preferred, when available.
if (\Drupal::hasService('kernel')) {
$site_path = \Drupal::service('site.path');
}
else {
$site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
}
2016-02-03 06:15:58 +00:00
// Allow system administrators to disable permissions hardening for the site
// directory. This allows additional files in the site directory to be
// updated when they are managed in a version control system.
if (Settings::get('skip_permissions_hardening')) {
2018-06-15 12:51:03 +00:00
$error_value = t('Protection disabled');
2016-02-03 06:15:58 +00:00
// If permissions hardening is disabled, then only show a warning for a
// writable file, as a reminder, rather than an error.
$file_protection_severity = REQUIREMENT_WARNING;
}
else {
2018-06-15 12:51:03 +00:00
$error_value = t('Not protected');
2016-02-03 06:15:58 +00:00
// In normal operation, writable files or directories are an error.
$file_protection_severity = REQUIREMENT_ERROR;
if (!drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir')) {
2017-03-04 01:20:24 +00:00
$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]);
2016-02-03 06:15:58 +00:00
}
2012-06-05 05:51:41 +00:00
}
2017-03-04 01:20:24 +00:00
foreach (['settings.php', 'settings.local.php', 'services.yml'] as $conf_file) {
2015-06-09 12:15:19 +00:00
$full_path = $site_path . '/' . $conf_file;
2018-06-15 12:51:03 +00:00
if (file_exists($full_path) && !drupal_verify_install_file($full_path, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE, 'file', !Settings::get('skip_permissions_hardening'))) {
2017-03-04 01:20:24 +00:00
$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]);
2012-06-05 05:51:41 +00:00
}
}
if (!empty($conf_errors)) {
if (count($conf_errors) == 1) {
$description = $conf_errors[0];
}
else {
2014-11-10 13:34:31 +00:00
// We use twig inline_template to avoid double escaping.
2017-03-04 01:20:24 +00:00
$description = [
2014-11-10 13:34:31 +00:00
'#type' => 'inline_template',
'#template' => '{{ configuration_error_list }}',
2017-03-04 01:20:24 +00:00
'#context' => [
'configuration_error_list' => [
2014-11-10 13:34:31 +00:00
'#theme' => 'item_list',
'#items' => $conf_errors,
2017-03-04 01:20:24 +00:00
],
],
];
2012-06-05 05:51:41 +00:00
}
2017-03-04 01:20:24 +00:00
$requirements['configuration_files'] = [
2018-06-15 12:51:03 +00:00
'value' => $error_value,
2016-02-03 06:15:58 +00:00
'severity' => $file_protection_severity,
2012-06-05 05:51:41 +00:00
'description' => $description,
2017-03-04 01:20:24 +00:00
];
2006-09-01 08:44:53 +00:00
}
else {
2017-03-04 01:20:24 +00:00
$requirements['configuration_files'] = [
2013-06-17 13:35:07 +00:00
'value' => t('Protected'),
2017-03-04 01:20:24 +00:00
];
2006-09-01 08:44:53 +00:00
}
2014-08-23 20:19:53 +00:00
$requirements['configuration_files']['title'] = t('Configuration files');
2006-09-01 08:44:53 +00:00
}
2014-02-27 04:48:12 +00:00
// Test the contents of the .htaccess files.
if ($phase == 'runtime') {
// Try to write the .htaccess files first, to prevent false alarms in case
// (for example) the /tmp directory was wiped.
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
/** @var \Drupal\Core\File\HtaccessWriterInterface $htaccessWriter */
$htaccessWriter = \Drupal::service("file.htaccess_writer");
$htaccessWriter->ensure();
foreach ($htaccessWriter->defaultProtectedDirs() as $protected_dir) {
$htaccess_file = $protected_dir->getPath() . '/.htaccess';
2014-02-27 04:48:12 +00:00
// Check for the string which was added to the recommended .htaccess file
// in the latest security update.
if (!file_exists($htaccess_file) || !($contents = @file_get_contents($htaccess_file)) || strpos($contents, 'Drupal_Security_Do_Not_Remove_See_SA_2013_003') === FALSE) {
Issue #2570355 by Sutharsan, stefan.r, kgoel, josephdpurcell, joelpittet, justAChris, dawehner, pfrenssen, pwolanin, David_Rothstein, catch: Replace remaining !placeholder and @placeholder with :placeholder for URLs
2015-09-22 06:16:37 +00:00
$url = 'https://www.drupal.org/SA-CORE-2013-003';
2017-03-04 01:20:24 +00:00
$requirements[$htaccess_file] = [
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
'title' => new TranslatableMarkup($protected_dir->getTitle()),
2014-02-27 04:48:12 +00:00
'value' => t('Not fully protected'),
'severity' => REQUIREMENT_ERROR,
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
'description' => t('See <a href=":url">@url</a> for information about the recommended .htaccess file which should be added to the %directory directory to help protect against arbitrary code execution.', [':url' => $url, '@url' => $url, '%directory' => $protected_dir->getPath()]),
2017-03-04 01:20:24 +00:00
];
2014-02-27 04:48:12 +00:00
}
}
}
2007-11-19 15:01:18 +00:00
// Report cron status.
2006-09-01 08:44:53 +00:00
if ($phase == 'runtime') {
2013-09-16 03:58:06 +00:00
$cron_config = \Drupal::config('system.cron');
2007-11-19 15:01:18 +00:00
// Cron warning threshold defaults to two days.
2012-07-21 19:16:31 +00:00
$threshold_warning = $cron_config->get('threshold.requirements_warning');
2007-11-19 15:01:18 +00:00
// Cron error threshold defaults to two weeks.
2012-07-21 19:16:31 +00:00
$threshold_error = $cron_config->get('threshold.requirements_error');
2007-11-19 15:01:18 +00:00
2008-11-05 14:28:04 +00:00
// Determine when cron last ran.
2013-09-16 03:58:06 +00:00
$cron_last = \Drupal::state()->get('system.cron_last');
2007-11-19 15:01:18 +00:00
if (!is_numeric($cron_last)) {
2013-11-16 21:29:18 +00:00
$cron_last = \Drupal::state()->get('install_time', 0);
2007-11-19 15:01:18 +00:00
}
2006-09-01 08:44:53 +00:00
2007-11-19 15:01:18 +00:00
// Determine severity based on time since cron last ran.
2012-05-25 05:42:59 +00:00
$severity = REQUIREMENT_INFO;
2008-09-17 07:11:59 +00:00
if (REQUEST_TIME - $cron_last > $threshold_error) {
2007-11-19 15:01:18 +00:00
$severity = REQUIREMENT_ERROR;
2006-09-01 08:44:53 +00:00
}
2008-11-05 14:28:04 +00:00
elseif (REQUEST_TIME - $cron_last > $threshold_warning) {
2007-11-19 15:01:18 +00:00
$severity = REQUIREMENT_WARNING;
}
// Set summary and description based on values determined above.
2017-03-04 01:20:24 +00:00
$summary = t('Last run @time ago', ['@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)]);
2008-03-17 16:53:58 +00:00
2017-03-04 01:20:24 +00:00
$requirements['cron'] = [
2013-06-17 13:35:07 +00:00
'title' => t('Cron maintenance tasks'),
2007-11-19 15:01:18 +00:00
'severity' => $severity,
'value' => $summary,
2017-03-04 01:20:24 +00:00
];
Issue #2296929 by stefan.r, josephdpurcell, codemonkie, YesCT, alexpott, akalata, herved, xjm, joelpittet, David_Rothstein, aneek, lauriii, kgoel, Cottser, effulgentsia, pfrenssen, pwolanin, Mile23: Remove system_requirements() SafeMarkup::set() use
2015-08-19 22:27:49 +00:00
if ($severity != REQUIREMENT_INFO) {
$requirements['cron']['description'][] = [
[
'#markup' => t('Cron has not run recently.'),
'#suffix' => ' ',
],
[
Issue #2570355 by Sutharsan, stefan.r, kgoel, josephdpurcell, joelpittet, justAChris, dawehner, pfrenssen, pwolanin, David_Rothstein, catch: Replace remaining !placeholder and @placeholder with :placeholder for URLs
2015-09-22 06:16:37 +00:00
'#markup' => t('For more information, see the online handbook entry for <a href=":cron-handbook">configuring cron jobs</a>.', [':cron-handbook' => 'https://www.drupal.org/cron']),
Issue #2296929 by stefan.r, josephdpurcell, codemonkie, YesCT, alexpott, akalata, herved, xjm, joelpittet, David_Rothstein, aneek, lauriii, kgoel, Cottser, effulgentsia, pfrenssen, pwolanin, Mile23: Remove system_requirements() SafeMarkup::set() use
2015-08-19 22:27:49 +00:00
'#suffix' => ' ',
],
];
}
$requirements['cron']['description'][] = [
[
Issue #665790 by chrisrockwell, Sumit kumar, lauriii, joelpittet, sun, vulcanr, vaplas, yoroy, leahtard, tompagabor, aspilicious, ckrina, Gábor Hojtsy, David_Rothstein, Manuel Garcia, rootwork, nod_, kostyashupenko, pguillard, Bojhan, droplet, typhonius, wturrell, mgifford, webkenny, cosmicdreams, tkoleary, YesCT, marcvangend, markabur, LewisNyman, mrfelton, oriol_e9g, prabhu9484, catch, hedrickbt, tsvenson, longwave, dww, kika, borisson_, rdellis87, realityloop, klonos: Redesign the status report page
2017-02-07 20:44:09 +00:00
'#type' => 'link',
'#prefix' => '(',
'#title' => t('more information'),
'#suffix' => ')',
'#url' => Url::fromRoute('system.cron_settings'),
Issue #2296929 by stefan.r, josephdpurcell, codemonkie, YesCT, alexpott, akalata, herved, xjm, joelpittet, David_Rothstein, aneek, lauriii, kgoel, Cottser, effulgentsia, pfrenssen, pwolanin, Mile23: Remove system_requirements() SafeMarkup::set() use
2015-08-19 22:27:49 +00:00
],
[
Issue #665790 by chrisrockwell, Sumit kumar, lauriii, joelpittet, sun, vulcanr, vaplas, yoroy, leahtard, tompagabor, aspilicious, ckrina, Gábor Hojtsy, David_Rothstein, Manuel Garcia, rootwork, nod_, kostyashupenko, pguillard, Bojhan, droplet, typhonius, wturrell, mgifford, webkenny, cosmicdreams, tkoleary, YesCT, marcvangend, markabur, LewisNyman, mrfelton, oriol_e9g, prabhu9484, catch, hedrickbt, tsvenson, longwave, dww, kika, borisson_, rdellis87, realityloop, klonos: Redesign the status report page
2017-02-07 20:44:09 +00:00
'#prefix' => '<span class="cron-description__run-cron">',
'#suffix' => '</span>',
'#type' => 'link',
'#title' => t('Run cron'),
'#url' => Url::fromRoute('system.run_cron'),
Issue #2296929 by stefan.r, josephdpurcell, codemonkie, YesCT, alexpott, akalata, herved, xjm, joelpittet, David_Rothstein, aneek, lauriii, kgoel, Cottser, effulgentsia, pfrenssen, pwolanin, Mile23: Remove system_requirements() SafeMarkup::set() use
2015-08-19 22:27:49 +00:00
],
];
2006-09-01 08:44:53 +00:00
}
Issue #1496480 by mrf, disasm, kbasarab, pfrenssen, cam8001, typhonius, Letharion, ACF, vijaycs85, heyrocker, Berdir, alexpott: Convert file system settings to the new configuration system.
2013-02-08 23:36:06 +00:00
if ($phase != 'install') {
2013-09-16 03:58:06 +00:00
$filesystem_config = \Drupal::config('system.file');
2017-03-04 01:20:24 +00:00
$directories = [
2013-08-22 01:11:07 +00:00
PublicStream::basePath(),
Issue #1496480 by mrf, disasm, kbasarab, pfrenssen, cam8001, typhonius, Letharion, ACF, vijaycs85, heyrocker, Berdir, alexpott: Convert file system settings to the new configuration system.
2013-02-08 23:36:06 +00:00
// By default no private files directory is configured. For private files
// to be secure the admin needs to provide a path outside the webroot.
2014-12-14 13:01:24 +00:00
PrivateStream::basePath(),
Issue #3039026 by kim.pepper, Berdir, Peter Majmesku, vadim.hirbu, YurkinPark, andypost, dww, claudiu.cristea, alexpott, jibran, dawehner, mikelutz: Deprecate file_directory_temp() and move to FileSystem service
2019-07-26 10:10:34 +00:00
\Drupal::service('file_system')->getTempDirectory(),
2017-03-04 01:20:24 +00:00
];
Issue #1496480 by mrf, disasm, kbasarab, pfrenssen, cam8001, typhonius, Letharion, ACF, vijaycs85, heyrocker, Berdir, alexpott: Convert file system settings to the new configuration system.
2013-02-08 23:36:06 +00:00
}
2006-09-01 08:44:53 +00:00
Issue #1496480 by mrf, disasm, kbasarab, pfrenssen, cam8001, typhonius, Letharion, ACF, vijaycs85, heyrocker, Berdir, alexpott: Convert file system settings to the new configuration system.
2013-02-08 23:36:06 +00:00
// During an install we need to make assumptions about the file system
// unless overrides are provided in settings.php.
2010-06-14 13:33:45 +00:00
if ($phase == 'install') {
2017-03-04 01:20:24 +00:00
$directories = [];
2014-03-24 08:51:28 +00:00
if ($file_public_path = Settings::get('file_public_path')) {
2013-08-22 01:11:07 +00:00
$directories[] = $file_public_path;
Issue #1496480 by mrf, disasm, kbasarab, pfrenssen, cam8001, typhonius, Letharion, ACF, vijaycs85, heyrocker, Berdir, alexpott: Convert file system settings to the new configuration system.
2013-02-08 23:36:06 +00:00
}
else {
// If we are installing Drupal, the settings.php file might not exist yet
2014-02-10 17:31:31 +00:00
// in the intended site directory, so don't require it.
2015-06-09 12:15:19 +00:00
$request = Request::createFromGlobals();
$site_path = DrupalKernel::findSitePath($request);
$directories[] = $site_path . '/files';
Issue #1496480 by mrf, disasm, kbasarab, pfrenssen, cam8001, typhonius, Letharion, ACF, vijaycs85, heyrocker, Berdir, alexpott: Convert file system settings to the new configuration system.
2013-02-08 23:36:06 +00:00
}
2014-12-14 13:01:24 +00:00
if ($file_private_path = Settings::get('file_private_path')) {
$directories[] = $file_private_path;
Issue #1496480 by mrf, disasm, kbasarab, pfrenssen, cam8001, typhonius, Letharion, ACF, vijaycs85, heyrocker, Berdir, alexpott: Convert file system settings to the new configuration system.
2013-02-08 23:36:06 +00:00
}
Issue #3039026 by kim.pepper, Berdir, Peter Majmesku, vadim.hirbu, YurkinPark, andypost, dww, claudiu.cristea, alexpott, jibran, dawehner, mikelutz: Deprecate file_directory_temp() and move to FileSystem service
2019-07-26 10:10:34 +00:00
if (Settings::get('file_temp_path')) {
$directories[] = Settings::get('file_temp_path');
Issue #1496480 by mrf, disasm, kbasarab, pfrenssen, cam8001, typhonius, Letharion, ACF, vijaycs85, heyrocker, Berdir, alexpott: Convert file system settings to the new configuration system.
2013-02-08 23:36:06 +00:00
}
else {
// If the temporary directory is not overridden use an appropriate
// temporary path for the system.
Issue #2620304 by kim.pepper, andypost, phenaproxima, mcdruid, alexpott, jibran, starshaped, kostyashupenko, nickolaj, Berdir, larowlan, catch, joachim, Mile23: htaccess functions should be a service
2019-09-30 02:09:49 +00:00
$directories[] = FileSystemComponent::getOsTemporaryDirectory();
Issue #1496480 by mrf, disasm, kbasarab, pfrenssen, cam8001, typhonius, Letharion, ACF, vijaycs85, heyrocker, Berdir, alexpott: Convert file system settings to the new configuration system.
2013-02-08 23:36:06 +00:00
}
2010-06-14 13:33:45 +00:00
}
2012-05-20 06:41:16 +00:00
// Check the config directory if it is defined in settings.php. If it isn't
// defined, the installer will create a valid config directory later, but
// during runtime we must always display an error.
2019-06-24 13:04:44 +00:00
$config_sync_directory = Settings::get('config_sync_directory');
if (!empty($config_sync_directory)) {
// If we're installing Drupal try and create the config sync directory.
if (!is_dir($config_sync_directory) && $phase == 'install') {
\Drupal::service('file_system')->prepareDirectory($config_sync_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
}
if (!is_dir($config_sync_directory)) {
if ($phase == 'install') {
$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' => $config_sync_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']);
2016-08-15 22:26:52 +00:00
}
2019-06-24 13:04:44 +00:00
else {
$description = t('The directory %directory does not exist.', ['%directory' => $config_sync_directory]);
2016-06-07 10:32:46 +00:00
}
2019-06-24 13:04:44 +00:00
$requirements['config sync directory'] = [
'title' => t('Configuration sync directory'),
'description' => $description,
'severity' => REQUIREMENT_ERROR,
];
2014-12-04 11:57:42 +00:00
}
2012-05-20 06:41:16 +00:00
}
2019-06-24 13:04:44 +00:00
if ($phase != 'install' && empty($config_sync_directory)) {
$requirements['config sync directory'] = [
'title' => t('Configuration sync directory'),
2013-06-17 13:35:07 +00:00
'value' => t('Not present'),
2019-06-24 13:04:44 +00:00
'description' => t("Your %file file must define the %setting setting as a string containing the directory in which configuration files can be found.", ['%file' => $site_path . '/settings.php', '%setting' => "\$settings['config_sync_directory']"]),
2012-05-20 06:41:16 +00:00
'severity' => REQUIREMENT_ERROR,
2017-03-04 01:20:24 +00:00
];
2012-05-20 06:41:16 +00:00
}
2017-03-04 01:20:24 +00:00
$requirements['file system'] = [
2013-06-17 13:35:07 +00:00
'title' => t('File system'),
2017-03-04 01:20:24 +00:00
];
2007-12-27 17:25:28 +00:00
2009-08-17 19:14:42 +00:00
$error = '';
// For installer, create the directories if possible.
foreach ($directories as $directory) {
2010-04-30 01:33:17 +00:00
if (!$directory) {
continue;
}
2009-08-17 19:14:42 +00:00
if ($phase == 'install') {
Issue #2244513 by kim.pepper, phenaproxima, 20th, andrei.dincu, beejeebus, Berdir, alexpott, jibran, andypost, larowlan, Chadwick Wood, acbramley, Wim Leers, sun, xjm, YesCT, chx, tim.plunkett: Move the unmanaged file APIs to the file_system service (file.inc)
2019-02-23 22:35:15 +00:00
\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
2008-01-16 10:37:43 +00:00
}
2009-08-17 19:14:42 +00:00
$is_writable = is_writable($directory);
$is_directory = is_dir($directory);
if (!$is_writable || !$is_directory) {
$description = '';
2013-06-17 13:35:07 +00:00
$requirements['file system']['value'] = t('Not writable');
2009-08-17 19:14:42 +00:00
if (!$is_directory) {
2017-03-04 01:20:24 +00:00
$error = t('The directory %directory does not exist.', ['%directory' => $directory]);
2009-08-17 19:14:42 +00:00
}
else {
2017-03-04 01:20:24 +00:00
$error = t('The directory %directory is not writable.', ['%directory' => $directory]);
2009-08-17 19:14:42 +00:00
}
// The files directory requirement check is done only during install and runtime.
if ($phase == 'runtime') {
2019-04-16 05:38:27 +00:00
$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()]);
2009-08-17 19:14:42 +00:00
}
elseif ($phase == 'install') {
// For the installer UI, we need different wording. 'value' will
// be treated as version, so provide none there.
2017-03-04 01:20:24 +00:00
$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']);
2009-08-17 19:14:42 +00:00
$requirements['file system']['value'] = '';
}
if (!empty($description)) {
2017-03-04 01:20:24 +00:00
$description = [
2014-11-10 13:34:31 +00:00
'#type' => 'inline_template',
'#template' => '{{ error }} {{ description }}',
2017-03-04 01:20:24 +00:00
'#context' => [
2014-11-10 13:34:31 +00:00
'error' => $error,
'description' => $description,
2017-03-04 01:20:24 +00:00
],
];
2009-08-17 19:14:42 +00:00
$requirements['file system']['description'] = $description;
$requirements['file system']['severity'] = REQUIREMENT_ERROR;
}
2007-11-15 23:12:38 +00:00
}
else {
2013-04-07 20:06:33 +00:00
// This function can be called before the config_cache table has been
// created.
2019-05-17 02:15:25 +00:00
if ($phase == 'install' || \Drupal::config('system.file')->get('default_scheme') == 'public') {
2013-06-17 13:35:07 +00:00
$requirements['file system']['value'] = t('Writable (<em>public</em> download method)');
2009-08-17 19:14:42 +00:00
}
else {
2013-06-17 13:35:07 +00:00
$requirements['file system']['value'] = t('Writable (<em>private</em> download method)');
2009-08-17 19:14:42 +00:00
}
2006-12-12 09:29:43 +00:00
}
}
2006-12-01 08:07:12 +00:00
// See if updates are available in update.php.
if ($phase == 'runtime') {
2017-03-04 01:20:24 +00:00
$requirements['update'] = [
2013-06-17 13:35:07 +00:00
'title' => t('Database updates'),
'value' => t('Up to date'),
2017-03-04 01:20:24 +00:00
];
2006-12-01 08:07:12 +00:00
// Check installed modules.
2015-09-09 17:07:09 +00:00
$has_pending_updates = FALSE;
2013-09-16 03:58:06 +00:00
foreach (\Drupal::moduleHandler()->getModuleList() as $module => $filename) {
2006-12-01 08:07:12 +00:00
$updates = drupal_get_schema_versions($module);
if ($updates !== FALSE) {
$default = drupal_get_installed_schema_version($module);
if (max($updates) > $default) {
2015-09-09 17:07:09 +00:00
$has_pending_updates = TRUE;
2006-12-01 08:07:12 +00:00
break;
}
}
}
2015-09-09 17:07:09 +00:00
if (!$has_pending_updates) {
/** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
$post_update_registry = \Drupal::service('update.post_update_registry');
$missing_post_update_functions = $post_update_registry->getPendingUpdateFunctions();
if (!empty($missing_post_update_functions)) {
$has_pending_updates = TRUE;
}
}
if ($has_pending_updates) {
$requirements['update']['severity'] = REQUIREMENT_ERROR;
$requirements['update']['value'] = t('Out of date');
2019-04-16 05:38:27 +00:00
$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()]);
2015-09-09 17:07:09 +00:00
}
2015-08-27 05:28:17 +00:00
2015-10-30 20:45:01 +00:00
$requirements['entity_update'] = [
'title' => t('Entity/field definitions'),
'value' => t('Up to date'),
];
// Verify that no entity updates are pending.
2015-11-25 20:20:02 +00:00
if ($change_list = \Drupal::entityDefinitionUpdateManager()->getChangeSummary()) {
$build = [];
foreach ($change_list as $entity_type_id => $changes) {
2019-05-24 06:44:36 +00:00
$entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
2015-11-25 20:20:02 +00:00
$build[] = [
'#theme' => 'item_list',
'#title' => $entity_type->getLabel(),
'#items' => $changes,
];
}
2016-06-30 11:11:38 +00:00
$entity_update_issues = \Drupal::service('renderer')->renderPlain($build);
2015-10-30 20:45:01 +00:00
$requirements['entity_update']['severity'] = REQUIREMENT_ERROR;
$requirements['entity_update']['value'] = t('Mismatched entity and/or field definitions');
2015-11-25 20:20:02 +00:00
$requirements['entity_update']['description'] = t('The following changes were detected in the entity type and field definitions. @updates', ['@updates' => $entity_update_issues]);
2014-09-15 20:37:27 +00:00
}
2006-12-01 08:07:12 +00:00
}
2007-08-28 11:42:56 +00:00
// Verify the update.php access setting
if ($phase == 'runtime') {
2014-03-24 08:51:28 +00:00
if (Settings::get('update_free_access')) {
2017-03-04 01:20:24 +00:00
$requirements['update access'] = [
2013-06-17 13:35:07 +00:00
'value' => t('Not protected'),
2007-08-28 11:42:56 +00:00
'severity' => REQUIREMENT_ERROR,
2017-03-04 01:20:24 +00:00
'description' => t('The update.php script is accessible to everyone without authentication check, which is a security risk. You must change the @settings_name value in your settings.php back to FALSE.', ['@settings_name' => '$settings[\'update_free_access\']']),
];
2007-08-28 11:42:56 +00:00
}
else {
2017-03-04 01:20:24 +00:00
$requirements['update access'] = [
2013-06-17 13:35:07 +00:00
'value' => t('Protected'),
2017-03-04 01:20:24 +00:00
];
2007-08-28 11:42:56 +00:00
}
2013-06-17 13:35:07 +00:00
$requirements['update access']['title'] = t('Access to update.php');
2007-08-28 11:42:56 +00:00
}
2010-05-16 20:08:38 +00:00
// Display an error if a newly introduced dependency in a module is not resolved.
if ($phase == 'update') {
2019-07-22 08:31:06 +00:00
$profile = \Drupal::installProfile();
2019-06-03 11:49:38 +00:00
$files = \Drupal::service('extension.list.module')->getList();
2010-05-16 20:08:38 +00:00
foreach ($files as $module => $file) {
2012-10-05 16:11:15 +00:00
// Ignore disabled modules and installation profiles.
2010-06-17 02:12:44 +00:00
if (!$file->status || $module == $profile) {
2010-05-16 20:08:38 +00:00
continue;
}
// Check the module's PHP version.
$name = $file->info['name'];
$php = $file->info['php'];
if (version_compare($php, PHP_VERSION, '>')) {
2017-03-04 01:20:24 +00:00
$requirements['php']['description'] .= t('@name requires at least PHP @version.', ['@name' => $name, '@version' => $php]);
2010-05-16 20:08:38 +00:00
$requirements['php']['severity'] = REQUIREMENT_ERROR;
}
// Check the module's required modules.
Issue #2677532 by alexpott, Mile23, kim.pepper, dawehner, andypost, Eric_A, xjm, Mixologic, larowlan, phenaproxima, markcarver, borisson_: Move drupal_check_incompatibility() functionality to a new Dependency class and Version component
2018-10-22 05:21:49 +00:00
/** @var \Drupal\Core\Extension\Dependency $requirement */
2010-05-16 20:08:38 +00:00
foreach ($file->requires as $requirement) {
Issue #2677532 by alexpott, Mile23, kim.pepper, dawehner, andypost, Eric_A, xjm, Mixologic, larowlan, phenaproxima, markcarver, borisson_: Move drupal_check_incompatibility() functionality to a new Dependency class and Version component
2018-10-22 05:21:49 +00:00
$required_module = $requirement->getName();
2010-05-16 20:08:38 +00:00
// Check if the module exists.
if (!isset($files[$required_module])) {
2017-03-04 01:20:24 +00:00
$requirements["$module-$required_module"] = [
2013-06-17 13:35:07 +00:00
'title' => t('Unresolved dependency'),
2017-03-04 01:20:24 +00:00
'description' => t('@name requires this module.', ['@name' => $name]),
'value' => t('@required_name (Missing)', ['@required_name' => $required_module]),
2010-05-16 20:08:38 +00:00
'severity' => REQUIREMENT_ERROR,
2017-03-04 01:20:24 +00:00
];
2010-05-16 20:08:38 +00:00
continue;
}
// Check for an incompatible version.
$required_file = $files[$required_module];
$required_name = $required_file->info['name'];
2013-09-16 03:58:06 +00:00
$version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $required_file->info['version']);
Issue #2677532 by alexpott, Mile23, kim.pepper, dawehner, andypost, Eric_A, xjm, Mixologic, larowlan, phenaproxima, markcarver, borisson_: Move drupal_check_incompatibility() functionality to a new Dependency class and Version component
2018-10-22 05:21:49 +00:00
if (!$requirement->isCompatible($version)) {
2017-03-04 01:20:24 +00:00
$requirements["$module-$required_module"] = [
2013-06-17 13:35:07 +00:00
'title' => t('Unresolved dependency'),
2017-03-04 01:20:24 +00:00
'description' => t('@name requires this module and version. Currently using @required_name version @version', ['@name' => $name, '@required_name' => $required_name, '@version' => $version]),
Issue #2677532 by alexpott, Mile23, kim.pepper, dawehner, andypost, Eric_A, xjm, Mixologic, larowlan, phenaproxima, markcarver, borisson_: Move drupal_check_incompatibility() functionality to a new Dependency class and Version component
2018-10-22 05:21:49 +00:00
'value' => t('@required_name (Version @compatibility required)', ['@required_name' => $required_name, '@compatibility' => $requirement->getConstraintString()]),
2010-05-16 20:08:38 +00:00
'severity' => REQUIREMENT_ERROR,
2017-03-04 01:20:24 +00:00
];
2010-05-16 20:08:38 +00:00
continue;
}
}
}
}
2017-06-22 11:52:57 +00:00
// Returns Unicode library status and errors.
$libraries = [
Unicode::STATUS_SINGLEBYTE => t('Standard PHP'),
Unicode::STATUS_MULTIBYTE => t('PHP Mbstring Extension'),
Unicode::STATUS_ERROR => t('Error'),
];
$severities = [
Unicode::STATUS_SINGLEBYTE => REQUIREMENT_WARNING,
Unicode::STATUS_MULTIBYTE => NULL,
Unicode::STATUS_ERROR => REQUIREMENT_ERROR,
];
$failed_check = Unicode::check();
$library = Unicode::getStatus();
$requirements['unicode'] = [
'title' => t('Unicode library'),
'value' => $libraries[$library],
'severity' => $severities[$library],
];
switch ($failed_check) {
case 'mb_strlen':
$requirements['unicode']['description'] = t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="http://php.net/mbstring">PHP mbstring extension</a> for improved Unicode support.');
break;
case 'mbstring.func_overload':
$requirements['unicode']['description'] = t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
break;
case 'mbstring.encoding_translation':
$requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
break;
case 'mbstring.http_input':
$requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
break;
case 'mbstring.http_output':
$requirements['unicode']['description'] = t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
break;
}
2006-09-01 08:44:53 +00:00
2007-11-06 09:00:31 +00:00
if ($phase == 'runtime') {
2009-01-14 21:13:42 +00:00
// Check for update status module.
2013-10-16 12:17:55 +00:00
if (!\Drupal::moduleHandler()->moduleExists('update')) {
2017-03-04 01:20:24 +00:00
$requirements['update status'] = [
2013-06-17 13:35:07 +00:00
'value' => t('Not enabled'),
2008-08-14 12:59:05 +00:00
'severity' => REQUIREMENT_WARNING,
2017-03-04 01:20:24 +00:00
'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>.', [
Issue #2570355 by Sutharsan, stefan.r, kgoel, josephdpurcell, joelpittet, justAChris, dawehner, pfrenssen, pwolanin, David_Rothstein, catch: Replace remaining !placeholder and @placeholder with :placeholder for URLs
2015-09-22 06:16:37 +00:00
':update' => 'https://www.drupal.org/documentation/modules/update',
2019-04-16 05:38:27 +00:00
':module' => Url::fromRoute('system.modules_list')->toString(),
2017-03-04 01:20:24 +00:00
]),
];
2007-11-06 09:00:31 +00:00
}
else {
2017-03-04 01:20:24 +00:00
$requirements['update status'] = [
2013-06-17 13:35:07 +00:00
'value' => t('Enabled'),
2017-03-04 01:20:24 +00:00
];
2007-11-06 09:00:31 +00:00
}
2013-06-17 13:35:07 +00:00
$requirements['update status']['title'] = t('Update notifications');
2013-12-10 13:50:21 +00:00
2014-03-24 08:51:28 +00:00
if (Settings::get('rebuild_access')) {
2017-03-04 01:20:24 +00:00
$requirements['rebuild access'] = [
2013-12-10 13:50:21 +00:00
'title' => t('Rebuild access'),
'value' => t('Enabled'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The rebuild_access setting is enabled in settings.php. It is recommended to have this setting disabled unless you are performing a rebuild.'),
2017-03-04 01:20:24 +00:00
];
2013-12-10 13:50:21 +00:00
}
2007-11-06 09:00:31 +00:00
}
2015-01-22 18:57:56 +00:00
// See if trusted hostnames have been configured, and warn the user if they
// are not set.
if ($phase == 'runtime') {
$trusted_host_patterns = Settings::get('trusted_host_patterns');
if (empty($trusted_host_patterns)) {
2017-03-04 01:20:24 +00:00
$requirements['trusted_host_patterns'] = [
2015-01-22 18:57:56 +00:00
'title' => t('Trusted Host Settings'),
'value' => t('Not enabled'),
2018-12-26 19:39:50 +00:00
'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']),
2015-01-22 18:57:56 +00:00
'severity' => REQUIREMENT_ERROR,
2017-03-04 01:20:24 +00:00
];
2015-01-22 18:57:56 +00:00
}
else {
2017-03-04 01:20:24 +00:00
$requirements['trusted_host_patterns'] = [
2015-01-22 18:57:56 +00:00
'title' => t('Trusted Host Settings'),
'value' => t('Enabled'),
2017-09-17 21:58:08 +00:00
'description' => t('The trusted_host_patterns setting is set to allow %trusted_host_patterns', ['%trusted_host_patterns' => implode(', ', $trusted_host_patterns)]),
2017-03-04 01:20:24 +00:00
];
2015-01-22 18:57:56 +00:00
}
}
2015-05-09 13:00:32 +00:00
2015-05-10 19:11:20 +00:00
// Check xdebug.max_nesting_level, as some pages will not work if it is too
// low.
if (extension_loaded('xdebug')) {
// Setting this value to 256 was considered adequate on Xdebug 2.3
// (see http://bugs.xdebug.org/bug_view_page.php?bug_id=00001100)
$minimum_nesting_level = 256;
$current_nesting_level = ini_get('xdebug.max_nesting_level');
if ($current_nesting_level < $minimum_nesting_level) {
$requirements['xdebug_max_nesting_level'] = [
'title' => t('Xdebug settings'),
'value' => t('xdebug.max_nesting_level is set to %value.', ['%value' => $current_nesting_level]),
'description' => t('Set <code>xdebug.max_nesting_level=@level</code> in your PHP configuration as some pages in your Drupal site will not work when this setting is too low.', ['@level' => $minimum_nesting_level]),
'severity' => REQUIREMENT_ERROR,
];
}
}
2015-01-22 18:57:56 +00:00
2016-09-22 20:52:14 +00:00
// Warning for httpoxy on IIS with affected PHP versions
// @see https://www.drupal.org/node/2783079
2019-05-24 10:36:30 +00:00
if (strpos($software, 'Microsoft-IIS') !== FALSE && version_compare(PHP_VERSION, '7.0.9', '<')) {
2016-09-22 20:52:14 +00:00
$dom = new \DOMDocument('1.0', 'UTF-8');
$webconfig = file_get_contents('web.config');
// If you are here the web.config file must - of course - be well formed.
// But the PHP DOM component will throw warnings on some XML compliant
// stuff, so silently parse the configuration file.
@$dom->loadHTML($webconfig);
$httpoxy_rewrite = FALSE;
foreach ($dom->getElementsByTagName('rule') as $rule) {
foreach ($rule->attributes as $attr) {
if (@$attr->name == 'name' && @$attr->nodeValue == 'Erase HTTP_PROXY') {
$httpoxy_rewrite = TRUE;
break 2;
}
}
}
if (!$httpoxy_rewrite) {
$requirements['iis_httpoxy_protection'] = [
'title' => t('IIS httpoxy protection'),
'value' => t('Your PHP runtime version is affected by the httpoxy vulnerability.'),
'description' => t('Either update your PHP runtime version or uncomment the "Erase HTTP_PROXY" rule in your web.config file and add HTTP_PROXY to the allowed headers list. See more details in the <a href=":link">security advisory</a>.', [':link' => 'https://www.drupal.org/SA-CORE-2016-003']),
'severity' => REQUIREMENT_ERROR,
];
}
}
Issue #2606772 by mikeker, pwolanin, YesCT, david_garcia, alexpott, cilefen, xjm, Cottser, catch, joelpittet, effulgentsia, kevla, dawehner: Long Twig cache directories can cause failures on some filesystems
2017-02-06 09:01:01 +00:00
// Installations on Windows can run into limitations with MAX_PATH if the
// Drupal root directory is too deep in the filesystem. Generally this shows
// up in cached Twig templates and other public files with long directory or
// file names. There is no definite root directory depth below which Drupal is
// guaranteed to function correctly on Windows. Since problems are likely
// with more than 100 characters in the Drupal root path, show an error.
if (substr(PHP_OS, 0, 3) == 'WIN') {
$depth = strlen(realpath(DRUPAL_ROOT . '/' . PublicStream::basePath()));
if ($depth > 120) {
$requirements['max_path_on_windows'] = [
'title' => t('Windows installation depth'),
'description' => t('The public files directory path is %depth characters. Paths longer than 120 characters will cause problems on Windows.', ['%depth' => $depth]),
'severity' => REQUIREMENT_ERROR,
];
}
}
Issue #2795489 by mpdonadio, gambry, Yogesh Pawar, cilefen, Munavijayalakshmi, wturrell, jhedstrom, xjm, catch, pjohn, ednawig: 2038 bug with PHP timestamps on 32-bit systems - warn users?
2017-06-23 19:38:22 +00:00
// Check to see if dates will be limited to 1901-2038.
if (PHP_INT_SIZE <= 4) {
$requirements['limited_date_range'] = [
'title' => t('Limited date range'),
'value' => t('Your PHP installation has a limited date range.'),
'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']),
'severity' => REQUIREMENT_WARNING,
];
}
Issue #2606772 by mikeker, pwolanin, YesCT, david_garcia, alexpott, cilefen, xjm, Cottser, catch, joelpittet, effulgentsia, kevla, dawehner: Long Twig cache directories can cause failures on some filesystems
2017-02-06 09:01:01 +00:00
Issue #2788777 by alexpott, bircher, jribeiro, Eli-T, mpotter, douggreen, GoZ, DamienMcKenna, Dane Powell, jibran, szeidler, Alumei, andypost, dawehner, johndevman: Allow a site-specific profile to be installed from existing config
2018-06-20 18:03:54 +00:00
// During installs from configuration don't support install profiles that
// implement hook_install.
if ($phase == 'install' && !empty($install_state['config_install_path'])) {
$install_hook = $install_state['parameters']['profile'] . '_install';
if (function_exists($install_hook)) {
$requirements['config_install'] = [
'title' => t('Configuration install'),
'value' => $install_state['parameters']['profile'],
'description' => t('The selected profile has a hook_install() implementation and therefore can not be installed from configuration.'),
'severity' => REQUIREMENT_ERROR,
];
}
}
2018-06-25 19:12:22 +00:00
if ($phase === 'runtime') {
$settings = Settings::getAll();
if (array_key_exists('install_profile', $settings)) {
// The following message is only informational because not all site owners
// have access to edit their settings.php as it may be controlled by their
// hosting provider.
$requirements['install_profile_in_settings'] = [
'title' => t('Install profile in settings'),
'value' => t("Drupal 8 no longer uses the \$settings['install_profile'] value in settings.php and it can be removed."),
'severity' => REQUIREMENT_INFO,
];
}
}
2019-10-22 16:13:37 +00:00
// Prevent installation or update if the Pathauto module is installed and its
// version is less than 1.6.
if ($phase === 'install' || $phase === 'update') {
if (\Drupal::moduleHandler()->moduleExists('pathauto')) {
$info = \Drupal::service('extension.list.module')->getExtensionInfo('pathauto');
if (version_compare($info['version'], '8.x-1.5') <= 0) {
$requirements['pathauto_module_incompatibility'] = [
'title' => t('Pathauto'),
'description' => t('The Pathauto module is not compatible with the current version of Drupal core. Update the <a href=":url">Pathauto</a> module to 8.x-1.6 or later.', [
':url' => 'https://drupal.org/project/pathauto',
]),
'severity' => REQUIREMENT_ERROR,
];
}
}
}
2006-09-01 08:44:53 +00:00
return $requirements;
}
2006-09-01 07:40:08 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_install().
2006-09-01 07:40:08 +00:00
*/
2006-07-13 13:14:25 +00:00
function system_install() {
2012-11-09 20:35:14 +00:00
// Populate the cron key state variable.
2014-02-27 04:48:12 +00:00
$cron_key = Crypt::randomBytesBase64(55);
2013-09-16 03:58:06 +00:00
\Drupal::state()->set('system.cron_key', $cron_key);
2014-01-03 07:48:25 +00:00
2015-03-31 15:19:26 +00:00
// Populate the site UUID and default name (if not set).
$site = \Drupal::configFactory()->getEditable('system.site');
$site->set('uuid', \Drupal::service('uuid')->generate());
if (!$site->get('name')) {
$site->set('name', 'Drupal');
}
2015-05-05 10:47:16 +00:00
$site->save(TRUE);
2006-07-13 13:14:25 +00:00
}
2007-10-05 14:43:26 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_schema().
2007-10-05 14:43:26 +00:00
*/
function system_schema() {
2017-03-04 01:20:24 +00:00
$schema['key_value'] = [
2016-09-28 16:22:20 +00:00
'description' => 'Generic key-value storage table. See the state system for an example.',
2017-03-04 01:20:24 +00:00
'fields' => [
'collection' => [
2016-09-28 16:22:20 +00:00
'description' => 'A named collection of key and value pairs.',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
2017-03-04 01:20:24 +00:00
],
'name' => [
2016-09-28 16:22:20 +00:00
'description' => 'The key of the key-value pair. As KEY is a SQL reserved keyword, name was chosen instead.',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
2017-03-04 01:20:24 +00:00
],
'value' => [
2016-09-28 16:22:20 +00:00
'description' => 'The value.',
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
2017-03-04 01:20:24 +00:00
],
],
'primary key' => ['collection', 'name'],
];
2016-09-28 16:22:20 +00:00
2017-03-04 01:20:24 +00:00
$schema['key_value_expire'] = [
2016-09-28 16:22:20 +00:00
'description' => 'Generic key/value storage table with an expiration.',
2017-03-04 01:20:24 +00:00
'fields' => [
'collection' => [
2016-09-28 16:22:20 +00:00
'description' => 'A named collection of key and value pairs.',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
2017-03-04 01:20:24 +00:00
],
'name' => [
2016-09-28 16:22:20 +00:00
// KEY is an SQL reserved word, so use 'name' as the key's field name.
'description' => 'The key of the key/value pair.',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
2017-03-04 01:20:24 +00:00
],
'value' => [
2016-09-28 16:22:20 +00:00
'description' => 'The value of the key/value pair.',
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
2017-03-04 01:20:24 +00:00
],
'expire' => [
2016-09-28 16:22:20 +00:00
'description' => 'The time since Unix epoch in seconds when this item expires. Defaults to the maximum possible time.',
'type' => 'int',
'not null' => TRUE,
'default' => 2147483647,
2017-03-04 01:20:24 +00:00
],
],
'primary key' => ['collection', 'name'],
'indexes' => [
'all' => ['name', 'collection', 'expire'],
'expire' => ['expire'],
],
];
$schema['sequences'] = [
2009-10-18 06:56:24 +00:00
'description' => 'Stores IDs.',
2017-03-04 01:20:24 +00:00
'fields' => [
'value' => [
2009-10-18 06:56:24 +00:00
'description' => 'The value of the sequence.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
2017-03-04 01:20:24 +00:00
],
],
'primary key' => ['value'],
];
2009-10-18 06:56:24 +00:00
2017-03-04 01:20:24 +00:00
$schema['sessions'] = [
2008-11-15 13:01:11 +00:00
'description' => "Drupal's session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated.",
2017-03-04 01:20:24 +00:00
'fields' => [
'uid' => [
2009-02-26 07:30:29 +00:00
'description' => 'The {users}.uid corresponding to a session, or 0 for anonymous user.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'unsigned' => TRUE,
2008-03-15 12:31:29 +00:00
'not null' => TRUE,
2017-03-04 01:20:24 +00:00
],
'sid' => [
2014-01-27 11:44:25 +00:00
'description' => "A session ID (hashed). The value is generated by Drupal's session handlers.",
2015-05-05 16:42:09 +00:00
'type' => 'varchar_ascii',
2010-06-27 10:48:17 +00:00
'length' => 128,
2007-10-10 11:39:35 +00:00
'not null' => TRUE,
2017-03-04 01:20:24 +00:00
],
'hostname' => [
2008-11-15 13:01:11 +00:00
'description' => 'The IP address that last used this session ID (sid).',
2015-05-05 16:42:09 +00:00
'type' => 'varchar_ascii',
2007-10-10 11:39:35 +00:00
'length' => 128,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => '',
2017-03-04 01:20:24 +00:00
],
'timestamp' => [
2008-11-15 13:01:11 +00:00
'description' => 'The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
2017-03-04 01:20:24 +00:00
],
'session' => [
2008-11-15 13:01:11 +00:00
'description' => 'The serialized contents of $_SESSION, an array of name/value pairs that persists across page requests by this session ID. Drupal loads $_SESSION from here at the start of each request and saves it at the end.',
2010-06-25 17:47:22 +00:00
'type' => 'blob',
2007-10-10 11:39:35 +00:00
'not null' => FALSE,
2008-03-15 12:31:29 +00:00
'size' => 'big',
2017-03-04 01:20:24 +00:00
],
],
'primary key' => [
2010-06-14 12:31:46 +00:00
'sid',
2017-03-04 01:20:24 +00:00
],
'indexes' => [
'timestamp' => ['timestamp'],
'uid' => ['uid'],
],
'foreign keys' => [
'session_user' => [
2010-08-22 13:55:53 +00:00
'table' => 'users',
2017-03-04 01:20:24 +00:00
'columns' => ['uid' => 'uid'],
],
],
];
2007-10-05 14:43:26 +00:00
return $schema;
}
2015-07-30 10:25:26 +00:00
2016-05-08 16:29:19 +00:00
/**
Issue #3087644 by jibran, Berdir, alexpott, longwave, Wim Leers, amateescu, catch, xjm, larowlan, dpi, quietone: Remove Drupal 8 updates up to and including 88**
2020-01-24 23:52:03 +00:00
* Implements hook_update_last_removed().
2015-07-30 10:25:26 +00:00
*/
Issue #3087644 by jibran, Berdir, alexpott, longwave, Wim Leers, amateescu, catch, xjm, larowlan, dpi, quietone: Remove Drupal 8 updates up to and including 88**
2020-01-24 23:52:03 +00:00
function system_update_last_removed() {
return 8805;
2016-08-23 07:43:52 +00:00
}
Issue #2796953 by Wim Leers, mondrake, effulgentsia, catch, mikeryan, ayalon, chx, Fabianx, tim.plunkett, jibran, xjm, slashrsm, phenaproxima, borisson_: [regression] Plugins extending from classes of uninstalled modules lead to fatal error
2016-09-21 08:09:07 +00:00
/**
Issue #3087644 by jibran, Berdir, alexpott, longwave, Wim Leers, amateescu, catch, xjm, larowlan, dpi, quietone: Remove Drupal 8 updates up to and including 88**
2020-01-24 23:52:03 +00:00
* Ensures that Drupal is updated from a supported version.
Issue #2796953 by Wim Leers, mondrake, effulgentsia, catch, mikeryan, ayalon, chx, Fabianx, tim.plunkett, jibran, xjm, slashrsm, phenaproxima, borisson_: [regression] Plugins extending from classes of uninstalled modules lead to fatal error
2016-09-21 08:09:07 +00:00
*/
Issue #3087644 by jibran, Berdir, alexpott, longwave, Wim Leers, amateescu, catch, xjm, larowlan, dpi, quietone: Remove Drupal 8 updates up to and including 88**
2020-01-24 23:52:03 +00:00
function system_update_9000() {
// See update_get_update_list(), there needs to be at least one update
// function to check for the last removed schema version.
2019-11-07 19:46:18 +00:00
}