Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023
This commit is contained in:
parent
2720a9ec4b
commit
f3791f1da3
1898 changed files with 54300 additions and 11481 deletions
|
@ -13,6 +13,7 @@ use Drupal\Core\Form\FormBase;
|
|||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Updater\Updater;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Configure update settings for this site.
|
||||
|
@ -27,7 +28,7 @@ class UpdateManagerInstall extends FormBase {
|
|||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* The app root.
|
||||
* The root location under which installed projects will be saved.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
@ -44,7 +45,7 @@ class UpdateManagerInstall extends FormBase {
|
|||
* Constructs a new UpdateManagerInstall.
|
||||
*
|
||||
* @param string $root
|
||||
* The app root.
|
||||
* The root location under which installed projects will be saved.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler.
|
||||
* @param string $site_path
|
||||
|
@ -68,7 +69,7 @@ class UpdateManagerInstall extends FormBase {
|
|||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('app.root'),
|
||||
$container->get('update.root'),
|
||||
$container->get('module_handler'),
|
||||
$container->get('site.path')
|
||||
);
|
||||
|
@ -192,7 +193,7 @@ class UpdateManagerInstall extends FormBase {
|
|||
|
||||
$project_location = $directory . '/' . $project;
|
||||
try {
|
||||
$updater = Updater::factory($project_location);
|
||||
$updater = Updater::factory($project_location, $this->root);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
drupal_set_message($e->getMessage(), 'error');
|
||||
|
@ -231,13 +232,19 @@ class UpdateManagerInstall extends FormBase {
|
|||
if (fileowner($project_real_location) == fileowner($this->sitePath)) {
|
||||
$this->moduleHandler->loadInclude('update', 'inc', 'update.authorize');
|
||||
$filetransfer = new Local($this->root);
|
||||
call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments));
|
||||
$response = call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments));
|
||||
if ($response instanceof Response) {
|
||||
$form_state->setResponse($response);
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, go through the regular workflow to prompt for FTP/SSH
|
||||
// credentials and invoke update_authorize_run_install() indirectly with
|
||||
// whatever FileTransfer object authorize.php creates for us.
|
||||
else {
|
||||
// The page title must be passed here to ensure it is initially used when
|
||||
// authorize.php loads for the first time with the FTP/SSH credentials
|
||||
// form.
|
||||
system_authorized_init('update_authorize_run_install', drupal_get_path('module', 'update') . '/update.authorize.inc', $arguments, $this->t('Update manager'));
|
||||
$form_state->setRedirectUrl(system_authorized_get_url());
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\update\Form;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
@ -115,14 +114,14 @@ class UpdateManagerUpdate extends FormBase {
|
|||
$project_name = $this->l($project['title'], Url::fromUri($project['link']));
|
||||
}
|
||||
else {
|
||||
$project_name = SafeMarkup::checkPlain($project['title']);
|
||||
$project_name = $project['title'];
|
||||
}
|
||||
}
|
||||
elseif (!empty($project['info']['name'])) {
|
||||
$project_name = SafeMarkup::checkPlain($project['info']['name']);
|
||||
$project_name = $project['info']['name'];
|
||||
}
|
||||
else {
|
||||
$project_name = SafeMarkup::checkPlain($name);
|
||||
$project_name = $name;
|
||||
}
|
||||
if ($project['project_type'] == 'theme' || $project['project_type'] == 'theme-disabled') {
|
||||
$project_name .= ' ' . $this->t('(Theme)');
|
||||
|
|
|
@ -14,6 +14,7 @@ use Drupal\Core\Form\FormStateInterface;
|
|||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\Core\Updater\Updater;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Configure update settings for this site.
|
||||
|
@ -21,7 +22,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
class UpdateReady extends FormBase {
|
||||
|
||||
/**
|
||||
* The app root.
|
||||
* The root location under which updated projects will be saved.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
@ -52,7 +53,7 @@ class UpdateReady extends FormBase {
|
|||
* Constructs a new UpdateReady object.
|
||||
*
|
||||
* @param string $root
|
||||
* The app root.
|
||||
* The root location under which updated projects will be saved.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The object that manages enabled modules in a Drupal installation.
|
||||
* @param \Drupal\Core\State\StateInterface $state
|
||||
|
@ -79,7 +80,7 @@ class UpdateReady extends FormBase {
|
|||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('app.root'),
|
||||
$container->get('update.root'),
|
||||
$container->get('module_handler'),
|
||||
$container->get('state'),
|
||||
$container->get('site.path')
|
||||
|
@ -139,7 +140,7 @@ class UpdateReady extends FormBase {
|
|||
$project_real_location = NULL;
|
||||
foreach ($projects as $project => $url) {
|
||||
$project_location = $directory . '/' . $project;
|
||||
$updater = Updater::factory($project_location);
|
||||
$updater = Updater::factory($project_location, $this->root);
|
||||
$project_real_location = drupal_realpath($project_location);
|
||||
$updates[] = array(
|
||||
'project' => $project,
|
||||
|
@ -156,12 +157,18 @@ class UpdateReady extends FormBase {
|
|||
if (fileowner($project_real_location) == fileowner($this->sitePath)) {
|
||||
$this->moduleHandler->loadInclude('update', 'inc', 'update.authorize');
|
||||
$filetransfer = new Local($this->root);
|
||||
update_authorize_run_update($filetransfer, $updates);
|
||||
$response = update_authorize_run_update($filetransfer, $updates);
|
||||
if ($response instanceof Response) {
|
||||
$form_state->setResponse($response);
|
||||
}
|
||||
}
|
||||
// Otherwise, go through the regular workflow to prompt for FTP/SSH
|
||||
// credentials and invoke update_authorize_run_update() indirectly with
|
||||
// whatever FileTransfer object authorize.php creates for us.
|
||||
else {
|
||||
// The page title must be passed here to ensure it is initially used
|
||||
// when authorize.php loads for the first time with the FTP/SSH
|
||||
// credentials form.
|
||||
system_authorized_init('update_authorize_run_update', drupal_get_path('module', 'update') . '/update.authorize.inc', array($updates), $this->t('Update manager'));
|
||||
$form_state->setRedirectUrl(system_authorized_get_url());
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
|||
/**
|
||||
* Upgrade variables to update.settings.yml.
|
||||
*
|
||||
* @group update
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateUpdateConfigsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
|
@ -31,7 +31,6 @@ class MigrateUpdateConfigsTest extends MigrateDrupal6TestBase {
|
|||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->loadDumps(['Variable.php']);
|
||||
$this->executeMigration('d6_update_settings');
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ class UpdateContribTest extends UpdateTestBase {
|
|||
* Tests the basic functionality of a contrib module on the status report.
|
||||
*/
|
||||
function testUpdateContribBasic() {
|
||||
$project_link = \Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'));
|
||||
$system_info = array(
|
||||
'#all' => array(
|
||||
'version' => '8.0.0',
|
||||
|
@ -87,7 +88,30 @@ class UpdateContribTest extends UpdateTestBase {
|
|||
$this->assertText(t('Up to date'));
|
||||
$this->assertRaw('<h3>' . t('Modules') . '</h3>');
|
||||
$this->assertNoText(t('Update available'));
|
||||
$this->assertRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project appears.');
|
||||
$this->assertRaw($project_link, 'Link to aaa_update_test project appears.');
|
||||
|
||||
// Since aaa_update_test is installed the fact it is hidden and in the
|
||||
// Testing package means it should not appear.
|
||||
$system_info['aaa_update_test']['hidden'] = TRUE;
|
||||
$this->config('update_test.settings')->set('system_info', $system_info)->save();
|
||||
$this->refreshUpdateStatus(
|
||||
array(
|
||||
'drupal' => '0.0',
|
||||
'aaa_update_test' => '1_0',
|
||||
)
|
||||
);
|
||||
$this->assertNoRaw($project_link, 'Link to aaa_update_test project does not appear.');
|
||||
|
||||
// A hidden and installed project not in the Testing package should appear.
|
||||
$system_info['aaa_update_test']['package'] = 'aaa_update_test';
|
||||
$this->config('update_test.settings')->set('system_info', $system_info)->save();
|
||||
$this->refreshUpdateStatus(
|
||||
array(
|
||||
'drupal' => '0.0',
|
||||
'aaa_update_test' => '1_0',
|
||||
)
|
||||
);
|
||||
$this->assertRaw($project_link, 'Link to aaa_update_test project appears.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,12 +22,13 @@ class UpdateCoreTest extends UpdateTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('update_test', 'update', 'language');
|
||||
public static $modules = ['update_test', 'update', 'language', 'block'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer modules', 'administer themes'));
|
||||
$this->drupalLogin($admin_user);
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
namespace Drupal\update\Tests;
|
||||
|
||||
use Drupal\Core\DrupalKernel;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
|
@ -29,6 +30,29 @@ use Drupal\simpletest\WebTestBase;
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\update\Tests;
|
||||
|
||||
use Drupal\Core\Extension\InfoParserDynamic;
|
||||
use Drupal\Core\Updater\Updater;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
|
@ -26,12 +27,12 @@ class UpdateUploadTest extends UpdateTestBase {
|
|||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$admin_user = $this->drupalCreateUser(array('administer software updates', 'administer site configuration'));
|
||||
$admin_user = $this->drupalCreateUser(array('administer modules', 'administer software updates', 'administer site configuration'));
|
||||
$this->drupalLogin($admin_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests upload and extraction of a module.
|
||||
* Tests upload, extraction, and update of a module.
|
||||
*/
|
||||
public function testUploadModule() {
|
||||
// Images are not valid archives, so get one and try to install it. We
|
||||
|
@ -46,6 +47,7 @@ class UpdateUploadTest extends UpdateTestBase {
|
|||
// This also checks that the correct archive extensions are allowed.
|
||||
$this->drupalPostForm('admin/modules/install', $edit, t('Install'));
|
||||
$this->assertText(t('Only files with the following extensions are allowed: @archive_extensions.', array('@archive_extensions' => archiver_get_extensions())),'Only valid archives can be uploaded.');
|
||||
$this->assertUrl('admin/modules/install');
|
||||
|
||||
// Check to ensure an existing module can't be reinstalled. Also checks that
|
||||
// the archive was extracted since we can't know if the module is already
|
||||
|
@ -56,6 +58,74 @@ class UpdateUploadTest extends UpdateTestBase {
|
|||
);
|
||||
$this->drupalPostForm('admin/modules/install', $edit, t('Install'));
|
||||
$this->assertText(t('@module_name is already installed.', array('@module_name' => 'AAA Update test')), 'Existing module was extracted and not reinstalled.');
|
||||
$this->assertUrl('admin/modules/install');
|
||||
|
||||
// Ensure that a new module can be extracted and installed.
|
||||
$updaters = drupal_get_updaters();
|
||||
$moduleUpdater = $updaters['module']['class'];
|
||||
$installedInfoFilePath = $this->container->get('update.root') . '/' . $moduleUpdater::getRootDirectoryRelativePath() . '/update_test_new_module/update_test_new_module.info.yml';
|
||||
$this->assertFalse(file_exists($installedInfoFilePath), 'The new module does not exist in the filesystem before it is installed with the Update Manager.');
|
||||
$validArchiveFile = drupal_get_path('module', 'update') . '/tests/update_test_new_module/8.x-1.0/update_test_new_module.tar.gz';
|
||||
$edit = array(
|
||||
'files[project_upload]' => $validArchiveFile,
|
||||
);
|
||||
$this->drupalPostForm('admin/modules/install', $edit, t('Install'));
|
||||
// Check that submitting the form takes the user to authorize.php.
|
||||
$this->assertUrl('core/authorize.php');
|
||||
$this->assertTitle('Update manager | Drupal');
|
||||
// Check for a success message on the page, and check that the installed
|
||||
// module now exists in the expected place in the filesystem.
|
||||
$this->assertRaw(t('Installed %project_name successfully', array('%project_name' => 'update_test_new_module')));
|
||||
$this->assertTrue(file_exists($installedInfoFilePath), 'The new module exists in the filesystem after it is installed with the Update Manager.');
|
||||
// Ensure the links are relative to the site root and not
|
||||
// core/authorize.php.
|
||||
$this->assertLink(t('Install another module'));
|
||||
$this->assertLinkByHref(Url::fromRoute('update.module_install')->toString());
|
||||
$this->assertLink(t('Enable newly added modules'));
|
||||
$this->assertLinkByHref(Url::fromRoute('system.modules_list')->toString());
|
||||
$this->assertLink(t('Administration pages'));
|
||||
$this->assertLinkByHref(Url::fromRoute('system.admin')->toString());
|
||||
// Ensure we can reach the "Install another module" link.
|
||||
$this->clickLink(t('Install another module'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl('admin/modules/install');
|
||||
|
||||
// Check that the module has the correct version before trying to update
|
||||
// it. Since the module is installed in sites/simpletest, which only the
|
||||
// child site has access to, standard module API functions won't find it
|
||||
// when called here. To get the version, the info file must be parsed
|
||||
// directly instead.
|
||||
$info_parser = new InfoParserDynamic();
|
||||
$info = $info_parser->parse($installedInfoFilePath);
|
||||
$this->assertEqual($info['version'], '8.x-1.0');
|
||||
|
||||
// Enable the module.
|
||||
$this->drupalPostForm('admin/modules', array('modules[Testing][update_test_new_module][enable]' => TRUE), t('Install'));
|
||||
|
||||
// Define the update XML such that the new module downloaded above needs an
|
||||
// update from 8.x-1.0 to 8.x-1.1.
|
||||
$update_test_config = $this->config('update_test.settings');
|
||||
$system_info = array(
|
||||
'update_test_new_module' => array(
|
||||
'project' => 'update_test_new_module',
|
||||
),
|
||||
);
|
||||
$update_test_config->set('system_info', $system_info)->save();
|
||||
$xml_mapping = array(
|
||||
'update_test_new_module' => '1_1',
|
||||
);
|
||||
$this->refreshUpdateStatus($xml_mapping);
|
||||
|
||||
// Run the updates for the new module.
|
||||
$this->drupalPostForm('admin/reports/updates/update', array('projects[update_test_new_module]' => TRUE), t('Download these updates'));
|
||||
$this->drupalPostForm(NULL, array('maintenance_mode' => FALSE), t('Continue'));
|
||||
$this->assertText(t('Update was completed successfully.'));
|
||||
$this->assertRaw(t('Installed %project_name successfully', array('%project_name' => 'update_test_new_module')));
|
||||
|
||||
// Parse the info file again to check that the module has been updated to
|
||||
// 8.x-1.1.
|
||||
$info = $info_parser->parse($installedInfoFilePath);
|
||||
$this->assertEqual($info['version'], '8.x-1.1');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,10 +51,6 @@ interface UpdateManagerInterface {
|
|||
* 'theme'.
|
||||
* - project_status: This indicates if the project is enabled and will
|
||||
* always be TRUE, as the function only returns enabled projects.
|
||||
* - sub_themes: If the project is a theme it contains an associative array
|
||||
* of all sub-themes.
|
||||
* - base_themes: If the project is a theme it contains an associative array
|
||||
* of all base-themes.
|
||||
*
|
||||
* @see update_process_project_info()
|
||||
* @see update_calculate_project_data()
|
||||
|
|
77
core/modules/update/src/UpdateRootFactory.php
Normal file
77
core/modules/update/src/UpdateRootFactory.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\update\UpdateRootFactory.
|
||||
*/
|
||||
|
||||
namespace Drupal\update;
|
||||
|
||||
use Drupal\Core\DrupalKernelInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* Gets the root path used by the Update Manager to install or update projects.
|
||||
*/
|
||||
class UpdateRootFactory {
|
||||
|
||||
/**
|
||||
* The Drupal kernel.
|
||||
*
|
||||
* @var \Drupal\Core\DrupalKernelInterface
|
||||
*/
|
||||
protected $drupalKernel;
|
||||
|
||||
/**
|
||||
* The request stack.
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\RequestStack
|
||||
*/
|
||||
protected $requestStack;
|
||||
|
||||
/**
|
||||
* Constructs an UpdateRootFactory instance.
|
||||
*
|
||||
* @param \Drupal\Core\DrupalKernelInterface $drupal_kernel
|
||||
* The Drupal kernel.
|
||||
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
|
||||
* The request stack.
|
||||
*/
|
||||
public function __construct(DrupalKernelInterface $drupal_kernel, RequestStack $request_stack) {
|
||||
$this->drupalKernel = $drupal_kernel;
|
||||
$this->requestStack = $request_stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the root path under which projects are installed or updated.
|
||||
*
|
||||
* The Update Manager will ensure that project files can only be copied to
|
||||
* specific subdirectories of this root path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get() {
|
||||
// Normally the Update Manager's root path is the same as the app root (the
|
||||
// directory in which the Drupal site is installed).
|
||||
$root_path = $this->drupalKernel->getAppRoot();
|
||||
|
||||
// When running in a test site, change the root path to be the testing site
|
||||
// directory. This ensures that it will always be writable by the webserver
|
||||
// (thereby allowing the actual extraction and installation of projects by
|
||||
// the Update Manager to be tested) and also ensures that new project files
|
||||
// added there won't be visible to the parent site and will be properly
|
||||
// cleaned up once the test finishes running. This is done here (rather
|
||||
// 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().
|
||||
if (DRUPAL_TEST_IN_CHILD_SITE) {
|
||||
$kernel = $this->drupalKernel;
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
$root_path .= '/' . $kernel::findSitePath($request);
|
||||
}
|
||||
|
||||
return $root_path;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue