Unverified Commit d8670b96 authored by alexpott's avatar alexpott
Browse files

Issue #3097423 by andypost, longwave: Remove update.module BC layers

parent 267ccab7
<?php
namespace Drupal\update\Tests;
@trigger_error(__NAMESPACE__ . '\UpdateTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\update\Functional\UpdateTestBase', E_USER_DEPRECATED);
use Drupal\Core\DrupalKernel;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\simpletest\WebTestBase;
/**
* Defines some shared functions used by all update tests.
*
* The overarching methodology of these tests is we need to compare a given
* state of installed modules and themes (e.g., version, project grouping,
* timestamps, etc) against a current state of what the release history XML
* files we fetch say is available. We have dummy XML files (in the
* core/modules/update/tests directory) that describe various scenarios of
* what's available for different test projects, and we have dummy .info file
* data (specified via hook_system_info_alter() in the update_test helper
* module) describing what's currently installed. Each test case defines a set
* of projects to install, their current state (via the
* 'update_test_system_info' variable) and the desired available update data
* (via the 'update_test_xml_map' variable), and then performs a series of
* assertions that the report matches our expectations given the specific
* initial state and availability scenario.
*
* @deprecated in drupal:8.?.? and is removed from drupal:9.0.0.
* Use \Drupal\Tests\update\Functional\UpdateTestBase instead.
*/
abstract class UpdateTestBase extends WebTestBase {
protected function setUp() {
parent::setUp();
// Change the root path which Update Manager uses to install and update
// projects to be inside the testing site directory. See
// \Drupal\update\UpdateRootFactory::get() for equivalent changes to the
// test child site.
$request = \Drupal::request();
$update_root = $this->container->get('update.root') . '/' . DrupalKernel::findSitePath($request);
$this->container->set('update.root', $update_root);
\Drupal::setContainer($this->container);
// Create the directories within the root path within which the Update
// Manager will install projects.
foreach (drupal_get_updaters() as $updater_info) {
$updater = $updater_info['class'];
$install_directory = $update_root . '/' . $updater::getRootDirectoryRelativePath();
if (!is_dir($install_directory)) {
mkdir($install_directory);
}
}
}
/**
* Refreshes the update status based on the desired available update scenario.
*
* @param $xml_map
* Array that maps project names to availability scenarios to fetch. The key
* '#all' is used if a project-specific mapping is not defined.
* @param $url
* (optional) A string containing the URL to fetch update data from.
* Defaults to 'update-test'.
*
* @see \Drupal\update_test\Controller\UpdateTestController::updateTest()
*/
protected function refreshUpdateStatus($xml_map, $url = 'update-test') {
// Tell the Update Manager module to fetch from the URL provided by
// update_test module.
$this->config('update.settings')->set('fetch.url', Url::fromUri('base:' . $url, ['absolute' => TRUE])->toString())->save();
// Save the map for UpdateTestController::updateTest() to use.
$this->config('update_test.settings')->set('xml_map', $xml_map)->save();
// Manually check the update status.
$this->drupalGet('admin/reports/updates');
$this->clickLink(t('Check manually'));
}
/**
* Runs a series of assertions that are applicable to all update statuses.
*/
protected function standardTests() {
$this->assertRaw('<h3>' . t('Drupal core') . '</h3>');
$this->assertRaw(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString(), 'Link to the Drupal project appears.');
$this->assertNoText(t('No available releases found'));
}
}
......@@ -91,10 +91,9 @@ class UpdateManager implements UpdateManagerInterface {
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* The theme handler.
* @param \Drupal\Core\Extension\ModuleExtensionList|null $extension_list_module
* The module extension list. This is left optional for BC reasons, but the
* optional usage is deprecated and will become required in Drupal 9.0.0.
* The module extension list.
*/
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, UpdateProcessorInterface $update_processor, TranslationInterface $translation, KeyValueFactoryInterface $key_value_expirable_factory, ThemeHandlerInterface $theme_handler, ModuleExtensionList $extension_list_module = NULL) {
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, UpdateProcessorInterface $update_processor, TranslationInterface $translation, KeyValueFactoryInterface $key_value_expirable_factory, ThemeHandlerInterface $theme_handler, ModuleExtensionList $extension_list_module) {
$this->updateSettings = $config_factory->get('update.settings');
$this->moduleHandler = $module_handler;
$this->updateProcessor = $update_processor;
......@@ -103,10 +102,6 @@ public function __construct(ConfigFactoryInterface $config_factory, ModuleHandle
$this->themeHandler = $theme_handler;
$this->availableReleasesTempStore = $key_value_expirable_factory->get('update_available_releases');
$this->projects = [];
if ($extension_list_module === NULL) {
@trigger_error('Invoking the UpdateManager constructor without the module extension list parameter is deprecated in Drupal 8.8.0 and will no longer be supported in Drupal 9.0.0. The extension list parameter is now required in the ConfigImporter constructor. See https://www.drupal.org/node/2943918', E_USER_DEPRECATED);
$extension_list_module = \Drupal::service('extension.list.module');
}
$this->moduleExtensionList = $extension_list_module;
}
......
......@@ -59,7 +59,7 @@ public function get() {
// than having the tests enable a module which overrides the update root
// factory service) to ensure that the parent site is automatically kept
// clean without relying on test authors to take any explicit steps. See
// also \Drupal\update\Tests\UpdateTestBase::setUp().
// also \Drupal\update\Tests\Functional\UpdateTestBase::setUp().
if (DRUPAL_TEST_IN_CHILD_SITE) {
$kernel = $this->drupalKernel;
$request = $this->requestStack->getCurrentRequest();
......
......@@ -20,98 +20,6 @@
use Drupal\update\UpdateFetcherInterface;
use Drupal\update\UpdateManagerInterface;
// These are internally used constants for this code, do not modify.
/**
* Project is missing security update(s).
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\update\UpdateManagerInterface::NOT_SECURE instead.
*
* @see https://www.drupal.org/node/2831620
*/
const UPDATE_NOT_SECURE = 1;
/**
* Current release has been unpublished and is no longer available.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\update\UpdateManagerInterface::REVOKED instead.
*
* @see https://www.drupal.org/node/2831620
*/
const UPDATE_REVOKED = 2;
/**
* Current release is no longer supported by the project maintainer.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\update\UpdateManagerInterface::NOT_SUPPORTED instead.
*
* @see https://www.drupal.org/node/2831620
*/
const UPDATE_NOT_SUPPORTED = 3;
/**
* Project has a new release available, but it is not a security release.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\update\UpdateManagerInterface::NOT_CURRENT instead.
*
* @see https://www.drupal.org/node/2831620
*/
const UPDATE_NOT_CURRENT = 4;
/**
* Project is up to date.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\update\UpdateManagerInterface::CURRENT instead.
*
* @see https://www.drupal.org/node/2831620
*/
const UPDATE_CURRENT = 5;
/**
* Project's status cannot be checked.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\update\UpdateFetcherInterface::NOT_CHECKED instead.
*
* @see https://www.drupal.org/node/2831620
*/
const UPDATE_NOT_CHECKED = -1;
/**
* No available update data was found for project.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\update\UpdateFetcherInterface::UNKNOWN instead.
*
* @see https://www.drupal.org/node/2831620
*/
const UPDATE_UNKNOWN = -2;
/**
* There was a failure fetching available update data for this project.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\update\UpdateFetcherInterface::NOT_FETCHED instead.
*
* @see https://www.drupal.org/node/2831620
*/
const UPDATE_NOT_FETCHED = -3;
/**
* We need to (re)fetch available update data for this project.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\update\UpdateFetcherInterface::FETCH_PENDING instead.
*
* @see https://www.drupal.org/node/2831620
*/
const UPDATE_FETCH_PENDING = -4;
/**
* Implements hook_help().
*/
......@@ -412,45 +320,6 @@ function update_get_available($refresh = FALSE) {
return $available;
}
/**
* Identifies equivalent security releases with a hardcoded list.
*
* Generally, only the latest minor version of Drupal 8 is supported. However,
* when security fixes are backported to an old branch, and the site owner
* updates to the release containing the backported fix, they should not
* see "Security update required!" again if the only other security releases
* are releases for the same advisories.
*
* @return string[]
* A list of security release numbers that are equivalent to this release
* (i.e. covered by the same advisory), for backported security fixes only.
*
* @internal
*
* @deprecated in drupal:8.6.0 and is removed from drupal:9.0.0. Use the
* 'Insecure' release type tag in update XML provided by Drupal.org to
* determine if releases are insecure.
*/
function _update_equivalent_security_releases() {
trigger_error("_update_equivalent_security_releases() was a temporary fix and will be removed before 9.0.0. Use the 'Insecure' release type tag in update XML provided by Drupal.org to determine if releases are insecure.", E_USER_DEPRECATED);
switch (\Drupal::VERSION) {
case '8.3.8':
return ['8.4.5', '8.5.0-rc1'];
case '8.3.9':
return ['8.4.6', '8.5.1'];
case '8.4.5':
return ['8.5.0-rc1'];
case '8.4.6':
return ['8.5.1'];
case '8.4.7':
return ['8.5.2'];
case '8.4.8':
return ['8.5.3'];
}
return [];
}
/**
* Adds a task to the queue for fetching release history data for a project.
*
......
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