Issue #3098250 by alexpott, longwave, Wim Leers, lauriii: Remove all @deprecated code in \Drupal\Core\Extension
parent
70a86d7b99
commit
4af66535e4
|
@ -102,24 +102,6 @@ class InfoParserDynamic implements InfoParserInterface {
|
|||
if (isset($parsed_info['version']) && $parsed_info['version'] === 'VERSION') {
|
||||
$parsed_info['version'] = \Drupal::VERSION;
|
||||
}
|
||||
// Special backwards compatible handling profiles and their 'dependencies'
|
||||
// key.
|
||||
if ($parsed_info['type'] === 'profile' && isset($parsed_info['dependencies']) && !array_key_exists('install', $parsed_info)) {
|
||||
// Only trigger the deprecation message if we are actually using the
|
||||
// profile with the missing 'install' key. This avoids triggering the
|
||||
// deprecation when scanning all the available install profiles.
|
||||
global $install_state;
|
||||
if (isset($install_state['parameters']['profile'])) {
|
||||
$pattern = '@' . preg_quote(DIRECTORY_SEPARATOR . $install_state['parameters']['profile'] . '.info.yml') . '$@';
|
||||
if (preg_match($pattern, $filename)) {
|
||||
@trigger_error("The install profile $filename only implements a 'dependencies' key. As of Drupal 8.6.0 profile's support a new 'install' key for modules that should be installed but not depended on. See https://www.drupal.org/node/2952947.", E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
// Move dependencies to install so that if a profile has both
|
||||
// dependencies and install then dependencies are real.
|
||||
$parsed_info['install'] = $parsed_info['dependencies'];
|
||||
$parsed_info['dependencies'] = [];
|
||||
}
|
||||
}
|
||||
return $parsed_info;
|
||||
}
|
||||
|
|
|
@ -247,24 +247,12 @@ class ThemeExtensionList extends ExtensionList {
|
|||
protected function createExtensionInfo(Extension $extension) {
|
||||
$info = parent::createExtensionInfo($extension);
|
||||
|
||||
// In the past, Drupal used to default to the `stable` theme as the base
|
||||
// theme. Explicitly opting out by specifying `base theme: false` was (and
|
||||
// still is) possible. However, defaulting to `base theme: stable` prevents
|
||||
// automatic updates to the next major version of Drupal, since each major
|
||||
// version may have a different version of "the stable theme", for example:
|
||||
// - for Drupal 8: `stable`
|
||||
// - for Drupal 9: `stable9`
|
||||
// - for Drupal 10: `stable10`
|
||||
// - et cetera
|
||||
// It is impossible to reliably determine which should be used by default,
|
||||
// hence we now require the base theme to be explicitly specified.
|
||||
if (!isset($info['base theme'])) {
|
||||
@trigger_error(sprintf('There is no `base theme` property specified in the %s.info.yml file. The optionality of the `base theme` property is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. All Drupal 8 themes must add `base theme: stable` to their *.info.yml file for them to continue to work as-is in future versions of Drupal. Drupal 9 requires the `base theme` property to be specified. See https://www.drupal.org/node/3066038', $extension->getName()), E_USER_DEPRECATED);
|
||||
$info['base theme'] = 'stable';
|
||||
throw new InfoParserException('Missing required key (base_theme) in ' . $extension->getExtensionPathname() . '/' . $extension->getExtensionFilename());
|
||||
}
|
||||
|
||||
// Remove the default Stable base theme when 'base theme: false' is set in
|
||||
// a theme .info.yml file.
|
||||
// Remove the base theme when 'base theme: false' is set in a theme
|
||||
// .info.yml file.
|
||||
if ($info['base theme'] === FALSE) {
|
||||
unset($info['base theme']);
|
||||
}
|
||||
|
|
|
@ -150,44 +150,6 @@ class ModuleHandlerTest extends KernelTestBase {
|
|||
$this->assertIdentical($enable_order, ['help', 'config', 'color']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninstalling a module that is a "dependency" of a profile.
|
||||
*
|
||||
* Note this test does not trigger the deprecation error because of static
|
||||
* caching in \Drupal\Core\Extension\InfoParser::parse().
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testUninstallProfileDependencyBC() {
|
||||
$profile = 'testing_install_profile_dependencies_bc';
|
||||
$dependency = 'dblog';
|
||||
$this->setInstallProfile($profile);
|
||||
// Prime the drupal_get_filename() static cache with the location of the
|
||||
// testing profile as it is not the currently active profile and we don't
|
||||
// yet have any cached way to retrieve its location.
|
||||
// @todo Remove as part of https://www.drupal.org/node/2186491
|
||||
drupal_get_filename('profile', $profile, 'core/profiles/' . $profile . '/' . $profile . '.info.yml');
|
||||
$this->enableModules(['module_test', $profile]);
|
||||
|
||||
$data = \Drupal::service('extension.list.module')->getList();
|
||||
$this->assertFalse(isset($data[$profile]->requires[$dependency]));
|
||||
$this->assertContains($dependency, $data[$profile]->info['install']);
|
||||
|
||||
$this->moduleInstaller()->install([$dependency]);
|
||||
$this->assertTrue($this->moduleHandler()->moduleExists($dependency));
|
||||
|
||||
// Uninstall the profile module "dependency".
|
||||
$result = $this->moduleInstaller()->uninstall([$dependency]);
|
||||
$this->assertTrue($result, 'ModuleInstaller::uninstall() returns TRUE.');
|
||||
$this->assertFalse($this->moduleHandler()->moduleExists($dependency));
|
||||
$this->assertEqual(drupal_get_installed_schema_version($dependency), SCHEMA_UNINSTALLED, "$dependency module was uninstalled.");
|
||||
|
||||
// Verify that the installation profile itself was not uninstalled.
|
||||
$uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: [];
|
||||
$this->assertTrue(in_array($dependency, $uninstalled_modules), "$dependency module is in the list of uninstalled modules.");
|
||||
$this->assertFalse(in_array($profile, $uninstalled_modules), 'The installation profile is not in the list of uninstalled modules.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninstalling a module installed by a profile.
|
||||
*/
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
name: 'Testing install profile dependencies BC layer'
|
||||
type: profile
|
||||
description: 'Profile for testing BC layer for profile dependencies.'
|
||||
version: VERSION
|
||||
hidden: true
|
||||
dependencies:
|
||||
- dblog
|
||||
- ban
|
||||
themes:
|
||||
- classy
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\FunctionalTests\Installer;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests that an install profile with only dependencies works as expected.
|
||||
*
|
||||
* @group Installer
|
||||
* @group legacy
|
||||
*/
|
||||
class InstallProfileDependenciesBcTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $profile = 'testing_install_profile_dependencies_bc';
|
||||
|
||||
/**
|
||||
* Tests that the install profile BC layer for dependencies key works.
|
||||
*
|
||||
* @expectedDeprecation The install profile core/profiles/testing_install_profile_dependencies_bc/testing_install_profile_dependencies_bc.info.yml only implements a 'dependencies' key. As of Drupal 8.6.0 profile's support a new 'install' key for modules that should be installed but not depended on. See https://www.drupal.org/node/2952947.
|
||||
*/
|
||||
public function testUninstallingModules() {
|
||||
$user = $this->drupalCreateUser(['administer modules']);
|
||||
$this->drupalLogin($user);
|
||||
$this->drupalGet('admin/modules/uninstall');
|
||||
$this->getSession()->getPage()->checkField('uninstall[ban]');
|
||||
$this->getSession()->getPage()->checkField('uninstall[dblog]');
|
||||
$this->click('#edit-submit');
|
||||
// Click the confirm button.
|
||||
$this->click('#edit-submit');
|
||||
$this->assertSession()->responseContains('The selected modules have been uninstalled.');
|
||||
$this->assertSession()->responseContains('No modules are available to uninstall.');
|
||||
// We've uninstalled modules therefore we need to rebuild the container in
|
||||
// the test runner.
|
||||
$this->rebuildContainer();
|
||||
$module_handler = $this->container->get('module_handler');
|
||||
$this->assertFalse($module_handler->moduleExists('ban'));
|
||||
$this->assertFalse($module_handler->moduleExists('dblog'));
|
||||
}
|
||||
|
||||
}
|
|
@ -5,17 +5,18 @@ namespace Drupal\KernelTests\Core\Theme;
|
|||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Extension\ExtensionDiscovery;
|
||||
use Drupal\Core\Extension\InfoParser;
|
||||
use Drupal\Core\Extension\InfoParserException;
|
||||
use Drupal\Core\Extension\InfoParserInterface;
|
||||
use Drupal\Core\Extension\ThemeExtensionList;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
|
||||
/**
|
||||
* Tests the behavior of the Stable theme.
|
||||
* Tests the behavior of a theme when base_theme info key is missing.
|
||||
*
|
||||
* @group Theme
|
||||
*/
|
||||
class BaseThemeDefaultDeprecationTest extends KernelTestBase {
|
||||
class BaseThemeMissingTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -29,13 +30,6 @@ class BaseThemeDefaultDeprecationTest extends KernelTestBase {
|
|||
*/
|
||||
protected $themeInstaller;
|
||||
|
||||
/**
|
||||
* The theme manager.
|
||||
*
|
||||
* @var \Drupal\Core\Theme\ThemeManagerInterface
|
||||
*/
|
||||
protected $themeManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -43,7 +37,6 @@ class BaseThemeDefaultDeprecationTest extends KernelTestBase {
|
|||
parent::setUp();
|
||||
|
||||
$this->themeInstaller = $this->container->get('theme_installer');
|
||||
$this->themeManager = $this->container->get('theme.manager');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,35 +58,25 @@ class BaseThemeDefaultDeprecationTest extends KernelTestBase {
|
|||
$vfs_root = vfsStream::setup('core');
|
||||
vfsStream::create([
|
||||
'themes' => [
|
||||
'test_stable' => [
|
||||
'test_stable.info.yml' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_stable/test_stable.info.yml'),
|
||||
'test_stable.theme' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_stable/test_stable.theme'),
|
||||
],
|
||||
'stable' => [
|
||||
'stable.info.yml' => file_get_contents(DRUPAL_ROOT . '/core/themes/stable/stable.info.yml'),
|
||||
'stable.theme' => file_get_contents(DRUPAL_ROOT . '/core/themes/stable/stable.theme'),
|
||||
'test_missing_base_theme' => [
|
||||
'test_missing_base_theme.info.yml' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.info.yml'),
|
||||
'test_missing_base_theme.theme' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.theme'),
|
||||
],
|
||||
],
|
||||
], $vfs_root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures Stable is used by default when no base theme has been defined.
|
||||
*
|
||||
* @group legacy
|
||||
* @expectedDeprecation There is no `base theme` property specified in the test_stable.info.yml file. The optionality of the `base theme` property is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. All Drupal 8 themes must add `base theme: stable` to their *.info.yml file for them to continue to work as-is in future versions of Drupal. Drupal 9 requires the `base theme` property to be specified. See https://www.drupal.org/node/3066038
|
||||
* Tests exception is thrown.
|
||||
*/
|
||||
public function testStableIsDefault() {
|
||||
public function testMissingBaseThemeException() {
|
||||
$this->container->get('extension.list.theme')
|
||||
->setExtensionDiscovery(new ExtensionDiscovery('vfs://core'))
|
||||
->setInfoParser(new VfsInfoParser('vfs:/'));
|
||||
|
||||
$this->themeInstaller->install(['test_stable']);
|
||||
$this->config('system.theme')->set('default', 'test_stable')->save();
|
||||
$theme = $this->themeManager->getActiveTheme();
|
||||
$base_themes = $theme->getBaseThemeExtensions();
|
||||
$base_theme = reset($base_themes);
|
||||
$this->assertTrue($base_theme->getName() == 'stable', "Stable theme is the base theme if a theme hasn't decided to opt out.");
|
||||
$this->expectException(InfoParserException::class);
|
||||
$this->expectExceptionMessage('Missing required key (base_theme) in themes/test_missing_base_theme/test_missing_base_theme.theme/test_missing_base_theme.theme');
|
||||
$this->themeInstaller->install(['test_missing_base_theme']);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
name: Test Missing Base Theme
|
||||
type: theme
|
||||
description: A theme to test missing base theme.
|
||||
version: VERSION
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Test preprocess functions for theme test_missing_base_theme.
|
||||
*/
|
Loading…
Reference in New Issue