Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -9,10 +9,16 @@ use Drupal\Component\Utility\Crypt;
|
|||
use Drupal\Component\Utility\Environment;
|
||||
use Drupal\Component\FileSystem\FileSystem;
|
||||
use Drupal\Component\Utility\OpCodeCache;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Path\AliasStorage;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Entity\ContentEntityTypeInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Entity\FieldableEntityInterface;
|
||||
use Drupal\Core\DrupalKernel;
|
||||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\Core\StreamWrapper\PrivateStream;
|
||||
use Drupal\Core\StreamWrapper\PublicStream;
|
||||
|
@ -45,10 +51,10 @@ function system_requirements($phase) {
|
|||
'value' => t('%profile_name (%profile-%version)', [
|
||||
'%profile_name' => $info['name'],
|
||||
'%profile' => $profile,
|
||||
'%version' => $info['version']
|
||||
'%version' => $info['version'],
|
||||
]),
|
||||
'severity' => REQUIREMENT_INFO,
|
||||
'weight' => -9
|
||||
'weight' => -9,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -71,14 +77,15 @@ function system_requirements($phase) {
|
|||
}
|
||||
|
||||
// Web server information.
|
||||
$software = \Drupal::request()->server->get('SERVER_SOFTWARE');
|
||||
$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'] && !isset($_GET['rewrite']) && strpos($software, 'Apache') !== FALSE) {
|
||||
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
|
||||
|
@ -151,7 +158,11 @@ function system_requirements($phase) {
|
|||
}
|
||||
}
|
||||
|
||||
// Test PHP version and show link to phpinfo() if it's available
|
||||
// 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') {
|
||||
|
@ -163,6 +174,8 @@ function system_requirements($phase) {
|
|||
];
|
||||
}
|
||||
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,
|
||||
|
@ -177,11 +190,25 @@ function system_requirements($phase) {
|
|||
// If PHP is old, it's not safe to continue with the requirements check.
|
||||
return $requirements;
|
||||
}
|
||||
if ((version_compare($phpversion, DRUPAL_RECOMMENDED_PHP) < 0) && ($phase === 'install' || $phase === 'runtime')) {
|
||||
// Warn if still on PHP 5. If at least PHP 7.0, relax from "warning" to
|
||||
// "info", and show it at runtime only, to not scare users while installing.
|
||||
if (version_compare($phpversion, '7.0') < 0) {
|
||||
$requirements['php']['description'] = t('Drupal will drop support for this version on March 6, 2019. Upgrade to PHP version %recommended or higher to ensure your site can receive updates and remain secure. See <a href="http://php.net/supported-versions.php">PHP\'s version support documentation</a> and the <a href=":php_requirements">Drupal 8 PHP requirements handbook page</a> for more information.', ['%recommended' => DRUPAL_RECOMMENDED_PHP, ':php_requirements' => 'https://www.drupal.org/docs/8/system-requirements/php']);
|
||||
$requirements['php']['severity'] = REQUIREMENT_WARNING;
|
||||
}
|
||||
else {
|
||||
if ($phase === 'runtime') {
|
||||
$requirements['php']['description'] = t('It is recommended to upgrade to PHP version %recommended or higher for the best ongoing support. See <a href="http://php.net/supported-versions.php">PHP\'s version support documentation</a> and the <a href=":php_requirements">Drupal 8 PHP requirements handbook page</a> for more information.', ['%recommended' => DRUPAL_RECOMMENDED_PHP, ':php_requirements' => 'https://www.drupal.org/docs/8/system-requirements/php']);
|
||||
$requirements['php']['severity'] = REQUIREMENT_INFO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Suggest to update to at least 5.5.21 or 5.6.5 for disabling multiple
|
||||
// statements.
|
||||
if (($phase === 'install' || \Drupal::database()->driver() === 'mysql') && !SystemRequirements::phpVersionWithPdoDisallowMultipleStatements($phpversion)) {
|
||||
$requirements['php'] = [
|
||||
$requirements['php_multiple_statement'] = [
|
||||
'title' => t('PHP (multiple statement disabling)'),
|
||||
'value' => $phpversion_label,
|
||||
'description' => t('PHP versions higher than 5.6.5 or 5.5.21 provide built-in SQL injection protection for mysql databases. It is recommended to update.'),
|
||||
|
@ -409,12 +436,13 @@ function system_requirements($phase) {
|
|||
// 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')) {
|
||||
$conf_errors[] = t('Protection disabled');
|
||||
$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')) {
|
||||
|
@ -423,7 +451,7 @@ function system_requirements($phase) {
|
|||
}
|
||||
foreach (['settings.php', 'settings.local.php', 'services.yml'] as $conf_file) {
|
||||
$full_path = $site_path . '/' . $conf_file;
|
||||
if (file_exists($full_path) && (Settings::get('skip_permissions_hardening') || !drupal_verify_install_file($full_path, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE))) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
@ -445,7 +473,7 @@ function system_requirements($phase) {
|
|||
];
|
||||
}
|
||||
$requirements['configuration_files'] = [
|
||||
'value' => t('Not protected'),
|
||||
'value' => $error_value,
|
||||
'severity' => $file_protection_severity,
|
||||
'description' => $description,
|
||||
];
|
||||
|
@ -463,19 +491,20 @@ function system_requirements($phase) {
|
|||
// Try to write the .htaccess files first, to prevent false alarms in case
|
||||
// (for example) the /tmp directory was wiped.
|
||||
file_ensure_htaccess();
|
||||
$file_system = \Drupal::service('file_system');
|
||||
$htaccess_files['public://.htaccess'] = [
|
||||
'title' => t('Public files directory'),
|
||||
'directory' => drupal_realpath('public://'),
|
||||
'directory' => $file_system->realpath('public://'),
|
||||
];
|
||||
if (PrivateStream::basePath()) {
|
||||
$htaccess_files['private://.htaccess'] = [
|
||||
'title' => t('Private files directory'),
|
||||
'directory' => drupal_realpath('private://'),
|
||||
'directory' => $file_system->realpath('private://'),
|
||||
];
|
||||
}
|
||||
$htaccess_files['temporary://.htaccess'] = [
|
||||
'title' => t('Temporary files directory'),
|
||||
'directory' => drupal_realpath('temporary://'),
|
||||
'directory' => $file_system->realpath('temporary://'),
|
||||
];
|
||||
foreach ($htaccess_files as $htaccess_file => $info) {
|
||||
// Check for the string which was added to the recommended .htaccess file
|
||||
|
@ -615,7 +644,7 @@ function system_requirements($phase) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($phase != 'install' && (empty($GLOBALS['config_directories']) || empty($GLOBALS['config_directories'][CONFIG_SYNC_DIRECTORY]) )) {
|
||||
if ($phase != 'install' && (empty($GLOBALS['config_directories']) || empty($GLOBALS['config_directories'][CONFIG_SYNC_DIRECTORY]))) {
|
||||
$requirements['config directories'] = [
|
||||
'title' => t('Configuration directories'),
|
||||
'value' => t('Not present'),
|
||||
|
@ -805,9 +834,46 @@ function system_requirements($phase) {
|
|||
}
|
||||
}
|
||||
|
||||
// Test Unicode library
|
||||
include_once DRUPAL_ROOT . '/core/includes/unicode.inc';
|
||||
$requirements = array_merge($requirements, unicode_requirements());
|
||||
// Returns Unicode library status and errors.
|
||||
$libraries = [
|
||||
Unicode::STATUS_SINGLEBYTE => t('Standard PHP'),
|
||||
Unicode::STATUS_MULTIBYTE => t('PHP Mbstring Extension'),
|
||||
Unicode::STATUS_ERROR => t('Error'),
|
||||
];
|
||||
$severities = [
|
||||
Unicode::STATUS_SINGLEBYTE => REQUIREMENT_WARNING,
|
||||
Unicode::STATUS_MULTIBYTE => NULL,
|
||||
Unicode::STATUS_ERROR => REQUIREMENT_ERROR,
|
||||
];
|
||||
$failed_check = Unicode::check();
|
||||
$library = Unicode::getStatus();
|
||||
|
||||
$requirements['unicode'] = [
|
||||
'title' => t('Unicode library'),
|
||||
'value' => $libraries[$library],
|
||||
'severity' => $severities[$library],
|
||||
];
|
||||
switch ($failed_check) {
|
||||
case 'mb_strlen':
|
||||
$requirements['unicode']['description'] = t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="http://php.net/mbstring">PHP mbstring extension</a> for improved Unicode support.');
|
||||
break;
|
||||
|
||||
case 'mbstring.func_overload':
|
||||
$requirements['unicode']['description'] = t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
|
||||
break;
|
||||
|
||||
case 'mbstring.encoding_translation':
|
||||
$requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
|
||||
break;
|
||||
|
||||
case 'mbstring.http_input':
|
||||
$requirements['unicode']['description'] = t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
|
||||
break;
|
||||
|
||||
case 'mbstring.http_output':
|
||||
$requirements['unicode']['description'] = t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href="http://php.net/mbstring">PHP mbstring documentation</a> for more information.');
|
||||
break;
|
||||
}
|
||||
|
||||
if ($phase == 'runtime') {
|
||||
// Check for update status module.
|
||||
|
@ -854,7 +920,7 @@ function system_requirements($phase) {
|
|||
$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' => join(', ', $trusted_host_patterns)]),
|
||||
'description' => t('The trusted_host_patterns setting is set to allow %trusted_host_patterns', ['%trusted_host_patterns' => implode(', ', $trusted_host_patterns)]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -926,6 +992,43 @@ function system_requirements($phase) {
|
|||
];
|
||||
}
|
||||
}
|
||||
// Check to see if dates will be limited to 1901-2038.
|
||||
if (PHP_INT_SIZE <= 4) {
|
||||
$requirements['limited_date_range'] = [
|
||||
'title' => t('Limited date range'),
|
||||
'value' => t('Your PHP installation has a limited date range.'),
|
||||
'description' => t('You are running on a system where PHP is compiled or limited to using 32-bit integers. This will limit the range of dates and timestamps to the years 1901-2038. Read about the <a href=":url">limitations of 32-bit PHP</a>.', [':url' => 'https://www.drupal.org/docs/8/system-requirements/limitations-of-32-bit-php']),
|
||||
'severity' => REQUIREMENT_WARNING,
|
||||
];
|
||||
}
|
||||
|
||||
// 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 8 no longer uses the \$settings['install_profile'] value in settings.php and it can be removed."),
|
||||
'severity' => REQUIREMENT_INFO,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
}
|
||||
|
@ -1486,7 +1589,7 @@ function system_update_8007() {
|
|||
$schema = \Drupal::keyValue('entity.storage_schema.sql')->getAll();
|
||||
$schema_copy = $schema;
|
||||
foreach ($schema as $item_name => $item) {
|
||||
list($entity_type_id, , ) = explode('.', $item_name);
|
||||
list($entity_type_id, ,) = explode('.', $item_name);
|
||||
if (!isset($entity_types[$entity_type_id])) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1763,6 +1866,10 @@ function system_update_8200(&$sandbox) {
|
|||
*/
|
||||
function system_update_8201() {
|
||||
// Empty update to cause a cache rebuild.
|
||||
|
||||
// Use hook_post_update_NAME() instead to clear the cache.
|
||||
// The use of hook_update_N() to clear the cache has been deprecated
|
||||
// see https://www.drupal.org/node/2960601 for more details.
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1770,6 +1877,10 @@ function system_update_8201() {
|
|||
*/
|
||||
function system_update_8202() {
|
||||
// Empty update to cause a cache rebuild.
|
||||
|
||||
// Use hook_post_update_NAME() instead to clear the cache.The use
|
||||
// of hook_update_N to clear the cache has been deprecated see
|
||||
// https://www.drupal.org/node/2960601 for more details.
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1789,3 +1900,276 @@ function system_update_8301() {
|
|||
->set('profile', \Drupal::installProfile())
|
||||
->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move revision metadata fields to the revision table.
|
||||
*/
|
||||
function system_update_8400(&$sandbox) {
|
||||
// Due to the fields from RevisionLogEntityTrait not being explicitly
|
||||
// mentioned in the storage they might have been installed wrongly in the base
|
||||
// table for revisionable untranslatable entities and in the data and revision
|
||||
// data tables for revisionable and translatable entities.
|
||||
$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
|
||||
$database = \Drupal::database();
|
||||
$database_schema = $database->schema();
|
||||
|
||||
if (!isset($sandbox['current'])) {
|
||||
// This must be the first run. Initialize the sandbox.
|
||||
$sandbox['current'] = 0;
|
||||
|
||||
$definitions = array_filter(\Drupal::entityTypeManager()->getDefinitions(), function (EntityTypeInterface $entity_type) use ($entity_definition_update_manager) {
|
||||
if ($entity_type = $entity_definition_update_manager->getEntityType($entity_type->id())) {
|
||||
return is_subclass_of($entity_type->getClass(), FieldableEntityInterface::class) && ($entity_type instanceof ContentEntityTypeInterface) && $entity_type->isRevisionable();
|
||||
}
|
||||
return FALSE;
|
||||
});
|
||||
$sandbox['entity_type_ids'] = array_keys($definitions);
|
||||
$sandbox['max'] = count($sandbox['entity_type_ids']);
|
||||
}
|
||||
|
||||
$current_entity_type_key = $sandbox['current'];
|
||||
for ($i = $current_entity_type_key; ($i < $current_entity_type_key + 1) && ($i < $sandbox['max']); $i++) {
|
||||
$entity_type_id = $sandbox['entity_type_ids'][$i];
|
||||
/** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
|
||||
$entity_type = $entity_definition_update_manager->getEntityType($entity_type_id);
|
||||
|
||||
$base_fields = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions($entity_type_id);
|
||||
$revision_metadata_fields = $entity_type->getRevisionMetadataKeys();
|
||||
$fields_to_update = array_intersect_key($base_fields, array_flip($revision_metadata_fields));
|
||||
|
||||
if (!empty($fields_to_update)) {
|
||||
// Initialize the entity table names.
|
||||
// @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage::initTableLayout()
|
||||
$base_table = $entity_type->getBaseTable() ?: $entity_type_id;
|
||||
$data_table = $entity_type->getDataTable() ?: $entity_type_id . '_field_data';
|
||||
$revision_table = $entity_type->getRevisionTable() ?: $entity_type_id . '_revision';
|
||||
$revision_data_table = $entity_type->getRevisionDataTable() ?: $entity_type_id . '_field_revision';
|
||||
$revision_field = $entity_type->getKey('revision');
|
||||
|
||||
// No data needs to be migrated if the entity type is not translatable.
|
||||
if ($entity_type->isTranslatable()) {
|
||||
if (!isset($sandbox[$entity_type_id])) {
|
||||
// This must be the first run for this entity type. Initialize the
|
||||
// sub-sandbox for it.
|
||||
|
||||
// Calculate the number of revisions to process.
|
||||
$count = \Drupal::entityQuery($entity_type_id)
|
||||
->allRevisions()
|
||||
->count()
|
||||
->accessCheck(FALSE)
|
||||
->execute();
|
||||
|
||||
$sandbox[$entity_type_id]['current'] = 0;
|
||||
$sandbox[$entity_type_id]['max'] = $count;
|
||||
}
|
||||
// Define the step size.
|
||||
$steps = Settings::get('entity_update_batch_size', 50);
|
||||
|
||||
// Collect the revision IDs to process.
|
||||
$revisions = \Drupal::entityQuery($entity_type_id)
|
||||
->allRevisions()
|
||||
->range($sandbox[$entity_type_id]['current'], $sandbox[$entity_type_id]['current'] + $steps)
|
||||
->sort($revision_field, 'ASC')
|
||||
->accessCheck(FALSE)
|
||||
->execute();
|
||||
$revisions = array_keys($revisions);
|
||||
|
||||
foreach ($fields_to_update as $revision_metadata_field_name => $definition) {
|
||||
// If the revision metadata field is present in the data and the
|
||||
// revision data table, install its definition again with the updated
|
||||
// storage code in order for the field to be installed in the
|
||||
// revision table. Afterwards, copy over the field values and remove
|
||||
// the field from the data and the revision data tables.
|
||||
if ($database_schema->fieldExists($data_table, $revision_metadata_field_name) && $database_schema->fieldExists($revision_data_table, $revision_metadata_field_name)) {
|
||||
// Install the field in the revision table.
|
||||
if (!isset($sandbox[$entity_type_id]['storage_definition_installed'][$revision_metadata_field_name])) {
|
||||
$entity_definition_update_manager->installFieldStorageDefinition($revision_metadata_field_name, $entity_type_id, $entity_type->getProvider(), $definition);
|
||||
$sandbox[$entity_type_id]['storage_definition_installed'][$revision_metadata_field_name] = TRUE;
|
||||
}
|
||||
|
||||
// Apply the field value from the revision data table to the
|
||||
// revision table.
|
||||
foreach ($revisions as $rev_id) {
|
||||
$field_value = $database->select($revision_data_table, 't')
|
||||
->fields('t', [$revision_metadata_field_name])
|
||||
->condition($revision_field, $rev_id)
|
||||
->execute()
|
||||
->fetchField();
|
||||
$database->update($revision_table)
|
||||
->condition($revision_field, $rev_id)
|
||||
->fields([$revision_metadata_field_name => $field_value])
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sandbox[$entity_type_id]['current'] += count($revisions);
|
||||
$sandbox[$entity_type_id]['finished'] = ($sandbox[$entity_type_id]['current'] == $sandbox[$entity_type_id]['max']) || empty($revisions);
|
||||
|
||||
if ($sandbox[$entity_type_id]['finished']) {
|
||||
foreach ($fields_to_update as $revision_metadata_field_name => $definition) {
|
||||
// Drop the field from the data and revision data tables.
|
||||
$database_schema->dropField($data_table, $revision_metadata_field_name);
|
||||
$database_schema->dropField($revision_data_table, $revision_metadata_field_name);
|
||||
}
|
||||
$sandbox['current']++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($fields_to_update as $revision_metadata_field_name => $definition) {
|
||||
if ($database_schema->fieldExists($base_table, $revision_metadata_field_name)) {
|
||||
// Install the field in the revision table.
|
||||
$entity_definition_update_manager->installFieldStorageDefinition($revision_metadata_field_name, $entity_type_id, $entity_type->getProvider(), $definition);
|
||||
// Drop the field from the base table.
|
||||
$database_schema->dropField($base_table, $revision_metadata_field_name);
|
||||
}
|
||||
}
|
||||
$sandbox['current']++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sandbox['current']++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sandbox['#finished'] = $sandbox['current'] == $sandbox['max'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove response.gzip (and response) from system module configuration.
|
||||
*/
|
||||
function system_update_8401() {
|
||||
\Drupal::configFactory()->getEditable('system.performance')
|
||||
->clear('response.gzip')
|
||||
->clear('response')
|
||||
->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the 'revision_translation_affected' field to all entity types.
|
||||
*/
|
||||
function system_update_8402() {
|
||||
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
|
||||
|
||||
// Clear the cached entity type definitions so we get the new
|
||||
// 'revision_translation_affected' entity key.
|
||||
\Drupal::entityTypeManager()->clearCachedDefinitions();
|
||||
|
||||
// Get a list of revisionable and translatable entity types.
|
||||
/** @var \Drupal\Core\Entity\ContentEntityTypeInterface[] $definitions */
|
||||
$definitions = array_filter(\Drupal::entityTypeManager()->getDefinitions(), function (EntityTypeInterface $entity_type) use ($definition_update_manager) {
|
||||
if ($entity_type = $definition_update_manager->getEntityType($entity_type->id())) {
|
||||
return $entity_type->isRevisionable() && $entity_type->isTranslatable();
|
||||
}
|
||||
return FALSE;
|
||||
});
|
||||
|
||||
foreach ($definitions as $entity_type_id => $entity_type) {
|
||||
$field_name = $entity_type->getKey('revision_translation_affected');
|
||||
// Install the 'revision_translation_affected' field if needed.
|
||||
if (!$definition_update_manager->getFieldStorageDefinition($field_name, $entity_type_id)) {
|
||||
$storage_definition = BaseFieldDefinition::create('boolean')
|
||||
->setLabel(t('Revision translation affected'))
|
||||
->setDescription(t('Indicates if the last edit of a translation belongs to current revision.'))
|
||||
->setReadOnly(TRUE)
|
||||
->setRevisionable(TRUE)
|
||||
->setTranslatable(TRUE)
|
||||
// Mark all pre-existing revisions as affected in order to be consistent
|
||||
// with the previous API return value: if the field was not defined the
|
||||
// value returned was always TRUE.
|
||||
->setInitialValue(TRUE);
|
||||
|
||||
$definition_update_manager
|
||||
->installFieldStorageDefinition($field_name, $entity_type_id, $entity_type_id, $storage_definition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all cache_* tables. They are recreated on demand with the new schema.
|
||||
*/
|
||||
function system_update_8403() {
|
||||
foreach (Cache::getBins() as $bin => $cache_backend) {
|
||||
// Try to delete the table regardless of which cache backend is handling it.
|
||||
// This is to ensure the new schema is used if the configuration for the
|
||||
// backend class is changed after the update hook runs.
|
||||
$table_name = "cache_$bin";
|
||||
$schema = Database::getConnection()->schema();
|
||||
if ($schema->tableExists($table_name)) {
|
||||
$schema->dropTable($table_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the 'revision_default' field to all relevant entity types.
|
||||
*/
|
||||
function system_update_8501() {
|
||||
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
|
||||
|
||||
// Clear the cached entity type definitions so we get the new
|
||||
// 'revision_default' revision metadata key.
|
||||
\Drupal::entityTypeManager()->clearCachedDefinitions();
|
||||
|
||||
// Get a list of revisionable entity types.
|
||||
/** @var \Drupal\Core\Entity\ContentEntityTypeInterface[] $definitions */
|
||||
$definitions = array_filter(\Drupal::entityTypeManager()->getDefinitions(), function (EntityTypeInterface $entity_type) use ($definition_update_manager) {
|
||||
if ($entity_type = $definition_update_manager->getEntityType($entity_type->id())) {
|
||||
return $entity_type->isRevisionable();
|
||||
}
|
||||
return FALSE;
|
||||
});
|
||||
|
||||
// Install the 'revision_default' field.
|
||||
foreach ($definitions as $entity_type_id => $entity_type) {
|
||||
$field_name = $entity_type->getRevisionMetadataKey('revision_default');
|
||||
// Install the 'revision_default' field if needed.
|
||||
if (!$definition_update_manager->getFieldStorageDefinition($field_name, $entity_type_id)) {
|
||||
// Make sure the new "revision_default" revision metadata key is available
|
||||
// also to code using the latest installed definition.
|
||||
$installed_entity_type = $definition_update_manager->getEntityType($entity_type_id);
|
||||
$revision_metadata_keys = $installed_entity_type->get('revision_metadata_keys');
|
||||
|
||||
if (!isset($revision_metadata_keys['revision_default'])) {
|
||||
// Update the property holding the required revision metadata keys,
|
||||
// which is used by the BC layer for retrieving the revision metadata
|
||||
// keys.
|
||||
// @see \Drupal\Core\Entity\ContentEntityType::getRevisionMetadataKeys().
|
||||
$required_revision_metadata_keys = $installed_entity_type->get('requiredRevisionMetadataKeys');
|
||||
$required_revision_metadata_keys['revision_default'] = $field_name;
|
||||
$installed_entity_type->set('requiredRevisionMetadataKeys', $required_revision_metadata_keys);
|
||||
|
||||
// Update the revision metadata keys to add the new required revision
|
||||
// metadata key "revision_default".
|
||||
$revision_metadata_keys['revision_default'] = $required_revision_metadata_keys['revision_default'];
|
||||
$installed_entity_type->set('revision_metadata_keys', $revision_metadata_keys);
|
||||
|
||||
$definition_update_manager->updateEntityType($installed_entity_type);
|
||||
}
|
||||
|
||||
$storage_definition = BaseFieldDefinition::create('boolean')
|
||||
->setLabel(t('Default revision'))
|
||||
->setDescription(t('A flag indicating whether this was a default revision when it was saved.'))
|
||||
->setStorageRequired(TRUE)
|
||||
->setTranslatable(FALSE)
|
||||
->setRevisionable(TRUE)
|
||||
// We cannot tell whether existing revisions were default or not when
|
||||
// they were created, but since we did not support creating non-default
|
||||
// revisions in any core stable UI so far, we default to TRUE.
|
||||
->setInitialValue(TRUE);
|
||||
|
||||
$definition_update_manager
|
||||
->installFieldStorageDefinition($field_name, $entity_type_id, $entity_type_id, $storage_definition);
|
||||
}
|
||||
else {
|
||||
$variables = ['@entity_type_label' => $entity_type->getLabel()];
|
||||
if ($field_name === 'revision_default') {
|
||||
\Drupal::logger('system')->error('An existing "Default revision" field was found for the @entity_type_label entity type, but no "revision_default" revision metadata key was found in its definition.', $variables);
|
||||
}
|
||||
else {
|
||||
\Drupal::logger('system')->error('An existing "Default revision" field was found for the @entity_type_label entity type.', $variables);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue