diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index 95dd5a8..d02485a 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -1092,8 +1092,8 @@ public function getName($module) { /** * {@inheritdoc} */ - public function invalidCore($core) { - return substr(\Drupal::CORE_COMPATIBILITY, 0, 1) != substr($core, 0, 1) || version_compare(\Drupal::VERSION, $core, '<'); + public function isCoreCompatible($core) { + return substr(\Drupal::CORE_COMPATIBILITY, 0, 1) == substr($core, 0, 1) && !version_compare(\Drupal::VERSION, $core, '<'); } /** diff --git a/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php b/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php index 15b07a5..6cd03f2 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php @@ -360,12 +360,12 @@ public function getName($theme); /** * Check a module's core compatibility * - * @param $core + * @param string $core * The value of the core key in a module .info.yml file. * * @return bool - * TRUE if invalid or incompatible, FALSE otherwise. + * FALSE if invalid or incompatible, TRUE otherwise. */ - public function invalidCore($core); + public function isCoreCompatible($core); } diff --git a/core/modules/system/src/Controller/SystemController.php b/core/modules/system/src/Controller/SystemController.php index 22bade6..d21674f 100644 --- a/core/modules/system/src/Controller/SystemController.php +++ b/core/modules/system/src/Controller/SystemController.php @@ -230,7 +230,7 @@ public function themesPage() { // Ensure this theme is compatible with this version of core. // Require the 'content' region to make sure the main page // content has a common place in all themes. - $theme->incompatible_core = !isset($theme->info['core']) || ($theme->info['core'] != \DRUPAL::CORE_COMPATIBILITY) || !isset($theme->info['regions']['content']); + $theme->incompatible_core = !isset($theme->info['core']) || !$this->moduleHandler()->isCoreCompatible($theme->info['core']) || !isset($theme->info['regions']['content']); $theme->incompatible_php = version_compare(phpversion(), $theme->info['php']) < 0; // Confirmed that the base theme is available. $theme->incompatible_base = isset($theme->info['base theme']) && !isset($themes[$theme->info['base theme']]); diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php index 2830a40..c458f92 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -336,7 +336,7 @@ protected function buildRow(array $modules, Extension $module, $distribution) { $reasons = array(); // Check the core compatibility. - if ($this->moduleHandler->invalidCore($module->info['core'])) { + if (!$this->moduleHandler->isCoreCompatible($module->info['core'])) { $compatible = FALSE; $reasons[] = $this->t('This version is not compatible with Drupal !core_version and should be replaced.', array( '!core_version' => \Drupal::VERSION, @@ -381,7 +381,7 @@ protected function buildRow(array $modules, Extension $module, $distribution) { } // Disable the checkbox if the dependency is incompatible with this // version of Drupal core. - elseif ($this->moduleHandler->invalidCore($modules[$dependency]->info['core'])) { + elseif (!$this->moduleHandler->isCoreCompatible($modules[$dependency]->info['core'])) { $row['#requires'][$dependency] = $this->t('@module (incompatible with this version of Drupal core)', array( '@module' => $name, )); diff --git a/core/modules/system/tests/modules/system_test/system_test.module.orig b/core/modules/system/tests/modules/system_test/system_test.module.orig deleted file mode 100644 index 8024680..0000000 --- a/core/modules/system/tests/modules/system_test/system_test.module.orig +++ /dev/null @@ -1,192 +0,0 @@ -get('system_test.verbose_module_hooks')) { - foreach ($modules as $module) { - drupal_set_message(t('hook_modules_installed fired for @module', array('@module' => $module))); - } - } -} - -/** - * Implements hook_modules_uninstalled(). - */ -function system_test_modules_uninstalled($modules) { - if (\Drupal::state()->get('system_test.verbose_module_hooks')) { - foreach ($modules as $module) { - drupal_set_message(t('hook_modules_uninstalled fired for @module', array('@module' => $module))); - } - } -} - -/** - * Implements hook_system_info_alter(). - */ -function system_test_system_info_alter(&$info, Extension $file, $type) { - // We need a static otherwise the last test will fail to alter common_test. - static $test; - if (($dependencies = \Drupal::state()->get('system_test.dependencies')) || $test) { - if ($file->getName() == 'module_test') { - $info['hidden'] = FALSE; - $info['dependencies'][] = array_shift($dependencies); - \Drupal::state()->set('system_test.dependencies', $dependencies); - $test = TRUE; - } - if ($file->getName() == 'common_test') { - $info['hidden'] = FALSE; - $info['version'] = '8.x-2.4-beta3'; - } - } - - // Make the system_dependencies_test visible by default. - if ($file->getName() == 'system_dependencies_test') { - $info['hidden'] = FALSE; - } - if (in_array($file->getName(), array( - 'system_incompatible_module_version_dependencies_test', - 'system_incompatible_core_version_dependencies_test', - 'system_incompatible_module_version_test', - 'system_incompatible_core_version_test', - ))) { - $info['hidden'] = FALSE; - } - if ($file->getName() == 'requirements1_test' || $file->getName() == 'requirements2_test') { - $info['hidden'] = FALSE; - } - if ($file->getName() == 'system_test') { - $info['hidden'] = \Drupal::state()->get('system_test.module_hidden', TRUE); - } -} - -/** - * Try to acquire a named lock and report the outcome. - * - * @deprecated \Drupal\system_test\Controller\SystemTestController::lockAcquire() - */ -function system_test_lock_acquire() { - if (\Drupal::lock()->acquire('system_test_lock_acquire')) { - \Drupal::lock()->release('system_test_lock_acquire'); - return ['#markup' => 'TRUE: Lock successfully acquired in system_test_lock_acquire()']; - } - else { - return ['#markup' => 'FALSE: Lock not acquired in system_test_lock_acquire()']; - } -} - -/** - * Try to acquire a specific lock, and then exit. - * - * @deprecated \Drupal\system_test\Controller\SystemTestController::lockExit() - */ -function system_test_lock_exit() { - if (\Drupal::lock()->acquire('system_test_lock_exit', 900)) { - echo 'TRUE: Lock successfully acquired in system_test_lock_exit()'; - // The shut-down function should release the lock. - exit(); - } - else { - return ['#markup' => 'FALSE: Lock not acquired in system_test_lock_exit()']; - } -} - -/** - * Implements hook_page_attachments(). - */ -function system_test_page_attachments(array &$page) { - $menu_item['path'] = current_path(); - $main_content_display = &drupal_static('system_main_content_added', FALSE); - - if ($menu_item['path'] == 'system-test/main-content-fallback') { - // Get the main content, to e.g. dynamically attach an asset. - drupal_set_page_content(); - // Indicate we don't want to override the main content. - $main_content_display = FALSE; - } - elseif ($menu_item['path'] == 'system-test/main-content-handling') { - // Set the main content. - drupal_set_page_content('
Overridden!
'); - } - // Used by FrontPageTestCase to get the results of drupal_is_front_page(). - $frontpage = \Drupal::state()->get('system_test.front_page_output') ?: 0; - if ($frontpage && drupal_is_front_page()) { - drupal_set_message(t('On front page.')); - } -} - -/** - * A simple page callback which adds a register shutdown function. - * - * @deprecated \Drupal\system_test\Controller\SystemTestController::shutdownFunctions() - */ -function system_test_page_shutdown_functions($arg1, $arg2) { - drupal_register_shutdown_function('_system_test_first_shutdown_function', $arg1, $arg2); -} - -/** - * Dummy shutdown function which registers another shutdown function. - */ -function _system_test_first_shutdown_function($arg1, $arg2) { - // Set something to ensure that this function got called. - \Drupal::state()->set('_system_test_first_shutdown_function', array($arg1, $arg2)); - drupal_register_shutdown_function('_system_test_second_shutdown_function', $arg1, $arg2); -} - -/** - * Dummy shutdown function. - */ -function _system_test_second_shutdown_function($arg1, $arg2) { - // Set something to ensure that this function got called. - \Drupal::state()->set('_system_test_second_shutdown_function', array($arg1, $arg2)); - - // Throw an exception with an HTML tag. Since this is called in a shutdown - // function, it will not bubble up to the default exception handler but will - // be caught in _drupal_shutdown_function() and be displayed through - // \Drupal\Core\Utility\Error::renderExceptionSafe() if possible. - throw new Exception('Drupal is awesome.'); -} - -/** - * Implements hook_filetransfer_info(). - */ -function system_test_filetransfer_info() { - return array( - 'system_test' => array( - 'title' => t('System Test FileTransfer'), - 'class' => 'Drupal\system_test\MockFileTransfer', - 'weight' => -10, - ), - ); -} - -/** - * Page callback to initialize authorize.php during testing. - * - * @see system_authorized_init(). - * - * @deprecated \Drupal\system_test\Controller\SystemTestController::authorizeInit() - */ -function system_test_authorize_init_page($page_title) { - $authorize_url = $GLOBALS['base_url'] . '/core/authorize.php'; - system_authorized_init('system_test_authorize_run', drupal_get_path('module', 'system_test') . '/system_test.module', array(), $page_title); - return new RedirectResponse($authorize_url); -} - -/** - * Implements hook_module_preinstall(). - */ -function system_test_module_preinstall($module) { - \Drupal::state()->set('system_test_preinstall_module', $module); -} - -/** - * Implements hook_module_preuninstall(). - */ -function system_test_module_preuninstall($module) { - \Drupal::state()->set('system_test_preuninstall_module', $module); -} diff --git a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php index 620e37d..7695646 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php @@ -10,6 +10,7 @@ use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ModuleHandler; use Drupal\Tests\UnitTestCase; +use Symfony\Component\Validator\Constraints\False; /** * @coversDefaultClass \Drupal\Core\Extension\ModuleHandler @@ -516,11 +517,11 @@ public function testGetModuleDirectories() { } /** - * @dataProvider providerInvalidCore - * @covers ::invalidCore + * @dataProvider providerIsCoreCompatible + * @covers ::isCoreCompatible */ - public function testInvalidCore($version, $incompatible) { - $this->assertEquals($this->moduleHandler->invalidCore($version), $incompatible); + public function testIsCoreCompatible($version, $compatible) { + $this->assertEquals($compatible, $this->moduleHandler->isCoreCompatible($version)); } /** @@ -529,7 +530,7 @@ public function testInvalidCore($version, $incompatible) { * @return array * An array of versions and whether they should be valid. */ - public function providerInvalidCore() { + public function providerIsCoreCompatible() { $current = \Drupal::VERSION; list($major, $minor) = explode('.', $current); @@ -538,16 +539,16 @@ public function providerInvalidCore() { $newer = $major + 1; $newer_minor = $major . '.' . ($minor + 1); - // Core version => invalid. + // Core version => valid. $versions = array( // Invalid. - "{$older}.x" => TRUE, - "{$older}.24" => TRUE, - "{$newer_minor}.x" => TRUE, - "{$newer}.0.x" => TRUE, + array("{$older}.x", FALSE), + array("{$older}.24", FALSE), + array("{$newer_minor}.x", FALSE), + array("{$newer}.0.x", FALSE), // Valid. - "{$major}.x" => FALSE, - "{$major}.{$minor}.x" => FALSE, + array("{$major}.x", TRUE), + array("{$major}.{$minor}.x", TRUE), ); return $versions;