Commit 9663575f authored by Sergey Shadrin's avatar Sergey Shadrin

[#124455] Docroot directory moved to match with composer installed relative paths

parent bd595219

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

sites/*/files
!sites/*/files/
sites/*/files/*
!sites/*/files/translations
sites/*/private
sites/*/settings.php
docroot/sites/*/files
!docroot/sites/*/files/
docroot/sites/*/files/*
!docroot/sites/*/files/translations
docroot/sites/*/private
docroot/sites/*/settings.php
# Exclude IDE specific directories.
.idea
.vscode
This file was automatically generated by Composer Patches (https://github.com/cweagans/composer-patches)
Patches applied to this directory:
2698057 Add support for <nolink>, <none> and empty values to the UI
Source: https://www.drupal.org/files/issues/2018-04-17/add_nolink_support-2698057-23.patch
<svg width="214" height="214" viewBox="0 0 214 214" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M172 59C154.963 36 135 19 105 0C110.5 30.5 58.5 50 41 68.5C23.5 87 17 106.188 17 125.902C17 174.204 57.6985 213.5 106 213.5C154.302 213.5 196.5 174.204 196.5 125.902C196.5 106.188 189.037 82 172 59Z" fill="#cccccc"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M105.318 83.5C92.4745 83.5 81.0102 88.6894 73.0589 96.8593C70.2775 99.7171 68.2075 104.354 67.3793 109.481C66.5258 114.766 67.2414 118.928 68.2111 120.763C58 122 51.5 113 52.5 104.5C53.2059 98.5 55.8754 91.5746 61.5929 85.7C72.5277 74.4646 88.115 67.5 105.318 67.5C137.872 67.5 165 92.6234 165 124.5C165 156.377 137.872 181.5 105.318 181.5C100.829 181.5 93.7529 180.358 90 180C85.3088 179.654 71.5 179 64 182L83.5 108.5C85.5 102 91.7553 98.2637 102.602 99.6635L84.5586 164.168C86.3276 164.183 88.0427 164.274 89.7083 164.397C91.628 164.538 93.3802 164.707 95.0667 164.87C98.4724 165.198 101.61 165.5 105.318 165.5C129.85 165.5 149 146.747 149 124.5C149 102.253 129.85 83.5 105.318 83.5Z" fill="white"/>
</svg>
<?php
namespace Drupal\link\Plugin\Field\FieldWidget;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
use Drupal\Core\Entity\Element\EntityAutocomplete;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\link\LinkItemInterface;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationListInterface;
/**
* Plugin implementation of the 'link' widget.
*
* @FieldWidget(
* id = "link_default",
* label = @Translation("Link"),
* field_types = {
* "link"
* }
* )
*/
class LinkWidget extends WidgetBase {
/**
* {@inheritdoc}
*/
public static function defaultSettings() {
return [
'placeholder_url' => '',
'placeholder_title' => '',
] + parent::defaultSettings();
}
/**
* Gets the URI without the 'internal:' or 'entity:' scheme.
*
* The following two forms of URIs are transformed:
* - 'entity:' URIs: to entity autocomplete ("label (entity id)") strings;
* - 'internal:' URIs: the scheme is stripped.
*
* This method is the inverse of ::getUserEnteredStringAsUri().
*
* @param string $uri
* The URI to get the displayable string for.
*
* @return string
*
* @see static::getUserEnteredStringAsUri()
*/
protected static function getUriAsDisplayableString($uri) {
$scheme = parse_url($uri, PHP_URL_SCHEME);
// By default, the displayable string is the URI.
$displayable_string = $uri;
// A different displayable string may be chosen in case of the 'internal:'
// or 'entity:' built-in schemes.
if ($scheme === 'internal') {
$uri_reference = explode(':', $uri, 2)[1];
// @todo '<front>' is valid input for BC reasons, may be removed by
// https://www.drupal.org/node/2421941
$path = parse_url($uri, PHP_URL_PATH);
if ($path === '/') {
$uri_reference = '<front>' . substr($uri_reference, 1);
}
$displayable_string = $uri_reference;
}
elseif ($scheme === 'entity') {
list($entity_type, $entity_id) = explode('/', substr($uri, 7), 2);
// Show the 'entity:' URI as the entity autocomplete would.
// @todo Support entity types other than 'node'. Will be fixed in
// https://www.drupal.org/node/2423093.
if ($entity_type == 'node' && $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity_id)) {
$displayable_string = EntityAutocomplete::getEntityLabels([$entity]);
}
}
elseif ($scheme === 'route') {
$displayable_string = ltrim($displayable_string, 'route:');
}
elseif ($uri == 'route:<nolink>') {
$displayable_string = '<nolink>';
}
return $displayable_string;
}
/**
* Gets the user-entered string as a URI.
*
* The following two forms of input are mapped to URIs:
* - entity autocomplete ("label (entity id)") strings: to 'entity:' URIs;
* - strings without a detectable scheme: to 'internal:' URIs.
*
* This method is the inverse of ::getUriAsDisplayableString().
*
* @param string $string
* The user-entered string.
*
* @return string
* The URI, if a non-empty $uri was passed.
*
* @see static::getUriAsDisplayableString()
*/
protected static function getUserEnteredStringAsUri($string) {
// By default, assume the entered string is a URI.
$uri = trim($string);
// Detect entity autocomplete string, map to 'entity:' URI.
$entity_id = EntityAutocomplete::extractEntityIdFromAutocompleteInput($string);
if ($entity_id !== NULL) {
// @todo Support entity types other than 'node'. Will be fixed in
// https://www.drupal.org/node/2423093.
$uri = 'entity:node/' . $entity_id;
}
// Support linking to nothing.
elseif (in_array($string, ['<nolink>', '<none>', '<button>'], TRUE)) {
$uri = 'route:' . $string;
}
// Support linking to nothing.
elseif (in_array($string, array('<nolink>', '<none>'))) {
$uri = 'route:<nolink>';
}
// Detect a schemeless string, map to 'internal:' URI.
elseif (!empty($string) && parse_url($string, PHP_URL_SCHEME) === NULL) {
// @todo '<front>' is valid input for BC reasons, may be removed by
// https://www.drupal.org/node/2421941
// - '<front>' -> '/'
// - '<front>#foo' -> '/#foo'
if (strpos($string, '<front>') === 0) {
$string = '/' . substr($string, strlen('<front>'));
}
$uri = 'internal:' . $string;
}
return $uri;
}
/**
* Form element validation handler for the 'uri' element.
*
* Disallows saving inaccessible or untrusted URLs.
*/
public static function validateUriElement($element, FormStateInterface $form_state, $form) {
$uri = static::getUserEnteredStringAsUri($element['#value']);
$form_state->setValueForElement($element, $uri);
// If getUserEnteredStringAsUri() mapped the entered value to an 'internal:'
// URI , ensure the raw value begins with '/', '?' or '#'.
// @todo '<front>' is valid input for BC reasons, may be removed by
// https://www.drupal.org/node/2421941
if (parse_url($uri, PHP_URL_SCHEME) === 'internal' && !in_array($element['#value'][0], ['/', '?', '#'], TRUE) && substr($element['#value'], 0, 7) !== '<front>') {
$form_state->setError($element, new TranslatableMarkup('Manually entered paths should start with one of the following characters: / ? #'));
return;
}
}
/**
* Form element validation handler for the 'title' element.
*
* Conditionally requires the link title if a URL value was filled in.
*/
public static function validateTitleElement(&$element, FormStateInterface $form_state, $form) {
if ($element['uri']['#value'] !== '' && $element['title']['#value'] === '') {
// We expect the field name placeholder value to be wrapped in $this->t() here,
// so it won't be escaped again as it's already marked safe.
$form_state->setError($element['title'], new TranslatableMarkup('@title field is required if there is @uri input.', ['@title' => $element['title']['#title'], '@uri' => $element['uri']['#title']]));
}
}
/**
* Form element validation handler for the 'title' element.
*
* Requires the URL value if a link title was filled in.
*/
public static function validateTitleNoLink(&$element, FormStateInterface $form_state, $form) {
if ($element['uri']['#value'] === '' && $element['title']['#value'] !== '') {
$form_state->setError($element['uri'], new TranslatableMarkup('The @uri field is required when the @title field is specified.', ['@title' => $element['title']['#title'], '@uri' => $element['uri']['#title']]));
}
}
/**
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
/** @var \Drupal\link\LinkItemInterface $item */
$item = $items[$delta];
$element['uri'] = [
'#type' => 'url',
'#title' => $this->t('URL'),
'#placeholder' => $this->getSetting('placeholder_url'),
// The current field value could have been entered by a different user.
// However, if it is inaccessible to the current user, do not display it
// to them.
'#default_value' => (!$item->isEmpty() && (\Drupal::currentUser()->hasPermission('link to any page') || $item->getUrl()->access())) ? static::getUriAsDisplayableString($item->uri) : NULL,
'#element_validate' => [[static::class, 'validateUriElement']],
'#maxlength' => 2048,
'#required' => $element['#required'],
'#link_type' => $this->getFieldSetting('link_type'),
];
// If the field is configured to support internal links, it cannot use the
// 'url' form element and we have to do the validation ourselves.
if ($this->supportsInternalLinks()) {
$element['uri']['#type'] = 'entity_autocomplete';
// @todo The user should be able to select an entity type. Will be fixed
// in https://www.drupal.org/node/2423093.
$element['uri']['#target_type'] = 'node';
// Disable autocompletion when the first character is '/', '#' or '?'.
$element['uri']['#attributes']['data-autocomplete-first-character-blacklist'] = '/#?';
// The link widget is doing its own processing in
// static::getUriAsDisplayableString().
$element['uri']['#process_default_value'] = FALSE;
}
// If the field is configured to allow only internal links, add a useful
// element prefix and description.
if (!$this->supportsExternalLinks()) {
$element['uri']['#field_prefix'] = rtrim(Url::fromRoute('<front>', [], ['absolute' => TRUE])->toString(), '/');
$element['uri']['#description'] = $this->t('This must be an internal path such as %add-node. You can also start typing the title of a piece of content to select it. Enter %front to link to the front page. Enter %nolink to display link text only. Enter %button to display keyboard-accessible link text only.', ['%add-node' => '/node/add', '%front' => '<front>', '%nolink' => '<nolink>', '%button' => '<button>']);
}
// If the field is configured to allow both internal and external links,
// show a useful description.
elseif ($this->supportsExternalLinks() && $this->supportsInternalLinks()) {
$element['uri']['#description'] = $this->t('Start typing the title of a piece of content to select it. You can also enter an internal path such as %add-node or an external URL such as %url. Enter %front to link to the front page. Enter %nolink to display link text only. Enter %button to display keyboard-accessible link text only.', ['%front' => '<front>', '%add-node' => '/node/add', '%url' => 'http://example.com', '%nolink' => '<nolink>', '%button' => '<button>']);
}
// If the field is configured to allow only external links, show a useful
// description.
elseif ($this->supportsExternalLinks() && !$this->supportsInternalLinks()) {
$element['uri']['#description'] = $this->t('This must be an external URL such as %url.', ['%url' => 'http://example.com']);
}
// Make uri required on the front-end when title filled-in.
if (!$this->isDefaultValueWidget($form_state) && $this->getFieldSetting('title') !== DRUPAL_DISABLED && !$element['uri']['#required']) {
$parents = $element['#field_parents'];
$parents[] = $this->fieldDefinition->getName();
$selector = $root = array_shift($parents);
if ($parents) {
$selector = $root . '[' . implode('][', $parents) . ']';
}
$element['uri']['#states']['required'] = [
':input[name="' . $selector . '[' . $delta . '][title]"]' => ['filled' => TRUE],
];
}
$element['title'] = [
'#type' => 'textfield',
'#title' => $this->t('Link text'),
'#placeholder' => $this->getSetting('placeholder_title'),
'#default_value' => $items[$delta]->title ?? NULL,
'#maxlength' => 255,
'#access' => $this->getFieldSetting('title') != DRUPAL_DISABLED,
'#required' => $this->getFieldSetting('title') === DRUPAL_REQUIRED && $element['#required'],
];
// Post-process the title field to make it conditionally required if URL is
// non-empty. Omit the validation on the field edit form, since the field
// settings cannot be saved otherwise.
//
// Validate that title field is filled out (regardless of uri) when it is a
// required field.
if (!$this->isDefaultValueWidget($form_state) && $this->getFieldSetting('title') === DRUPAL_REQUIRED) {
$element['#element_validate'][] = [static::class, 'validateTitleElement'];
$element['#element_validate'][] = [static::class, 'validateTitleNoLink'];
if (!$element['title']['#required']) {
// Make title required on the front-end when URI filled-in.
$parents = $element['#field_parents'];
$parents[] = $this->fieldDefinition->getName();
$selector = $root = array_shift($parents);
if ($parents) {
$selector = $root . '[' . implode('][', $parents) . ']';
}
$element['title']['#states']['required'] = [
':input[name="' . $selector . '[' . $delta . '][uri]"]' => ['filled' => TRUE],
];
}
}
// Ensure that a URI is always entered when an optional title field is
// submitted.
if (!$this->isDefaultValueWidget($form_state) && $this->getFieldSetting('title') == DRUPAL_OPTIONAL) {
$element['#element_validate'][] = [static::class, 'validateTitleNoLink'];
}
// Exposing the attributes array in the widget is left for alternate and more
// advanced field widgets.
$element['attributes'] = [
'#type' => 'value',
'#tree' => TRUE,
'#value' => !empty($items[$delta]->options['attributes']) ? $items[$delta]->options['attributes'] : [],
'#attributes' => ['class' => ['link-field-widget-attributes']],
];
// If cardinality is 1, ensure a proper label is output for the field.
if ($this->fieldDefinition->getFieldStorageDefinition()->getCardinality() == 1) {
// If the link title is disabled, use the field definition label as the
// title of the 'uri' element.
if ($this->getFieldSetting('title') == DRUPAL_DISABLED) {
$element['uri']['#title'] = $element['#title'];
// By default the field description is added to the title field. Since
// the title field is disabled, we add the description, if given, to the
// uri element instead.
if (!empty($element['#description'])) {
if (empty($element['uri']['#description'])) {
$element['uri']['#description'] = $element['#description'];
}
else {
// If we have the description of the type of field together with
// the user provided description, we want to make a distinction
// between "core help text" and "user entered help text". To make
// this distinction more clear, we put them in an unordered list.
$element['uri']['#description'] = [
'#theme' => 'item_list',
'#items' => [
// Assume the user-specified description has the most relevance,
// so place it first.
$element['#description'],
$element['uri']['#description'],
],
];
}
}
}
// Otherwise wrap everything in a details element.
else {
$element += [
'#type' => 'fieldset',
];
}
}
return $element;
}
/**
* Indicates enabled support for link to routes.
*
* @return bool
* Returns TRUE if the LinkItem field is configured to support links to
* routes, otherwise FALSE.
*/
protected function supportsInternalLinks() {
$link_type = $this->getFieldSetting('link_type');
return (bool) ($link_type & LinkItemInterface::LINK_INTERNAL);
}
/**
* Indicates enabled support for link to external URLs.
*
* @return bool
* Returns TRUE if the LinkItem field is configured to support links to
* external URLs, otherwise FALSE.
*/
protected function supportsExternalLinks() {
$link_type = $this->getFieldSetting('link_type');
return (bool) ($link_type & LinkItemInterface::LINK_EXTERNAL);
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
$elements['placeholder_url'] = [
'#type' => 'textfield',
'#title' => $this->t('Placeholder for URL'),
'#default_value' => $this->getSetting('placeholder_url'),
'#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
];
$elements['placeholder_title'] = [
'#type' => 'textfield',
'#title' => $this->t('Placeholder for link text'),
'#default_value' => $this->getSetting('placeholder_title'),
'#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
'#states' => [
'invisible' => [
':input[name="instance[settings][title]"]' => ['value' => DRUPAL_DISABLED],
],
],
];
return $elements;
}
/**
* {@inheritdoc}
*/
public function settingsSummary() {
$summary = [];
$placeholder_title = $this->getSetting('placeholder_title');
$placeholder_url = $this->getSetting('placeholder_url');
if (empty($placeholder_title) && empty($placeholder_url)) {
$summary[] = $this->t('No placeholders');
}
else {
if (!empty($placeholder_title)) {
$summary[] = $this->t('Title placeholder: @placeholder_title', ['@placeholder_title' => $placeholder_title]);
}
if (!empty($placeholder_url)) {
$summary[] = $this->t('URL placeholder: @placeholder_url', ['@placeholder_url' => $placeholder_url]);
}
}
return $summary;
}
/**
* {@inheritdoc}
*/
public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
foreach ($values as &$value) {
$value['uri'] = static::getUserEnteredStringAsUri($value['uri']);
$value += ['options' => []];
}
return $values;
}
/**
* {@inheritdoc}
*
* Override the '%uri' message parameter, to ensure that 'internal:' URIs
* show a validation error message that doesn't mention that scheme.
*/
public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {
/** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
foreach ($violations as $offset => $violation) {
$parameters = $violation->getParameters();
if (isset($parameters['@uri'])) {
$parameters['@uri'] = static::getUriAsDisplayableString($parameters['@uri']);
$violations->set($offset, new ConstraintViolation(
$this->t($violation->getMessageTemplate(), $parameters),
$violation->getMessageTemplate(),
$parameters,
$violation->getRoot(),
$violation->getPropertyPath(),
$violation->getInvalidValue(),
$violation->getPlural(),
$violation->getCode()
));
}
}
parent::flagErrors($items, $violations, $form, $form_state);
}
}
--- modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
+++ modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
@@ -204,17 +211,17 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
// element prefix and description.
if (!$this->supportsExternalLinks()) {
$element['uri']['#field_prefix'] = rtrim(\Drupal::url('<front>', [], ['absolute' => TRUE]), '/');
- $element['uri']['#description'] = $this->t('This must be an internal path such as %add-node. You can also start typing the title of a piece of content to select it. Enter %front to link to the front page.', ['%add-node' => '/node/add', '%front' => '<front>']);
+ $element['uri']['#description'] = $this->t('This must be an internal path such as %add-node. You can also start typing the title of a piece of content to select it. Enter %front to link to the front page. Enter %nolink to display link text only.', ['%add-node' => '/node/add', '%front' => '<front>', '%nolink' => '<nolink>']);
}
// If the field is configured to allow both internal and external links,
// show a useful description.
elseif ($this->supportsExternalLinks() && $this->supportsInternalLinks()) {
- $element['uri']['#description'] = $this->t('Start typing the title of a piece of content to select it. You can also enter an internal path such as %add-node or an external URL such as %url. Enter %front to link to the front page.', ['%front' => '<front>', '%add-node' => '/node/add', '%url' => 'http://example.com']);
+ $element['uri']['#description'] = $this->t('Start typing the title of a piece of content to select it. You can also enter an internal path such as %add-node or an external URL such as %url. Enter %front to link to the front page. Enter %nolink to display link text only.', ['%front' => '<front>', '%add-node' => '/node/add', '%url' => 'http://example.com', '%nolink' => '<nolink>']);
}
// If the field is configured to allow only external links, show a useful
// description.
elseif ($this->supportsExternalLinks() && !$this->supportsInternalLinks()) {
- $element['uri']['#description'] = $this->t('This must be an external URL such as %url.', ['%url' => 'http://example.com']);
+ $element['uri']['#description'] = $this->t('This must be an external URL such as %url. Enter %nolink to display link text only.', ['%url' => 'http://example.com', '%nolink' => '<nolink>']);
}
$element['title'] = [
<?php
namespace Drupal\system\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\Core\Path\PathMatcherInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\path_alias\AliasManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Provides a 'Request Path' condition.
*
* @Condition(
* id = "request_path",
* label = @Translation("Request Path"),
* )
*/
class RequestPath extends ConditionPluginBase implements ContainerFactoryPluginInterface {
/**
* An alias manager to find the alias for the current system path.
*
* @var \Drupal\path_alias\AliasManagerInterface
*/
protected $aliasManager;
/**
* The path matcher.
*
* @var \Drupal\Core\Path\PathMatcherInterface
*/
protected $pathMatcher;
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* The current path.
*
* @var \Drupal\Core\Path\CurrentPathStack
*/
protected $currentPath;
/**
* Constructs a RequestPath condition plugin.
*
* @param \Drupal\path_alias\AliasManagerInterface $alias_manager
* An alias manager to find the alias for the current system path.
* @param \Drupal\Core\Path\PathMatcherInterface $path_matcher
* The path matcher service.
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
* @param \Drupal\Core\Path\CurrentPathStack $current_path
* The current path.
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param array $plugin_definition
* The plugin implementation definition.
*/
public function __construct(AliasManagerInterface $alias_manager, PathMatcherInterface $path_matcher, RequestStack $request_stack, CurrentPathStack $current_path, array $configuration, $plugin_id, array $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->aliasManager = $alias_manager;
$this->pathMatcher = $path_matcher;
$this->requestStack = $request_stack;
$this->currentPath = $current_path;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$container->get('path_alias.manager'),
$container->get('path.matcher'),
$container->get('request_stack'),
$container->get('path.current'),
$configuration,
$plugin_id,
$plugin_definition);
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return ['pages' => ''] + parent::defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['pages'] = [
'#type' => 'textarea',
'#title' => $this->t('Pages'),
'#default_value' => $this->configuration['pages'],
'#description' => $this->t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. An example path is %user-wildcard for every user page. %front is the front page.", [
'%user-wildcard' => '/user/*',
'%front' => '<front>',
]),
];
return parent::buildConfigurationForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['pages'] = $form_state->getValue('pages');
parent::submitConfigurationForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function summary() {
if (empty($this->configuration['pages'])) {
return $this->t('No page is specified');
}
$pages = array_map('trim', explode("\n", $this->configuration['pages']));
$pages = implode(', ', $pages);
if (!empty($this->configuration['negate'])) {
return $this->t('Do not return true on the following pages: @pages', ['@pages' => $pages]);
}
return $this->t('Return true on the following pages: @pages', ['@pages' => $pages]);
}
/**
* {@inheritdoc}
*/
public function evaluate() {
// Convert path to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$pages = $this->configuration['pages'] ? mb_strtolower($this->configuration['pages']) : '';
if (!$pages) {
return TRUE;
}
$request = $this->requestStack->getCurrentRequest();
// Compare the lowercase path alias (if any) and internal path.
$path = $this->currentPath->getPath($request);
// Do not trim a trailing slash if that is the complete path.
$path = $path === '/' ? $path : rtrim($path, '/');
$path_alias = mb_strtolower($this->aliasManager->getAliasByPath($path));
return $this->pathMatcher->matchPath($path_alias, $pages) || (($path != $path_alias) && $this->pathMatcher->matchPath($path, $pages));
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
$contexts = parent::getCacheContexts();
$contexts[] = 'url.path';
return $contexts;
}
}
<?php
/**
* @file
* Install, update and uninstall functions for the system module.
*/
use Drupal\Component\FileSystem\FileSystem as FileSystemComponent;
use Drupal\Component\Utility\Bytes;
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Environment;
use Drupal\Component\Utility\OpCodeCache;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Extension\ExtensionLifecycle;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Link;
use Drupal\Core\Utility\PhpRequirements;
use Drupal\Core\Render\Markup;
use Drupal\Core\Site\Settings;
use Drupal\Core\StreamWrapper\PrivateStream;
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
use GuzzleHttp\Exception\TransferException;
use Symfony\Component\HttpFoundation\Request;
// cspell:ignore quickedit
/**
* An array of machine names of modules that were removed from Drupal core.
*/
const DRUPAL_CORE_REMOVED_MODULE_LIST = [
'aggregator' => 'Aggregator',
'ckeditor' => 'CKEditor',
'color' => 'Color',
'hal' => 'HAL',
'quickedit' => 'Quick Edit',
'rdf' => 'RDF',
];
/**
* An array of machine names of themes that were removed from Drupal core.
*/
const DRUPAL_CORE_REMOVED_THEME_LIST = [
'bartik' => 'Bartik',
'classy' => 'Classy',
'seven' => 'Seven',
'stable' => 'Stable',
];
/**
* Implements hook_requirements().
*/
function system_requirements($phase) {
global $install_state;
// Get the current default PHP requirements for this version of Drupal.
$minimum_supported_php = PhpRequirements::getMinimumSupportedPhp();
// Reset the extension lists.
/** @var \Drupal\Core\Extension\ModuleExtensionList $module_extension_list */
$module_extension_list = \Drupal::service('extension.list.module');
$module_extension_list->reset();
/** @var \Drupal\Core\Extension\ThemeExtensionList $theme_extension_list */
$theme_extension_list = \Drupal::service('extension.list.theme');
$theme_extension_list->reset();
$requirements = [];
// Report Drupal version
if ($phase == 'runtime') {
$requirements['drupal'] = [
'title' => t('Drupal'),
'value' => \Drupal::VERSION,
'severity' => REQUIREMENT_INFO,
'weight' => -10,
];
// Display the currently active installation profile, if the site
// is not running the default installation profile.
$profile = \Drupal::installProfile();
if ($profile != 'standard') {
$info = $module_extension_list->getExtensionInfo($profile);
$requirements['install_profile'] = [
'title' => t('Installation profile'),
'value' => t('%profile_name (%profile-%version)', [
'%profile_name' => $info['name'],
'%profile' => $profile,
'%version' => $info['version'],
]),
'severity' => REQUIREMENT_INFO,
'weight' => -9,
];
}
// Gather all obsolete and experimental modules being enabled.
$obsolete_extensions = [];
$deprecated_modules = [];
$experimental_modules = [];
$enabled_modules = \Drupal::moduleHandler()->getModuleList();
foreach ($enabled_modules as $module => $data) {
$info = $module_extension_list->getExtensionInfo($module);
if (isset($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER])) {
if ($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::EXPERIMENTAL) {
$experimental_modules[$module] = $info['name'];
}
elseif ($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::DEPRECATED) {
$deprecated_modules[] = ['name' => $info['name'], 'lifecycle_link' => $info['lifecycle_link']];
}
elseif ($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::OBSOLETE) {
$obsolete_extensions[$module] = ['name' => $info['name'], 'lifecycle_link' => $info['lifecycle_link']];
}
}
}
// Warn if any experimental modules are installed.
if (!empty($experimental_modules)) {
$requirements['experimental_modules'] = [
'title' => t('Experimental modules enabled'),
'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 deprecated modules are installed.
if (!empty($deprecated_modules)) {
foreach ($deprecated_modules as $deprecated_module) {
$deprecated_modules_link_list[] = (string) Link::fromTextAndUrl($deprecated_module['name'], Url::fromUri($deprecated_module['lifecycle_link']))->toString();
}
$requirements['deprecated_modules'] = [
'title' => t('Deprecated modules enabled'),
'value' => t('Deprecated modules found: %module_list.', [
'%module_list' => Markup::create(implode(', ', $deprecated_modules_link_list)),
]),
'severity' => REQUIREMENT_WARNING,
];
}
// Gather all obsolete and experimental themes being enabled.
$experimental_themes = [];
$deprecated_themes = [];
$installed_themes = \Drupal::service('theme_handler')->listInfo();
foreach ($installed_themes as $theme => $data) {
$info = $theme_extension_list->getExtensionInfo($theme);
if (isset($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER])) {
if ($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::EXPERIMENTAL) {
$experimental_themes[$theme] = $info['name'];
}
elseif ($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::DEPRECATED) {
$deprecated_themes[] = ['name' => $info['name'], 'lifecycle_link' => $info['lifecycle_link']];
}
elseif ($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::OBSOLETE) {
$obsolete_extensions[$theme] = ['name' => $info['name'], 'lifecycle_link' => $info['lifecycle_link']];
}
}
// Currently, we check for both the key/value pairs 'experimental: true'
// and 'lifecycle: experimental' to determine if an extension is marked as
// experimental.
// @todo Remove the check for 'experimental: true' as part of
// https://www.drupal.org/node/3250342
if (isset($data->info['experimental']) && $data->info['experimental']) {
$experimental_themes[$theme] = $data->info['name'];
}
}
// Warn if any experimental themes are enabled.
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)]),
'severity' => REQUIREMENT_WARNING,
];
}
// Warn if any deprecated themes are enabled.
if (!empty($deprecated_themes)) {
foreach ($deprecated_themes as $deprecated_theme) {
$deprecated_themes_link_list[] = (string) Link::fromTextAndUrl($deprecated_theme['name'], Url::fromUri($deprecated_theme['lifecycle_link']))->toString();
}
$requirements['deprecated_themes'] = [
'title' => t('Deprecated themes enabled'),
'value' => t('Deprecated themes found: %theme_list.', [
'%theme_list' => Markup::create(implode(', ', $deprecated_themes_link_list)),
]),
'severity' => REQUIREMENT_WARNING,
];
}
// Warn if any obsolete extensions (themes or modules) are enabled.
if (!empty($obsolete_extensions)) {
foreach ($obsolete_extensions as $obsolete_extension) {
$obsolete_extensions_link_list[] = (string) Link::fromTextAndUrl($obsolete_extension['name'], Url::fromUri($obsolete_extension['lifecycle_link']))->toString();
}
$requirements['obsolete_extensions'] = [
'title' => t('Obsolete extensions enabled'),
'value' => t('Obsolete extensions found: %extensions. Obsolete extensions are provided only so that they can be uninstalled cleanly. You should immediately uninstall these extensions since they may be removed in a future release.', [
'%extensions' => Markup::create(implode(', ', $obsolete_extensions_link_list)),
]),
'severity' => REQUIREMENT_WARNING,
];
}
_system_advisories_requirements($requirements);
}
// Web server information.
$request_object = \Drupal::request();
$software = $request_object->server->get('SERVER_SOFTWARE');
$requirements['webserver'] = [
'title' => t('Web server'),
'value' => $software,
];
// Tests clean URL support.
if ($phase == 'install' && $install_state['interactive'] && !$request_object->query->has('rewrite') && strpos($software, 'Apache') !== FALSE) {
// 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;
}
elseif ($matches[1] == 2) {
if (!isset($matches[2])) {
$rewrite_warning = TRUE;
}
elseif ($matches[2] < 2) {
$rewrite_error = TRUE;
}
elseif ($matches[2] == 2) {
if (!isset($matches[3])) {
$rewrite_warning = TRUE;
}
elseif ($matches[3] < 16) {
$rewrite_error = TRUE;
}
}
}
}
else {
$rewrite_warning = TRUE;
}
if ($rewrite_warning) {
$requirements['apache_version'] = [
'title' => t('Apache version'),
'value' => $apache_version_string,
'severity' => REQUIREMENT_WARNING,
'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]),
];
}
if ($rewrite_error) {
$requirements['Apache version'] = [
'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' => 'https://www.drupal.org/docs/8/clean-urls-in-drupal-8']),
];
}
if (!$rewrite_error && !$rewrite_warning) {
$requirements['rewrite_module'] = [
'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' => 'https://www.drupal.org/docs/8/clean-urls-in-drupal-8']),
];
}
}
// 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.
$phpversion = $phpversion_label = phpversion();
if (function_exists('phpinfo')) {
if ($phase === 'runtime') {
$phpversion_label = t('@phpversion (<a href=":url">more information</a>)', ['@phpversion' => $phpversion, ':url' => (new Url('system.php'))->toString()]);
}
$requirements['php'] = [
'title' => t('PHP'),
'value' => $phpversion_label,
];
}
else {
// @todo Revisit whether this description makes sense in
// https://www.drupal.org/project/drupal/issues/2927318.
$requirements['php'] = [
'title' => t('PHP'),
'value' => $phpversion_label,
'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']),
'severity' => REQUIREMENT_INFO,
];
}
// Check if the PHP version is below what Drupal supports.
if (version_compare($phpversion, $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 PHP requirements</a> page for more information.',
[
'%version' => $minimum_supported_php,
'%recommended' => \Drupal::RECOMMENDED_PHP,
':php_requirements' => 'https://www.drupal.org/docs/system-requirements/php-requirements',
]
);
// If the PHP version is also below the absolute minimum allowed, it's not
// safe to continue with the requirements check, and should always be an
// error.
if (version_compare($phpversion, \Drupal::MINIMUM_PHP) < 0) {
$requirements['php']['severity'] = REQUIREMENT_ERROR;
return $requirements;
}
// Otherwise, the message should be an error at runtime, and a warning
// during installation or update.
$requirements['php']['severity'] = ($phase === 'runtime') ? REQUIREMENT_ERROR : REQUIREMENT_WARNING;
}
// 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 PHP requirements</a> page for more information.', ['%recommended' => \Drupal::RECOMMENDED_PHP, ':php_requirements' => 'https://www.drupal.org/docs/system-requirements/php-requirements']);
$requirements['php']['severity'] = REQUIREMENT_INFO;
// PHP 8.1.0 through 8.1.5 have a known OPcache bug that can cause fatal
// errors, so warn about that when running Drupal on those versions.
// @todo Remove this when \Drupal::MINIMUM_PHP is at least 8.1.6 in
// https://www.drupal.org/i/3305726.
if (version_compare(\Drupal::MINIMUM_PHP, '8.1.6') < 0) {
$requirements['php']['description'] = t('PHP %version has <a href=":bug_url">an OPcache bug that can cause fatal errors with class autoloading</a>. This can be fixed by upgrading to PHP 8.1.6 or later. See <a href="http://php.net/supported-versions.php">PHP\'s version support documentation</a> and the <a href=":php_requirements">Drupal PHP requirements</a> page for more information.', [
'%version' => $phpversion,
':bug_url' => 'https://github.com/php/php-src/issues/8164',
':php_requirements' => 'https://www.drupal.org/docs/system-requirements/php-requirements',
]);
$requirements['php']['severity'] = REQUIREMENT_WARNING;
}
}
// Test for PHP extensions.
$requirements['php_extensions'] = [
'title' => t('PHP extensions'),
];
$missing_extensions = [];
$required_extensions = [
'date',
'dom',
'filter',
'gd',
'hash',
'json',
'pcre',
'pdo',
'session',
'SimpleXML',
'SPL',
'tokenizer',
'xml',
];
foreach ($required_extensions as $extension) {
if (!extension_loaded($extension)) {
$missing_extensions[] = $extension;
}
}
if (!empty($missing_extensions)) {
$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):', [
':system_requirements' => 'https://www.drupal.org/docs/system-requirements',
]);
// We use twig inline_template to avoid twig's autoescape.
$description = [
'#type' => 'inline_template',
'#template' => '{{ description }}{{ missing_extensions }}',
'#context' => [
'description' => $description,
'missing_extensions' => [
'#theme' => 'item_list',
'#items' => $missing_extensions,
],
],
];
$requirements['php_extensions']['value'] = t('Disabled');
$requirements['php_extensions']['severity'] = REQUIREMENT_ERROR;
$requirements['php_extensions']['description'] = $description;
}
else {
$requirements['php_extensions']['value'] = t('Enabled');
}
if ($phase == 'install' || $phase == 'runtime') {
// Check to see if OPcache is installed.
if (!OpCodeCache::isEnabled()) {
$requirements['php_opcache'] = [
'value' => t('Not enabled'),
'severity' => REQUIREMENT_WARNING,
'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.'),
];
}
else {
$requirements['php_opcache']['value'] = t('Enabled');
}
$requirements['php_opcache']['title'] = t('PHP OPcode caching');
}
// Check to see if APCu is installed and configured correctly.
if ($phase == 'runtime' && PHP_SAPI != 'cli') {
$requirements['php_apcu']['title'] = t('PHP APCu caching');
if (extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) {
$memory_info = apcu_sma_info(TRUE);
$apcu_actual_size = format_size($memory_info['seg_size']);
$apcu_recommended_size = '32 MB';
$requirements['php_apcu']['value'] = t('Enabled (@size)', ['@size' => $apcu_actual_size]);
if (Bytes::toNumber($apcu_actual_size) < Bytes::toNumber($apcu_recommended_size)) {
$requirements['php_apcu']['severity'] = REQUIREMENT_WARNING;
$requirements['php_apcu']['description'] = t('Depending on your configuration, Drupal can run with a @apcu_size APCu limit. However, a @apcu_default_size APCu limit (the default) or above is recommended, especially if your site uses additional custom or contributed modules.', [
'@apcu_size' => $apcu_actual_size,
'@apcu_default_size' => $apcu_recommended_size,
]);
}
else {
$memory_available = $memory_info['avail_mem'] / $memory_info['seg_size'];
if ($memory_available < 0.1) {
$requirements['php_apcu']['severity'] = REQUIREMENT_ERROR;
}
elseif ($memory_available < 0.25) {
$requirements['php_apcu']['severity'] = REQUIREMENT_WARNING;
}
else {
$requirements['php_apcu']['severity'] = REQUIREMENT_OK;
}
$requirements['php_apcu']['description'] = t('Memory available: @available.', [
'@available' => format_size($memory_info['avail_mem']),
]);
}
}
else {
$requirements['php_apcu'] += [
'value' => t('Not enabled'),
'severity' => REQUIREMENT_INFO,
'description' => t('PHP APCu caching can improve your site\'s performance considerably. It is <strong>highly recommended</strong> to have <a href="https://www.php.net/manual/apcu.installation.php" target="_blank">APCu</a> installed on your server.'),
];
}
}
if ($phase != 'update') {
// Test whether we have a good source of random bytes.
$requirements['php_random_bytes'] = [
'title' => t('Random number generation'),
];
try {
$bytes = random_bytes(10);
if (strlen($bytes) != 10) {
throw new \Exception("Tried to generate 10 random bytes, generated '" . strlen($bytes) . "'");
}
$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);
$open_basedir_blocks_urandom = !array_intersect(['/dev', '/dev/', '/dev/urandom'], $open_basedir_paths);
}
}
$args = [
':drupal-php' => 'https://www.drupal.org/docs/system-requirements/php-requirements',
'%exception_message' => $e->getMessage(),
];
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;
}
}
if ($phase == 'install' || $phase == 'update') {
// Test for PDO (database).
$requirements['database_extensions'] = [
'title' => t('Database support'),
];
// Make sure PDO is available.
$database_ok = extension_loaded('pdo');
if (!$database_ok) {
$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.', [
':link' => 'https://www.drupal.org/docs/system-requirements/php-requirements#database',
]);
}
else {
// Make sure at least one supported database driver exists.
$drivers = drupal_detect_database_types();
if (empty($drivers)) {
$database_ok = FALSE;
$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>.', [
':drupal-databases' => 'https://www.drupal.org/docs/system-requirements/database-server-requirements',
]);
}
// 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;
$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.', [
':link' => 'https://www.drupal.org/docs/system-requirements/php-requirements#database',
]);
}
}
if (!$database_ok) {
$requirements['database_extensions']['value'] = t('Disabled');
$requirements['database_extensions']['severity'] = REQUIREMENT_ERROR;
$requirements['database_extensions']['description'] = $pdo_message;
}
else {
$requirements['database_extensions']['value'] = t('Enabled');
}
}
if ($phase === 'runtime' || $phase === 'update') {
// Database information.
$class = Database::getConnection()->getDriverClass('Install\\Tasks');
/** @var \Drupal\Core\Database\Install\Tasks $tasks */
$tasks = new $class();
$requirements['database_system'] = [
'title' => t('Database system'),
'value' => $tasks->name(),
];
$requirements['database_system_version'] = [
'title' => t('Database system version'),
'value' => Database::getConnection()->version(),
];
$errors = $tasks->engineVersionRequirementsCheck();
$error_count = count($errors);
if ($error_count > 0) {
$error_message = [
'#theme' => 'item_list',
'#items' => $errors,
// Use the comma-list style to display a single error without bullets.
'#context' => ['list_style' => $error_count === 1 ? 'comma-list' : ''],
];
$requirements['database_system_version']['severity'] = REQUIREMENT_ERROR;
$requirements['database_system_version']['description'] = $error_message;
}
}
// Test with PostgreSQL databases for the status of the pg_trgm extension.
if ($phase === 'runtime' || $phase === 'update') {
if (Database::isActiveConnection()) {
$connection = Database::getConnection();
// Set the requirement just for postgres.
if ($connection->driver() == 'pgsql') {
$requirements['pgsql_extension_pg_trgm'] = [
'severity' => REQUIREMENT_OK,
'title' => t('PostgreSQL pg_trgm extension'),
'value' => t('Available'),
'description' => 'The pg_trgm PostgreSQL extension is present.',
];
// If the extension is not available, set the requirement error.
if (!$connection->schema()->extensionExists('pg_trgm')) {
$requirements['pgsql_extension_pg_trgm']['severity'] = REQUIREMENT_ERROR;
$requirements['pgsql_extension_pg_trgm']['value'] = t('Not created');
$requirements['pgsql_extension_pg_trgm']['description'] = t('The <a href=":pg_trgm">pg_trgm</a> PostgreSQL extension is not present. The extension is required by Drupal 10 to improve performance when using PostgreSQL. See <a href=":requirements">Drupal database server requirements</a> for more information.', [
':pg_trgm' => 'https://www.postgresql.org/docs/current/pgtrgm.html',
':requirements' => 'https://www.drupal.org/docs/system-requirements/database-server-requirements',
]);
}
}
}
}
if ($phase === 'runtime' || $phase === 'update') {
// Test database JSON support.
$requirements['database_support_json'] = [
'title' => t('Database support for JSON'),
'severity' => REQUIREMENT_OK,
'value' => t('Available'),
'description' => t('Is required in Drupal 10.0.'),
];
if (!Database::getConnection()->hasJson()) {
$requirements['database_support_json']['value'] = t('Not available');
$requirements['database_support_json']['severity'] = REQUIREMENT_ERROR;
}
}
// Test PHP memory_limit
$memory_limit = ini_get('memory_limit');
$requirements['php_memory_limit'] = [
'title' => t('PHP memory limit'),
'value' => $memory_limit == -1 ? t('-1 (Unlimited)') : $memory_limit,
];
if (!Environment::checkMemoryLimit(\Drupal::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]);
}
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]);
}
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]);
}
if (!empty($description['phase'])) {
if ($php_ini_path = get_cfg_var('cfg_file_path')) {
$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]);
}
else {
$description['memory'] = t('Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.');
}
$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']);
$description = [
'#type' => 'inline_template',
'#template' => '{{ description_phase }} {{ description_memory }} {{ handbook }}',
'#context' => [
'description_phase' => $description['phase'],
'description_memory' => $description['memory'],
'handbook' => $handbook_link,
],
];
$requirements['php_memory_limit']['description'] = $description;
$requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING;
}
}
// Test configuration files and directory for writability.
if ($phase == 'runtime') {
$conf_errors = [];
// 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::getContainer()->getParameter('site.path');
}
else {
$site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
}
// 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')) {
$error_value = t('Protection disabled');
// 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 {
$error_value = t('Not protected');
// 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')) {
$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]);
}
}
foreach (['settings.php', 'settings.local.php', 'services.yml'] as $conf_file) {
$full_path = $site_path . '/' . $conf_file;
if (file_exists($full_path) && !drupal_verify_install_file($full_path, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE, 'file', !Settings::get('skip_permissions_hardening'))) {
$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]);
}
}
if (!empty($conf_errors)) {
if (count($conf_errors) == 1) {
$description = $conf_errors[0];
}
else {
// We use twig inline_template to avoid double escaping.
$description = [
'#type' => 'inline_template',
'#template' => '{{ configuration_error_list }}',
'#context' => [
'configuration_error_list' => [
'#theme' => 'item_list',
'#items' => $conf_errors,
],
],
];
}
$requirements['configuration_files'] = [
'value' => $error_value,
'severity' => $file_protection_severity,
'description' => $description,
];
}
else {
$requirements['configuration_files'] = [
'value' => t('Protected'),
];
}
$requirements['configuration_files']['title'] = t('Configuration files');
}
// 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.
/** @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';
// 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) {
$url = 'https://www.drupal.org/SA-CORE-2013-003';
$requirements[$htaccess_file] = [
'title' => new TranslatableMarkup($protected_dir->getTitle()),
'value' => t('Not fully protected'),
'severity' => REQUIREMENT_ERROR,
'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()]),
];
}
}
}
// Report cron status.
if ($phase == 'runtime') {
$cron_config = \Drupal::config('system.cron');
// Cron warning threshold defaults to two days.
$threshold_warning = $cron_config->get('threshold.requirements_warning');
// Cron error threshold defaults to two weeks.
$threshold_error = $cron_config->get('threshold.requirements_error');
// Determine when cron last ran.
$cron_last = \Drupal::state()->get('system.cron_last');
if (!is_numeric($cron_last)) {
$cron_last = \Drupal::state()->get('install_time', 0);
}
// Determine severity based on time since cron last ran.
$severity = REQUIREMENT_INFO;
$request_time = \Drupal::time()->getRequestTime();
if ($request_time - $cron_last > $threshold_error) {
$severity = REQUIREMENT_ERROR;
}
elseif ($request_time - $cron_last > $threshold_warning) {
$severity = REQUIREMENT_WARNING;
}
// Set summary and description based on values determined above.
$summary = t('Last run @time ago', ['@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)]);
$requirements['cron'] = [
'title' => t('Cron maintenance tasks'),
'severity' => $severity,
'value' => $summary,
];
if ($severity != REQUIREMENT_INFO) {
$requirements['cron']['description'][] = [
[
'#markup' => t('Cron has not run recently.'),
'#suffix' => ' ',
],
[
'#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']),
'#suffix' => ' ',
],
];
}
$requirements['cron']['description'][] = [
[
'#type' => 'link',
'#prefix' => '(',
'#title' => t('more information'),
'#suffix' => ')',
'#url' => Url::fromRoute('system.cron_settings'),
],
[
'#prefix' => '<span class="cron-description__run-cron">',
'#suffix' => '</span>',
'#type' => 'link',
'#title' => t('Run cron'),
'#url' => Url::fromRoute('system.run_cron'),
],
];
}
if ($phase != 'install') {
$directories = [
PublicStream::basePath(),
// By default no private files directory is configured. For private files
// to be secure the admin needs to provide a path outside the webroot.
PrivateStream::basePath(),
\Drupal::service('file_system')->getTempDirectory(),
];
}
// During an install we need to make assumptions about the file system
// unless overrides are provided in settings.php.
if ($phase == 'install') {
$directories = [];
if ($file_public_path = Settings::get('file_public_path')) {
$directories[] = $file_public_path;
}
else {
// If we are installing Drupal, the settings.php file might not exist yet
// in the intended site directory, so don't require it.
$request = Request::createFromGlobals();
$site_path = DrupalKernel::findSitePath($request);
$directories[] = $site_path . '/files';
}
if ($file_private_path = Settings::get('file_private_path')) {
$directories[] = $file_private_path;
}
if (Settings::get('file_temp_path')) {
$directories[] = Settings::get('file_temp_path');
}
else {
// If the temporary directory is not overridden use an appropriate
// temporary path for the system.
$directories[] = FileSystemComponent::getOsTemporaryDirectory();
}
}
// 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.
$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']);
}
else {
$description = t('The directory %directory does not exist.', ['%directory' => $config_sync_directory]);
}
$requirements['config sync directory'] = [
'title' => t('Configuration sync directory'),
'description' => $description,
'severity' => REQUIREMENT_ERROR,
];
}
}
if ($phase != 'install' && empty($config_sync_directory)) {
$requirements['config sync directory'] = [
'title' => t('Configuration sync directory'),
'value' => t('Not present'),
'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']"]),
'severity' => REQUIREMENT_ERROR,
];
}
$requirements['file system'] = [
'title' => t('File system'),
];
$error = '';
// For installer, create the directories if possible.
foreach ($directories as $directory) {
if (!$directory) {
continue;
}
if ($phase == 'install') {
\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
}
$is_writable = is_writable($directory);
$is_directory = is_dir($directory);
if (!$is_writable || !$is_directory) {
$description = '';
$requirements['file system']['value'] = t('Not writable');
if (!$is_directory) {
$error = t('The directory %directory does not exist.', ['%directory' => $directory]);
}
else {
$error = t('The directory %directory is not writable.', ['%directory' => $directory]);
}
// 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' => Url::fromRoute('system.file_system_settings')->toString()]);
}
elseif ($phase == 'install') {
// For the installer UI, we need different wording. 'value' will
// be treated as version, so provide none there.
$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']);
$requirements['file system']['value'] = '';
}
if (!empty($description)) {
$description = [
'#type' => 'inline_template',
'#template' => '{{ error }} {{ description }}',
'#context' => [
'error' => $error,
'description' => $description,
],
];
$requirements['file system']['description'] = $description;
$requirements['file system']['severity'] = REQUIREMENT_ERROR;
}
}
else {
// This function can be called before the config_cache table has been
// created.
if ($phase == 'install' || \Drupal::config('system.file')->get('default_scheme') == 'public') {
$requirements['file system']['value'] = t('Writable (<em>public</em> download method)');
}
else {
$requirements['file system']['value'] = t('Writable (<em>private</em> download method)');
}
}
}
// See if updates are available in update.php.
if ($phase == 'runtime') {
$requirements['update'] = [
'title' => t('Database updates'),
'value' => t('Up to date'),
];
// Check installed modules.
$has_pending_updates = FALSE;
/** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
$update_registry = \Drupal::service('update.update_hook_registry');
foreach (\Drupal::moduleHandler()->getModuleList() as $module => $filename) {
$updates = $update_registry->getAvailableUpdates($module);
if ($updates) {
$default = $update_registry->getInstalledVersion($module);
if (max($updates) > $default) {
$has_pending_updates = TRUE;
break;
}
}
}
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');
$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'] = [
'title' => t('Entity/field definitions'),
'value' => t('Up to date'),
];
// Verify that no entity updates are pending.
if ($change_list = \Drupal::entityDefinitionUpdateManager()->getChangeSummary()) {
$build = [];
foreach ($change_list as $entity_type_id => $changes) {
$entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
$build[] = [
'#theme' => 'item_list',
'#title' => $entity_type->getLabel(),
'#items' => $changes,
];
}
$entity_update_issues = \Drupal::service('renderer')->renderPlain($build);
$requirements['entity_update']['severity'] = REQUIREMENT_ERROR;
$requirements['entity_update']['value'] = t('Mismatched entity and/or field definitions');
$requirements['entity_update']['description'] = t('The following changes were detected in the entity type and field definitions. @updates', ['@updates' => $entity_update_issues]);
}
}
// Verify the update.php access setting
if ($phase == 'runtime') {
if (Settings::get('update_free_access')) {
$requirements['update access'] = [
'value' => t('Not protected'),
'severity' => REQUIREMENT_ERROR,
'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\']']),
];
}
else {
$requirements['update access'] = [
'value' => t('Protected'),
];
}
$requirements['update access']['title'] = t('Access to update.php');
}
// Display an error if a newly introduced dependency in a module is not resolved.
if ($phase === 'update' || $phase === 'runtime') {
$create_extension_incompatibility_list = function (array $extension_names, PluralTranslatableMarkup $description, PluralTranslatableMarkup $title, TranslatableMarkup|string $message = '', TranslatableMarkup|string $additional_description = '') {
if ($message === '') {
$message = new TranslatableMarkup('Review the <a href=":url"> suggestions for resolving this incompatibility</a> to repair your installation, and then re-run update.php.', [':url' => 'https://www.drupal.org/docs/updating-drupal/troubleshooting-database-updates']);
}
// Use an inline twig template to:
// - Concatenate MarkupInterface objects and preserve safeness.
// - Use the item_list theme for the extension list.
$template = [
'#type' => 'inline_template',
'#template' => '{{ description }}{{ extensions }}{{ additional_description }}<br>',
'#context' => [
'extensions' => [
'#theme' => 'item_list',
],
],
];
$template['#context']['extensions']['#items'] = $extension_names;
$template['#context']['description'] = $description;
$template['#context']['additional_description'] = $additional_description;
return [
'title' => $title,
'value' => [
'list' => $template,
'handbook_link' => [
'#markup' => $message,
],
],
'severity' => REQUIREMENT_ERROR,
];
};
$profile = \Drupal::installProfile();
$files = $module_extension_list->getList();
$files += $theme_extension_list->getList();
$core_incompatible_extensions = [];
$php_incompatible_extensions = [];
foreach ($files as $extension_name => $file) {
// Ignore uninstalled extensions and installation profiles.
if (!$file->status || $extension_name == $profile) {
continue;
}
$name = $file->info['name'];
if (!empty($file->info['core_incompatible'])) {
$core_incompatible_extensions[$file->info['type']][] = $name;
}
// Check the extension's PHP version.
$php = $file->info['php'];
if (version_compare($php, PHP_VERSION, '>')) {
$php_incompatible_extensions[$file->info['type']][] = $name;
}
// Check the module's required modules.
/** @var \Drupal\Core\Extension\Dependency $requirement */
foreach ($file->requires as $requirement) {
$required_module = $requirement->getName();
// Check if the module exists.
if (!isset($files[$required_module])) {
$requirements["$extension_name-$required_module"] = [
'title' => t('Unresolved dependency'),
'description' => t('@name requires this module.', ['@name' => $name]),
'value' => t('@required_name (Missing)', ['@required_name' => $required_module]),
'severity' => REQUIREMENT_ERROR,
];
continue;
}
// Check for an incompatible version.
$required_file = $files[$required_module];
$required_name = $required_file->info['name'];
$version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $required_file->info['version'] ?? '');
if (!$requirement->isCompatible($version)) {
$requirements["$extension_name-$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' => $requirement->getConstraintString()]),
'severity' => REQUIREMENT_ERROR,
];
continue;
}
}
}
if (!empty($core_incompatible_extensions['module'])) {
$requirements['module_core_incompatible'] = $create_extension_incompatibility_list(
$core_incompatible_extensions['module'],
new PluralTranslatableMarkup(
count($core_incompatible_extensions['module']),
'The following module is installed, but it is incompatible with Drupal @version:',
'The following modules are installed, but they are incompatible with Drupal @version:',
['@version' => \Drupal::VERSION]
),
new PluralTranslatableMarkup(
count($core_incompatible_extensions['module']),
'Incompatible module',
'Incompatible modules'
)
);
}
if (!empty($core_incompatible_extensions['theme'])) {
$requirements['theme_core_incompatible'] = $create_extension_incompatibility_list(
$core_incompatible_extensions['theme'],
new PluralTranslatableMarkup(
count($core_incompatible_extensions['theme']),
'The following theme is installed, but it is incompatible with Drupal @version:',
'The following themes are installed, but they are incompatible with Drupal @version:',
['@version' => \Drupal::VERSION]
),
new PluralTranslatableMarkup(
count($core_incompatible_extensions['theme']),
'Incompatible theme',
'Incompatible themes'
)
);
}
if (!empty($php_incompatible_extensions['module'])) {
$requirements['module_php_incompatible'] = $create_extension_incompatibility_list(
$php_incompatible_extensions['module'],
new PluralTranslatableMarkup(
count($php_incompatible_extensions['module']),
'The following module is installed, but it is incompatible with PHP @version:',
'The following modules are installed, but they are incompatible with PHP @version:',
['@version' => phpversion()]
),
new PluralTranslatableMarkup(
count($php_incompatible_extensions['module']),
'Incompatible module',
'Incompatible modules'
)
);
}
if (!empty($php_incompatible_extensions['theme'])) {
$requirements['theme_php_incompatible'] = $create_extension_incompatibility_list(
$php_incompatible_extensions['theme'],
new PluralTranslatableMarkup(
count($php_incompatible_extensions['theme']),
'The following theme is installed, but it is incompatible with PHP @version:',
'The following themes are installed, but they are incompatible with PHP @version:',
['@version' => phpversion()]
),
new PluralTranslatableMarkup(
count($php_incompatible_extensions['theme']),
'Incompatible theme',
'Incompatible themes'
)
);
}
$extension_config = \Drupal::configFactory()->get('core.extension');
// Look for removed core modules.
$is_removed_module = function ($extension_name) use ($module_extension_list) {
return !$module_extension_list->exists($extension_name)
&& array_key_exists($extension_name, DRUPAL_CORE_REMOVED_MODULE_LIST);
};
$removed_modules = array_filter(array_keys($extension_config->get('module')), $is_removed_module);
if (!empty($removed_modules)) {
$list = [];
foreach ($removed_modules as $removed_module) {
$list[] = t('<a href=":url">@module</a>', [
':url' => "https://www.drupal.org/project/$removed_module",
'@module' => DRUPAL_CORE_REMOVED_MODULE_LIST[$removed_module],
]);
}
$requirements['removed_module'] = $create_extension_incompatibility_list(
$list,
new PluralTranslatableMarkup(
count($removed_modules),
'You must add the following contributed module and reload this page.',
'You must add the following contributed modules and reload this page.'
),
new PluralTranslatableMarkup(
count($removed_modules),
'Removed core module',
'Removed core modules'
),
new TranslatableMarkup(
'For more information read the <a href=":url">documentation on deprecated modules.</a>',
[':url' => 'https://www.drupal.org/node/3223395#s-recommendations-for-deprecated-modules']
),
new PluralTranslatableMarkup(
count($removed_modules),
'This module is installed on your site but is no longer provided by Core.',
'These modules are installed on your site but are no longer provided by Core.'
),
);
}
// Look for removed core themes.
$is_removed_theme = function ($extension_name) use ($theme_extension_list) {
return !$theme_extension_list->exists($extension_name)
&& array_key_exists($extension_name, DRUPAL_CORE_REMOVED_THEME_LIST);
};
$removed_themes = array_filter(array_keys($extension_config->get('theme')), $is_removed_theme);
if (!empty($removed_themes)) {
$list = [];
foreach ($removed_themes as $removed_theme) {
$list[] = t('<a href=":url">@theme</a>', [
':url' => "https://www.drupal.org/project/$removed_theme",
'@theme' => DRUPAL_CORE_REMOVED_THEME_LIST[$removed_theme],
]);
}
$requirements['removed_theme'] = $create_extension_incompatibility_list(
$list,
new PluralTranslatableMarkup(
count($removed_themes),
'You must add the following contributed theme and reload this page.',
'You must add the following contributed themes and reload this page.'
),
new PluralTranslatableMarkup(
count($removed_themes),
'Removed core theme',
'Removed core themes'
),
new TranslatableMarkup(
'For more information read the <a href=":url">documentation on deprecated themes.</a>',
[':url' => 'https://www.drupal.org/node/3223395#s-recommendations-for-deprecated-themes']
),
new PluralTranslatableMarkup(
count($removed_themes),
'This theme is installed on your site but is no longer provided by Core.',
'These themes are installed on your site but are no longer provided by Core.'
),
);
}
// Look for missing modules.
$is_missing_module = function ($extension_name) use ($module_extension_list) {
return !$module_extension_list->exists($extension_name) && !in_array($extension_name, array_keys(DRUPAL_CORE_REMOVED_MODULE_LIST), TRUE);
};
$invalid_modules = array_filter(array_keys($extension_config->get('module')), $is_missing_module);
if (!empty($invalid_modules)) {
$requirements['invalid_module'] = $create_extension_incompatibility_list(
$invalid_modules,
new PluralTranslatableMarkup(
count($invalid_modules),
'The following module is marked as installed in the core.extension configuration, but it is missing:',
'The following modules are marked as installed in the core.extension configuration, but they are missing:'
),
new PluralTranslatableMarkup(
count($invalid_modules),
'Missing or invalid module',
'Missing or invalid modules'
)
);
}
// Look for invalid themes.
$is_missing_theme = function ($extension_name) use (&$theme_extension_list) {
return !$theme_extension_list->exists($extension_name) && !in_array($extension_name, array_keys(DRUPAL_CORE_REMOVED_THEME_LIST), TRUE);
};
$invalid_themes = array_filter(array_keys($extension_config->get('theme')), $is_missing_theme);
if (!empty($invalid_themes)) {
$requirements['invalid_theme'] = $create_extension_incompatibility_list(
$invalid_themes,
new PluralTranslatableMarkup(
count($invalid_themes),
'The following theme is marked as installed in the core.extension configuration, but it is missing:',
'The following themes are marked as installed in the core.extension configuration, but they are missing:'
),
new PluralTranslatableMarkup(
count($invalid_themes),
'Missing or invalid theme',
'Missing or invalid themes'
)
);
}
}
// 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.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;
}
if ($phase == 'runtime') {
// Check for update status module.
$requirements['update status'] = [
'value' => t('Enabled'),
];
$requirements['update status']['title'] = t('Update notifications');
if (Settings::get('rebuild_access')) {
$requirements['rebuild access'] = [
'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.'),
];
}
}
// 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)) {
$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/docs/installing-drupal/trusted-host-settings']),
'severity' => REQUIREMENT_ERROR,
];
}
else {
$requirements['trusted_host_patterns'] = [
'title' => t('Trusted Host Settings'),
'value' => t('Enabled'),
'description' => t('The trusted_host_patterns setting is set to allow %trusted_host_patterns', ['%trusted_host_patterns' => implode(', ', $trusted_host_patterns)]),
];
}
}
// When the database driver is provided by a module, then check that the
// providing module is enabled.
if ($phase === 'runtime' || $phase === 'update') {
$connection = Database::getConnection();
$provider = $connection->getProvider();
if ($provider !== 'core' && !\Drupal::moduleHandler()->moduleExists($provider)) {
$autoload = $connection->getConnectionOptions()['autoload'] ?? '';
if (strpos($autoload, 'src/Driver/Database/') !== FALSE) {
$post_update_registry = \Drupal::service('update.post_update_registry');
$pending_updates = $post_update_registry->getPendingUpdateInformation();
if (!in_array('enable_provider_database_driver', array_keys($pending_updates['system']['pending'] ?? []), TRUE)) {
// Only show the warning when the post update function has run and
// the module that is providing the database driver is not enabled.
$requirements['database_driver_provided_by_module'] = [
'title' => t('Database driver provided by module'),
'value' => t('Not enabled'),
'description' => t('The current database driver is provided by the module: %module. The module is currently not enabled. You should immediately <a href=":enable">enable</a> the module.', ['%module' => $provider, ':enable' => Url::fromRoute('system.modules_list')->toString()]),
'severity' => REQUIREMENT_ERROR,
];
}
}
}
}
// 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,
];
}
}
// 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,
];
}
}
// 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/system-requirements/limitations-of-32-bit-php']),
'severity' => REQUIREMENT_WARNING,
];
}
// 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,
];
}
}
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 9 no longer uses the \$settings['install_profile'] value in settings.php and it should be removed."),
'severity' => REQUIREMENT_WARNING,
];
}
}
// Ensure that no module has a current schema version that is lower than the
// one that was last removed.
if ($phase == 'update') {
$module_handler = \Drupal::moduleHandler();
/** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
$update_registry = \Drupal::service('update.update_hook_registry');
$module_list = [];
$module_handler->invokeAllWith(
'update_last_removed',
function (callable $hook, string $module) use (&$module_list, $update_registry, $module_extension_list) {
$last_removed = $hook();
if ($last_removed && $last_removed > $update_registry->getInstalledVersion($module)) {
/** @var \Drupal\Core\Extension\Extension $module_info */
$module_info = $module_extension_list->get($module);
$module_list[$module] = [
'name' => $module_info->info['name'],
'last_removed' => $last_removed,
'installed_version' => $update_registry->getInstalledVersion($module),
];
}
}
);
// If user module is in the list then only show a specific message for
// Drupal core.
if (isset($module_list['user'])) {
$requirements['user_update_last_removed'] = [
'title' => t('The version of Drupal you are trying to update from is too old'),
'description' => t('Updating to Drupal @current_major is only supported from Drupal version @required_min_version or higher. If you are trying to update from an older version, first update to the latest version of Drupal @previous_major. (<a href=":url">Drupal upgrade guide</a>)', [
'@current_major' => 10,
'@required_min_version' => '9.4.0',
'@previous_major' => 9,
':url' => 'https://www.drupal.org/docs/upgrading-drupal/drupal-8-and-higher',
]),
'severity' => REQUIREMENT_ERROR,
];
}
else {
foreach ($module_list as $module => $data) {
$requirements[$module . '_update_last_removed'] = [
'title' => t('Unsupported schema version: @module', ['@module' => $data['name']]),
'description' => t('The installed version of the %module module is too old to update. Update to an intermediate version first (last removed version: @last_removed_version, installed version: @installed_version).', [
'%module' => $data['name'],
'@last_removed_version' => $data['last_removed'],
'@installed_version' => $data['installed_version'],
]),
'severity' => REQUIREMENT_ERROR,
];
}
}
// Also check post-updates. Only do this if we're not already showing an
// error for hook_update_N().
if (empty($module_list)) {
$existing_updates = \Drupal::service('keyvalue')->get('post_update')->get('existing_updates', []);
$post_update_registry = \Drupal::service('update.post_update_registry');
$modules = \Drupal::moduleHandler()->getModuleList();
foreach ($modules as $module => $extension) {
$module_info = $module_extension_list->get($module);
$removed_post_updates = $post_update_registry->getRemovedPostUpdates($module);
if ($missing_updates = array_diff(array_keys($removed_post_updates), $existing_updates)) {
$versions = array_unique(array_intersect_key($removed_post_updates, array_flip($missing_updates)));
$description = new PluralTranslatableMarkup(count($versions),
'The installed version of the %module module is too old to update. Update to a version prior to @versions first (missing updates: @missing_updates).',
'The installed version of the %module module is too old to update. Update first to a version prior to all of the following: @versions (missing updates: @missing_updates).',
[
'%module' => $module_info->info['name'],
'@missing_updates' => implode(', ', $missing_updates),
'@versions' => implode(', ', $versions),
]
);
$requirements[$module . '_post_update_removed'] = [
'title' => t('Missing updates for: @module', ['@module' => $module_info->info['name']]),
'description' => $description,
'severity' => REQUIREMENT_ERROR,
];
}
}
}
}
return $requirements;
}
/**
* Implements hook_install().
*/
function system_install() {
// Populate the cron key state variable.
$cron_key = Crypt::randomBytesBase64(55);
\Drupal::state()->set('system.cron_key', $cron_key);
// 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');
}
$site->save(TRUE);
// Populate the dummy query string added to all CSS and JavaScript files.
_drupal_flush_css_js();
}
/**
* Implements hook_schema().
*/
function system_schema() {
$schema['sequences'] = [
'description' => 'Stores IDs.',
'fields' => [
'value' => [
'description' => 'The value of the sequence.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
],
'primary key' => ['value'],
];
$schema['sessions'] = [
'description' => "Drupal's session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated.",
'fields' => [
'uid' => [
'description' => 'The {users}.uid corresponding to a session, or 0 for anonymous user.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
'sid' => [
'description' => "A session ID (hashed). The value is generated by Drupal's session handlers.",
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
],
'hostname' => [
'description' => 'The IP address that last used this session ID (sid).',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
],
'timestamp' => [
'description' => 'The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
],
'session' => [
'description' => 'The serialized contents of the user\'s session, an array of name/value pairs that persists across page requests by this session ID. Drupal loads the user\'s session from here at the start of each request and saves it at the end.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
],
],
'primary key' => [
'sid',
],
'indexes' => [
'timestamp' => ['timestamp'],
'uid' => ['uid'],
],
'foreign keys' => [
'session_user' => [
'table' => 'users',
'columns' => ['uid' => 'uid'],
],
],
];
return $schema;
}
/**
* Implements hook_update_last_removed().
*/
function system_update_last_removed() {
return 8901;
}
/**
* Display requirements from security advisories.
*
* @param array[] $requirements
* The requirements array as specified in hook_requirements().
*/
function _system_advisories_requirements(array &$requirements): void {
if (!\Drupal::config('system.advisories')->get('enabled')) {
return;
}
/** @var \Drupal\system\SecurityAdvisories\SecurityAdvisoriesFetcher $fetcher */
$fetcher = \Drupal::service('system.sa_fetcher');
try {
$advisories = $fetcher->getSecurityAdvisories(TRUE, 5);
}
catch (TransferException $exception) {
$requirements['system_advisories']['title'] = t('Critical security announcements');
$requirements['system_advisories']['severity'] = REQUIREMENT_WARNING;
$requirements['system_advisories']['description'] = ['#theme' => 'system_security_advisories_fetch_error_message'];
watchdog_exception('system', $exception, 'Failed to retrieve security advisory data.');
return;
}
if (!empty($advisories)) {
$advisory_links = [];
$severity = REQUIREMENT_WARNING;
foreach ($advisories as $advisory) {
if (!$advisory->isPsa()) {
$severity = REQUIREMENT_ERROR;
}
$advisory_links[] = new Link($advisory->getTitle(), Url::fromUri($advisory->getUrl()));
}
$requirements['system_advisories']['title'] = t('Critical security announcements');
$requirements['system_advisories']['severity'] = $severity;
$requirements['system_advisories']['description'] = [
'list' => [
'#theme' => 'item_list',
'#items' => $advisory_links,
],
];
if (\Drupal::moduleHandler()->moduleExists('help')) {
$requirements['system_advisories']['description']['help_link'] = Link::createFromRoute(
'What are critical security announcements?',
'help.page', ['name' => 'system'],
['fragment' => 'security-advisories']
)->toRenderable();
}
}
}
name: 'Update Manager'
type: module
description: 'Не поддерживается в ДАР CMS'
version: VERSION
package: Core
dependencies:
- drupal:file
<svg width="214" height="214" viewBox="0 0 214 214" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M172 59C154.963 36 135 19 105 0C110.5 30.5 58.5 50 41 68.5C23.5 87 17 106.188 17 125.902C17 174.204 57.6985 213.5 106 213.5C154.302 213.5 196.5 174.204 196.5 125.902C196.5 106.188 189.037 82 172 59Z" fill="#ffffff"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M105.318 83.5C92.4745 83.5 81.0102 88.6894 73.0589 96.8593C70.2775 99.7171 68.2075 104.354 67.3793 109.481C66.5258 114.766 67.2414 118.928 68.2111 120.763C58 122 51.5 113 52.5 104.5C53.2059 98.5 55.8754 91.5746 61.5929 85.7C72.5277 74.4646 88.115 67.5 105.318 67.5C137.872 67.5 165 92.6234 165 124.5C165 156.377 137.872 181.5 105.318 181.5C100.829 181.5 93.7529 180.358 90 180C85.3088 179.654 71.5 179 64 182L83.5 108.5C85.5 102 91.7553 98.2637 102.602 99.6635L84.5586 164.168C86.3276 164.183 88.0427 164.274 89.7083 164.397C91.628 164.538 93.3802 164.707 95.0667 164.87C98.4724 165.198 101.61 165.5 105.318 165.5C129.85 165.5 149 146.747 149 124.5C149 102.253 129.85 83.5 105.318 83.5Z" fill="#cccccc"/>
</svg>
\ No newline at end of file
<svg width="214" height="214" viewBox="0 0 214 214" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M172 59C154.963 36 135 19 105 0C110.5 30.5 58.5 50 41 68.5C23.5 87 17 106.188 17 125.902C17 174.204 57.6985 213.5 106 213.5C154.302 213.5 196.5 174.204 196.5 125.902C196.5 106.188 189.037 82 172 59Z" fill="#008CF2"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M105.318 83.5C92.4745 83.5 81.0102 88.6894 73.0589 96.8593C70.2775 99.7171 68.2075 104.354 67.3793 109.481C66.5258 114.766 67.2414 118.928 68.2111 120.763C58 122 51.5 113 52.5 104.5C53.2059 98.5 55.8754 91.5746 61.5929 85.7C72.5277 74.4646 88.115 67.5 105.318 67.5C137.872 67.5 165 92.6234 165 124.5C165 156.377 137.872 181.5 105.318 181.5C100.829 181.5 93.7529 180.358 90 180C85.3088 179.654 71.5 179 64 182L83.5 108.5C85.5 102 91.7553 98.2637 102.602 99.6635L84.5586 164.168C86.3276 164.183 88.0427 164.274 89.7083 164.397C91.628 164.538 93.3802 164.707 95.0667 164.87C98.4724 165.198 101.61 165.5 105.318 165.5C129.85 165.5 149 146.747 149 124.5C149 102.253 129.85 83.5 105.318 83.5Z" fill="white"/>
</svg>
\ No newline at end of file
<?php
/**
* @file
* Includes the autoloader created by Composer.
*
* This file was generated by drupal-scaffold.
*
* @see composer.json
* @see index.php
* @see core/install.php
* @see core/rebuild.php
* @see core/modules/statistics/statistics.php
*/
return require __DIR__ . '/../vendor/autoload.php';
This file was automatically generated by Composer Patches (https://github.com/cweagans/composer-patches)
Patches applied to this directory:
Deprecated function: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Html::getId() (line 219 of core/lib/Drupal/Component/Utility/Html.php)
Source: https://www.drupal.org/files/issues/2023-04-06/3326684-apply-condition1.patch
Querying with NULL values results in warning mb_strtolower(): Passing null to parameter is deprecated
Source: https://www.drupal.org/files/issues/2022-08-23/3302838-13.patch
--errors=box-model,
display-property-grouping,
duplicate-background-images,
duplicate-properties,
empty-rules,
ids,
import,
important,
known-properties,
outline-none,
overqualified-elements,
qualified-headings,
shorthand,
star-property-hack,
text-indent,
underscore-property-hack,
unique-headings,
unqualified-attributes,
vendor-prefix,
zero-units
--ignore=adjoining-classes,
box-sizing,
bulletproof-font-face,
compatible-vendor-prefixes,
errors,
fallback-colors,
floats,
font-faces,
font-sizes,
gradients,
import-ie-limit,
order-alphabetical,
regex-selectors,
rules-count,
selector-max,
selector-max-approaching,
selector-newline,
universal-selector
--exclude-list=core/assets,
vendor
Please read core/INSTALL.txt for detailed installation instructions for your
Drupal website.
<img alt="Drupal Logo" src="https://www.drupal.org/files/Wordmark_blue_RGB.png" height="60px">
Drupal is an open source content management platform supporting a variety of
websites ranging from personal weblogs to large community-driven websites. For
more information, visit the Drupal website, [Drupal.org][Drupal.org], and join
the [Drupal community][Drupal community].
## Contributing
Drupal is developed on [Drupal.org][Drupal.org], the home of the international
Drupal community since 2001!
[Drupal.org][Drupal.org] hosts Drupal's [GitLab repository][GitLab repository],
its [issue queue][issue queue], and its [documentation][documentation]. Before
you start working on code, be sure to search the [issue queue][issue queue] and
create an issue if your aren't able to find an existing issue.
Every issue on Drupal.org automatically creates a new community-accessible fork
that you can contribute to. Learn more about the code contribution process on
the [Issue forks & merge requests page][issue forks].
## Usage
For a brief introduction, see [USAGE.txt](/core/USAGE.txt). You can also find
guides, API references, and more by visiting Drupal's [documentation
page][documentation].
You can quickly extend Drupal's core feature set by installing any of its
[thousands of free and open source modules][modules]. With Drupal and its
module ecosystem, you can often build most or all of what your project needs
before writing a single line of code.
## Changelog
Drupal keeps detailed [change records][changelog]. You can search Drupal's
changes for a record of every notable breaking change and new feature since
2011.
## Security
For a list of security announcements, see the [Security advisories
page][Security advisories] (available as [an RSS feed][security RSS]). This
page also describes how to subscribe to these announcements via email.
For information about the Drupal security process, or to find out how to report
a potential security issue to the Drupal security team, see the [Security team
page][security team].
## Need a helping hand?
Visit the [Support page][support] or browse [over a thousand Drupal
providers][service providers] offering design, strategy, development, and
hosting services.
## Legal matters
Know your rights when using Drupal by reading Drupal core's
[license](/core/LICENSE.txt).
Learn about the [Drupal trademark and logo policy here][trademark].
[Drupal.org]: https://www.drupal.org
[Drupal community]: https://www.drupal.org/community
[GitLab repository]: https://git.drupalcode.org/project/drupal
[issue queue]: https://www.drupal.org/project/issues/drupal
[issue forks]: https://www.drupal.org/drupalorg/docs/gitlab-integration/issue-forks-merge-requests
[documentation]: https://www.drupal.org/documentation
[changelog]: https://www.drupal.org/list-changes/drupal
[modules]: https://www.drupal.org/project/project_module
[security advisories]: https://www.drupal.org/security
[security RSS]: https://www.drupal.org/security/rss.xml
[security team]: https://www.drupal.org/drupal-security-team
[service providers]: https://www.drupal.org/drupal-services
[support]: https://www.drupal.org/support
[trademark]: https://www.drupal.com/trademark
core/**/*
vendor/**/*
sites/**/files/**/*
libraries/**/*
sites/**/libraries/**/*
profiles/**/libraries/**/*
**/js_test_files/**/*
**/node_modules/**/*
{
"extends": "./core/.eslintrc.json"
}
<?php
/**
* @file
* Router script for the built-in PHP web server.
*
* The built-in web server should only be used for development and testing as it
* has a number of limitations that makes running Drupal on it highly insecure
* and somewhat limited.
*
* Note that:
* - The server is single-threaded, any requests made during the execution of
* the main request will hang until the main request has been completed.
* - The web server does not enforce any of the settings in .htaccess in
* particular a remote user will be able to download files that normally would
* be protected from direct access such as .module files.
*
* The router script is needed to work around a bug in PHP, see
* https://bugs.php.net/bug.php?id=61286.
*
* Usage:
* php -S localhost:8888 .ht.router.php
*
* @see http://php.net/manual/en/features.commandline.webserver.php
*/
$url = parse_url($_SERVER['REQUEST_URI']);
if (file_exists(__DIR__ . $url['path'])) {
// Serve the requested resource as-is.
return FALSE;
}
// Work around the PHP bug.
$path = $url['path'];
$script = 'index.php';
if (strpos($path, '.php') !== FALSE) {
// Work backwards through the path to check if a script exists. Otherwise
// fallback to index.php.
do {
$path = dirname($path);
if (preg_match('/\.php$/', $path) && is_file(__DIR__ . $path)) {
// Discovered that the path contains an existing PHP file. Use that as the
// script to include.
$script = ltrim($path, '/');
break;
}
} while ($path !== '/' && $path !== '.');
}
// Update $_SERVER variables to point to the correct index-file.
$index_file_absolute = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $script;
$index_file_relative = DIRECTORY_SEPARATOR . $script;
// SCRIPT_FILENAME will point to the router script itself, it should point to
// the full path of index.php.
$_SERVER['SCRIPT_FILENAME'] = $index_file_absolute;
// SCRIPT_NAME and PHP_SELF will either point to index.php or contain the full
// virtual path being requested depending on the URL being requested. They
// should always point to index.php relative to document root.
$_SERVER['SCRIPT_NAME'] = $index_file_relative;
$_SERVER['PHP_SELF'] = $index_file_relative;
// Require the script and let core take over.
require $_SERVER['SCRIPT_FILENAME'];
#
# Apache/PHP/Drupal settings:
#
# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config|yarn\.lock|package\.json)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
</IfModule>
</FilesMatch>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Set the default handler.
DirectoryIndex index.php index.html index.htm
# Add correct encoding for SVGZ.
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
# Most of the following PHP settings cannot be changed at runtime. See
# sites/default/default.settings.php and
# Drupal\Core\DrupalKernel::bootEnvironment() for settings that can be
# changed at runtime.
<IfModule mod_php.c>
php_value assert.active 0
</IfModule>
# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
# Enable expirations.
ExpiresActive On
# Cache all files and redirects for 2 weeks after access (A).
ExpiresDefault A1209600
<FilesMatch \.php$>
# Do not allow PHP scripts to be cached unless they explicitly send cache
# headers themselves. Otherwise all scripts would have to overwrite the
# headers set by mod_expires if they want another caching behavior. This may
# fail if an error occurs early in the bootstrap process, and it may cause
# problems if a non-Drupal PHP file is installed in a subdirectory.
ExpiresActive Off
</FilesMatch>
</IfModule>
# Set a fallback resource if mod_rewrite is not enabled. This allows Drupal to
# work without clean URLs. This requires Apache version >= 2.2.16. If Drupal is
# not accessed by the top level URL (i.e.: http://example.com/drupal/ instead of
# http://example.com/), the path to index.php will need to be adjusted.
<IfModule !mod_rewrite.c>
FallbackResource /index.php
</IfModule>
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# Set "protossl" to "s" if we were accessed via https://. This is used later
# if you enable "www." stripping or enforcement, in order to ensure that
# you don't bounce between http and https.
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
# Make sure Authorization HTTP header is available to PHP
# even when running as CGI or FastCGI.
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Block access to "hidden" directories whose names begin with a period. This
# includes directories used by version control systems such as Subversion or
# Git to store control files. Files whose names begin with a period, as well
# as the control files used by CVS, are protected by the FilesMatch directive
# above.
#
# NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
# not possible to block access to entire directories from .htaccess because
# <DirectoryMatch> is not allowed here.
#
# If you do not have mod_rewrite installed, you should remove these
# directories from your webroot or otherwise protect them from being
# downloaded.
RewriteRule "/\.|^\.(?!well-known/)" - [F]
# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/foo will be redirected to http://www.example.com/foo)
# uncomment the following:
# RewriteCond %{HTTP_HOST} .
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/foo will be redirected to http://example.com/foo)
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /
# Redirect common PHP files to their new locations.
RewriteCond %{REQUEST_URI} ^(.*)?/(install\.php) [OR]
RewriteCond %{REQUEST_URI} ^(.*)?/(rebuild\.php)
RewriteCond %{REQUEST_URI} !core
RewriteRule ^ %1/core/%2 [L,QSA,R=301]
# Rewrite install.php during installation to see if mod_rewrite is working
RewriteRule ^core/install\.php core/install.php?rewrite=ok [QSA,L]
# Pass all requests not referring directly to files in the filesystem to
# index.php.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
# For security reasons, deny access to other PHP files on public sites.
# Note: The following URI conditions are not anchored at the start (^),
# because Drupal may be located in a subdirectory. To further improve
# security, you can replace '!/' with '!^/'.
# Allow access to PHP files in /core (like authorize.php or install.php):
RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
# Allow access to test-specific PHP files:
RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?\.php
# Allow access to Statistics module's custom front controller.
# Copy and adapt this rule to directly execute PHP files in contributed or
# custom modules or to run another PHP application in the same directory.
RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics\.php$
# Deny access to any other PHP files that do not match the rules above.
# Specifically, disallow autoload.php from being served directly.
RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]
# Rules to correctly serve gzip compressed CSS and JS files.
# Requires both mod_rewrite and mod_headers to be enabled.
<IfModule mod_headers.c>
# Serve gzip compressed CSS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*css_[a-zA-Z0-9-_])\.css$ $1\.css\.gz [QSA]
# Serve gzip compressed JS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*js_[a-zA-Z0-9-_])\.js$ $1\.js\.gz [QSA]
# Serve correct content types, and prevent double compression.
RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1,E=no-brotli:1]
RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1,E=no-brotli:1]
<FilesMatch "(\.js\.gz|\.css\.gz)$">
# Serve correct encoding type.
Header set Content-Encoding gzip
# Force proxies to cache gzipped & non-gzipped css/js files separately.
Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>
</IfModule>
# Various header fixes.
<IfModule mod_headers.c>
# Disable content sniffing, since it's an attack vector.
Header always set X-Content-Type-Options nosniff
# Disable Proxy header, since it's an attack vector.
RequestHeader unset Proxy
</IfModule>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment