Commit 5b52c418 authored by catch's avatar catch

Issue #3031128 by alexpott, TrevorBradley, indigoxela, catch, cilefen,...

Issue #3031128 by alexpott, TrevorBradley, indigoxela, catch, cilefen, larowlan, jibran: Update from 8.6.7 to 8.6.8 warnings - Drupal\Core\Extension\Extension has no unserializer

(cherry picked from commit bf21c001)
parent 50c0a045
......@@ -9,6 +9,7 @@
*/
use Drupal\Component\Graph\Graph;
use Drupal\Core\Update\UpdateKernel;
use Drupal\Core\Utility\Error;
/**
......@@ -29,6 +30,10 @@ function update_fix_compatibility() {
$extension_config->set('module', module_config_sort($extension_config->get('module')));
$extension_config->save();
}
// Fix extension objects if the update is being done via Drush 8. In non-Drush
// environments this will already be fixed by the UpdateKernel this point.
UpdateKernel::fixSerializedExtensionObjects(\Drupal::getContainer());
}
/**
......
......@@ -7,6 +7,7 @@
use Drupal\Core\Site\Settings;
use Drupal\Core\StackMiddleware\ReverseProxyMiddleware;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
......@@ -190,4 +191,44 @@ protected function handleAccess(Request $request) {
}
}
/**
* {@inheritdoc}
*/
public function loadLegacyIncludes() {
parent::loadLegacyIncludes();
static::fixSerializedExtensionObjects($this->container);
}
/**
* Fixes caches and theme info if they contain old Extension objects.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The container.
*
* @internal
* This function is only to be called by the Drupal core update process.
* Additionally, this function will be removed in minor release of Drupal.
*
* @todo https://www.drupal.org/project/drupal/issues/3031322 Remove once
* Drupal 8.6.x is not supported.
*/
public static function fixSerializedExtensionObjects(ContainerInterface $container) {
// Create a custom error handler that will clear caches if a warning occurs
// while getting 'system.theme.data' from state. If this state value was
// created by Drupal <= 8.6.7 then when it is read by Drupal >= 8.6.8 there
// will be PHP warnings. This silently fixes Drupal so that the update can
// continue.
$callable = function () use ($container) {
foreach ($container->getParameter('cache_bins') as $service_id => $bin) {
$container->get($service_id)->deleteAll();
}
// Also rebuild themes because it uses state as cache.
$container->get('theme_handler')->refreshInfo();
};
set_error_handler($callable, E_ERROR | E_WARNING);
$container->get('state')->get('system.theme.data', []);
restore_error_handler();
}
}
<?php
// @codingStandardsIgnoreFile
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Manually configure the test mail collector implementation to prevent
// tests from sending out emails and collect them in state instead.
// While this should be enforced via settings.php prior to installation,
// some tests expect to be able to test mail system implementations.
$config = $connection->select('config')
->fields('config', ['data'])
->condition('collection', '')
->condition('name', 'system.mail')
->execute()
->fetchField();
$config = unserialize($config);
$config['interface']['default'] = 'test_mail_collector';
$connection->update('config')
->fields([
'data' => serialize($config),
'collection' => '',
'name' => 'system.mail',
])
->condition('collection', '')
->condition('name', 'system.mail')
->execute();
// By default, verbosely display all errors and disable all production
// environment optimizations for all tests to avoid needless overhead and
// ensure a sane default experience for test authors.
// @see https://www.drupal.org/node/2259167
$config = $connection->select('config')
->fields('config', ['data'])
->condition('collection', '')
->condition('name', 'system.logging')
->execute()
->fetchField();
$config = unserialize($config);
$config['error_level'] = 'verbose';
$connection->update('config')
->fields([
'data' => serialize($config),
'collection' => '',
'name' => 'system.logging',
])
->condition('collection', '')
->condition('name', 'system.logging')
->execute();
$config = $connection->select('config')
->fields('config', ['data'])
->condition('collection', '')
->condition('name', 'system.performance')
->execute()
->fetchField();
$config = unserialize($config);
$config['css']['preprocess'] = FALSE;
$config['js']['preprocess'] = FALSE;
$connection->update('config')
->fields([
'data' => serialize($config),
'collection' => '',
'name' => 'system.performance',
])
->condition('collection', '')
->condition('name', 'system.performance')
->execute();
// Set an explicit time zone to not rely on the system one, which may vary
// from setup to setup. The Australia/Sydney time zone is chosen so all
// tests are run using an edge case scenario (UTC10 and DST). This choice
// is made to prevent time zone related regressions and reduce the
// fragility of the testing system in general.
$config = $connection->select('config')
->fields('config', ['data'])
->condition('collection', '')
->condition('name', 'system.date')
->execute()
->fetchField();
$config = unserialize($config);
$config['timezone']['default'] = 'Australia/Sydney';
$connection->update('config')
->fields([
'data' => serialize($config),
'collection' => '',
'name' => 'system.date',
])
->condition('collection', '')
->condition('name', 'system.date')
->execute();
<?php
namespace Drupal\Tests\system\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Updates from 8.6.0 with warm caches.
*
* @group Update
* @group legacy
*/
class WarmCacheUpdateFrom8dot6Test extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
// Created by installing minimal on 8.6.0, logging on as user 1 and doing:
// php ./core/scripts/db-tools.php dump-database-d8-mysql --schema-only=sessions,watchdog
$this->databaseDumpFiles[0] = __DIR__ . '/../../../../tests/fixtures/update/drupal-8.6.0-minimal-with-warm-caches.sql.gz';
$this->databaseDumpFiles[1] = __DIR__ . '/../../../../tests/fixtures/update/drupal-8.test-config-init.php';
}
/**
* Tests that the content and configuration were properly updated.
*/
public function testUpdatedSite() {
$this->runUpdates();
$this->drupalGet('');
$this->resetAll();
// Ensure that drupal-8.test-config-init.php has run correctly.
$this->assertSame('test_mail_collector', $this->config('system.mail')->get('interface.default'));
$this->assertSame('verbose', $this->config('system.logging')->get('error_level'));
$this->assertSame(FALSE, $this->config('system.performance')->get('css.preprocess'));
$this->assertSame(FALSE, $this->config('system.performance')->get('js.preprocess'));
$this->assertSame('Australia/Sydney', $this->config('system.date')->get('timezone.default'));
}
/**
* {@inheritdoc}
*/
protected function initConfig(ContainerInterface $container) {
// Don't touch configuration before running the updates as this invokes
// \Drupal\system\EventSubscriber\ConfigCacheTag::onSave() which lists
// themes. This functionality is replicated in
// core/modules/system/tests/fixtures/update/drupal-8.test-config-init.php.
}
}
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