updated core and modules
This commit is contained in:
@@ -44,9 +44,9 @@ class UpdateController extends ControllerBase {
|
||||
* A build array with the update status of projects.
|
||||
*/
|
||||
public function updateStatus() {
|
||||
$build = array(
|
||||
$build = [
|
||||
'#theme' => 'update_report'
|
||||
);
|
||||
];
|
||||
if ($available = update_get_available(TRUE)) {
|
||||
$this->moduleHandler()->loadInclude('update', 'compare.inc');
|
||||
$build['#data'] = update_calculate_project_data($available);
|
||||
@@ -59,15 +59,15 @@ class UpdateController extends ControllerBase {
|
||||
*/
|
||||
public function updateStatusManually() {
|
||||
$this->updateManager->refreshUpdateData();
|
||||
$batch = array(
|
||||
'operations' => array(
|
||||
array(array($this->updateManager, 'fetchDataBatch'), array()),
|
||||
),
|
||||
$batch = [
|
||||
'operations' => [
|
||||
[[$this->updateManager, 'fetchDataBatch'], []],
|
||||
],
|
||||
'finished' => 'update_fetch_data_finished',
|
||||
'title' => t('Checking available update data'),
|
||||
'progress_message' => t('Trying to check available update data ...'),
|
||||
'error_message' => t('Error checking available update data.'),
|
||||
);
|
||||
];
|
||||
batch_set($batch);
|
||||
return batch_process('admin/reports/updates');
|
||||
}
|
||||
|
||||
@@ -79,41 +79,41 @@ class UpdateManagerInstall extends FormBase {
|
||||
return $form;
|
||||
}
|
||||
|
||||
$form['help_text'] = array(
|
||||
$form['help_text'] = [
|
||||
'#prefix' => '<p>',
|
||||
'#markup' => $this->t('You can find <a href=":module_url">modules</a> and <a href=":theme_url">themes</a> on <a href=":drupal_org_url">drupal.org</a>. The following file extensions are supported: %extensions.', array(
|
||||
'#markup' => $this->t('You can find <a href=":module_url">modules</a> and <a href=":theme_url">themes</a> on <a href=":drupal_org_url">drupal.org</a>. The following file extensions are supported: %extensions.', [
|
||||
':module_url' => 'https://www.drupal.org/project/modules',
|
||||
':theme_url' => 'https://www.drupal.org/project/themes',
|
||||
':drupal_org_url' => 'https://www.drupal.org',
|
||||
'%extensions' => archiver_get_extensions(),
|
||||
)),
|
||||
]),
|
||||
'#suffix' => '</p>',
|
||||
);
|
||||
];
|
||||
|
||||
$form['project_url'] = array(
|
||||
$form['project_url'] = [
|
||||
'#type' => 'url',
|
||||
'#title' => $this->t('Install from a URL'),
|
||||
'#description' => $this->t('For example: %url', array('%url' => 'http://ftp.drupal.org/files/projects/name.tar.gz')),
|
||||
);
|
||||
'#description' => $this->t('For example: %url', ['%url' => 'http://ftp.drupal.org/files/projects/name.tar.gz']),
|
||||
];
|
||||
|
||||
$form['information'] = array(
|
||||
$form['information'] = [
|
||||
'#prefix' => '<strong>',
|
||||
'#markup' => $this->t('Or'),
|
||||
'#suffix' => '</strong>',
|
||||
);
|
||||
];
|
||||
|
||||
$form['project_upload'] = array(
|
||||
$form['project_upload'] = [
|
||||
'#type' => 'file',
|
||||
'#title' => $this->t('Upload a module or theme archive to install'),
|
||||
'#description' => $this->t('For example: %filename from your local computer', array('%filename' => 'name.tar.gz')),
|
||||
);
|
||||
'#description' => $this->t('For example: %filename from your local computer', ['%filename' => 'name.tar.gz']),
|
||||
];
|
||||
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
$form['actions'] = ['#type' => 'actions'];
|
||||
$form['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#button_type' => 'primary',
|
||||
'#value' => $this->t('Install'),
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -136,12 +136,12 @@ class UpdateManagerInstall extends FormBase {
|
||||
if ($form_state->getValue('project_url')) {
|
||||
$local_cache = update_manager_file_get($form_state->getValue('project_url'));
|
||||
if (!$local_cache) {
|
||||
drupal_set_message($this->t('Unable to retrieve Drupal project from %url.', array('%url' => $form_state->getValue('project_url'))), 'error');
|
||||
drupal_set_message($this->t('Unable to retrieve Drupal project from %url.', ['%url' => $form_state->getValue('project_url')]), 'error');
|
||||
return;
|
||||
}
|
||||
}
|
||||
elseif ($_FILES['files']['name']['project_upload']) {
|
||||
$validators = array('file_validate_extensions' => array(archiver_get_extensions()));
|
||||
$validators = ['file_validate_extensions' => [archiver_get_extensions()]];
|
||||
if (!($finfo = file_save_upload('project_upload', $validators, NULL, 0, FILE_EXISTS_REPLACE))) {
|
||||
// Failed to upload the file. file_save_upload() calls
|
||||
// drupal_set_message() on failure.
|
||||
@@ -170,7 +170,7 @@ class UpdateManagerInstall extends FormBase {
|
||||
// MODULE/) and others list an actual file (i.e., MODULE/README.TXT).
|
||||
$project = strtok($files[0], '/\\');
|
||||
|
||||
$archive_errors = $this->moduleHandler->invokeAll('verify_update_archive', array($project, $local_cache, $directory));
|
||||
$archive_errors = $this->moduleHandler->invokeAll('verify_update_archive', [$project, $local_cache, $directory]);
|
||||
if (!empty($archive_errors)) {
|
||||
drupal_set_message(array_shift($archive_errors), 'error');
|
||||
// @todo: Fix me in D8: We need a way to set multiple errors on the same
|
||||
@@ -204,20 +204,20 @@ class UpdateManagerInstall extends FormBase {
|
||||
}
|
||||
|
||||
if (!$project_title) {
|
||||
drupal_set_message($this->t('Unable to determine %project name.', array('%project' => $project)), 'error');
|
||||
drupal_set_message($this->t('Unable to determine %project name.', ['%project' => $project]), 'error');
|
||||
}
|
||||
|
||||
if ($updater->isInstalled()) {
|
||||
drupal_set_message($this->t('%project is already installed.', array('%project' => $project_title)), 'error');
|
||||
drupal_set_message($this->t('%project is already installed.', ['%project' => $project_title]), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
$project_real_location = drupal_realpath($project_location);
|
||||
$arguments = array(
|
||||
$arguments = [
|
||||
'project' => $project,
|
||||
'updater_name' => get_class($updater),
|
||||
'local_url' => $project_real_location,
|
||||
);
|
||||
];
|
||||
|
||||
// This process is inherently difficult to test therefore use a state flag.
|
||||
$test_authorize = FALSE;
|
||||
@@ -232,7 +232,7 @@ class UpdateManagerInstall extends FormBase {
|
||||
if (fileowner($project_real_location) == fileowner($this->sitePath) && !$test_authorize) {
|
||||
$this->moduleHandler->loadInclude('update', 'inc', 'update.authorize');
|
||||
$filetransfer = new Local($this->root);
|
||||
$response = call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments));
|
||||
$response = call_user_func_array('update_authorize_run_install', array_merge([$filetransfer], $arguments));
|
||||
if ($response instanceof Response) {
|
||||
$form_state->setResponse($response);
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ class UpdateManagerUpdate extends FormBase {
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$this->moduleHandler->loadInclude('update', 'inc', 'update.manager');
|
||||
|
||||
$last_markup = array(
|
||||
$last_markup = [
|
||||
'#theme' => 'update_last_check',
|
||||
'#last' => $this->state->get('update.last_check') ?: 0,
|
||||
);
|
||||
$form['last_check'] = array(
|
||||
];
|
||||
$form['last_check'] = [
|
||||
'#markup' => drupal_render($last_markup),
|
||||
);
|
||||
];
|
||||
|
||||
if (!_update_manager_check_backends($form, 'update')) {
|
||||
return $form;
|
||||
@@ -78,9 +78,9 @@ class UpdateManagerUpdate extends FormBase {
|
||||
|
||||
$available = update_get_available(TRUE);
|
||||
if (empty($available)) {
|
||||
$form['message'] = array(
|
||||
$form['message'] = [
|
||||
'#markup' => $this->t('There was a problem getting update information. Try again later.'),
|
||||
);
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -91,11 +91,11 @@ class UpdateManagerUpdate extends FormBase {
|
||||
// manual updates, such as core). Then, each subarray is an array of
|
||||
// projects of that type, indexed by project short name, and containing an
|
||||
// array of data for cells in that project's row in the appropriate table.
|
||||
$projects = array();
|
||||
$projects = [];
|
||||
|
||||
// This stores the actual download link we're going to update from for each
|
||||
// project in the form, regardless of if it's enabled or disabled.
|
||||
$form['project_downloads'] = array('#tree' => TRUE);
|
||||
$form['project_downloads'] = ['#tree' => TRUE];
|
||||
$this->moduleHandler->loadInclude('update', 'inc', 'update.compare');
|
||||
$project_data = update_calculate_project_data($available);
|
||||
foreach ($project_data as $name => $project) {
|
||||
@@ -134,25 +134,25 @@ class UpdateManagerUpdate extends FormBase {
|
||||
$recommended_version .= '<div title="{{ major_update_warning_title }}" class="update-major-version-warning">{{ major_update_warning_text }}</div>';
|
||||
}
|
||||
|
||||
$recommended_version = array(
|
||||
$recommended_version = [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => $recommended_version,
|
||||
'#context' => array(
|
||||
'#context' => [
|
||||
'release_version' => $recommended_release['version'],
|
||||
'release_link' => $recommended_release['release_link'],
|
||||
'project_title' => $this->t('Release notes for @project_title', array('@project_title' => $project['title'])),
|
||||
'project_title' => $this->t('Release notes for @project_title', ['@project_title' => $project['title']]),
|
||||
'major_update_warning_title' => $this->t('Major upgrade warning'),
|
||||
'major_update_warning_text' => $this->t('This update is a major version update which means that it may not be backwards compatible with your currently running version. It is recommended that you read the release notes and proceed at your own risk.'),
|
||||
'release_notes' => $this->t('Release notes'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Create an entry for this project.
|
||||
$entry = array(
|
||||
$entry = [
|
||||
'title' => $project_name,
|
||||
'installed_version' => $project['existing_version'],
|
||||
'recommended_version' => array('data' => $recommended_version),
|
||||
);
|
||||
'recommended_version' => ['data' => $recommended_version],
|
||||
];
|
||||
|
||||
switch ($project['status']) {
|
||||
case UPDATE_NOT_SECURE:
|
||||
@@ -181,11 +181,11 @@ class UpdateManagerUpdate extends FormBase {
|
||||
}
|
||||
|
||||
// Use the project title for the tableselect checkboxes.
|
||||
$entry['title'] = array('data' => array(
|
||||
$entry['title'] = ['data' => [
|
||||
'#title' => $entry['title'],
|
||||
'#markup' => $entry['title'],
|
||||
));
|
||||
$entry['#attributes'] = array('class' => array('update-' . $type));
|
||||
]];
|
||||
$entry['#attributes'] = ['class' => ['update-' . $type]];
|
||||
|
||||
// Drupal core needs to be upgraded manually.
|
||||
$needs_manual = $project['project_type'] == 'core';
|
||||
@@ -198,15 +198,15 @@ class UpdateManagerUpdate extends FormBase {
|
||||
unset($entry['#weight']);
|
||||
$attributes = $entry['#attributes'];
|
||||
unset($entry['#attributes']);
|
||||
$entry = array(
|
||||
$entry = [
|
||||
'data' => $entry,
|
||||
) + $attributes;
|
||||
] + $attributes;
|
||||
}
|
||||
else {
|
||||
$form['project_downloads'][$name] = array(
|
||||
$form['project_downloads'][$name] = [
|
||||
'#type' => 'value',
|
||||
'#value' => $recommended_release['download_link'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// Based on what kind of project this is, save the entry into the
|
||||
@@ -230,62 +230,62 @@ class UpdateManagerUpdate extends FormBase {
|
||||
}
|
||||
|
||||
if (empty($projects)) {
|
||||
$form['message'] = array(
|
||||
$form['message'] = [
|
||||
'#markup' => $this->t('All of your projects are up to date.'),
|
||||
);
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
$headers = array(
|
||||
'title' => array(
|
||||
$headers = [
|
||||
'title' => [
|
||||
'data' => $this->t('Name'),
|
||||
'class' => array('update-project-name'),
|
||||
),
|
||||
'class' => ['update-project-name'],
|
||||
],
|
||||
'installed_version' => $this->t('Installed version'),
|
||||
'recommended_version' => $this->t('Recommended version'),
|
||||
);
|
||||
];
|
||||
|
||||
if (!empty($projects['enabled'])) {
|
||||
$form['projects'] = array(
|
||||
$form['projects'] = [
|
||||
'#type' => 'tableselect',
|
||||
'#header' => $headers,
|
||||
'#options' => $projects['enabled'],
|
||||
);
|
||||
];
|
||||
if (!empty($projects['disabled'])) {
|
||||
$form['projects']['#prefix'] = '<h2>' . $this->t('Enabled') . '</h2>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($projects['disabled'])) {
|
||||
$form['disabled_projects'] = array(
|
||||
$form['disabled_projects'] = [
|
||||
'#type' => 'tableselect',
|
||||
'#header' => $headers,
|
||||
'#options' => $projects['disabled'],
|
||||
'#weight' => 1,
|
||||
'#prefix' => '<h2>' . $this->t('Disabled') . '</h2>',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// If either table has been printed yet, we need a submit button and to
|
||||
// validate the checkboxes.
|
||||
if (!empty($projects['enabled']) || !empty($projects['disabled'])) {
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
$form['actions'] = ['#type' => 'actions'];
|
||||
$form['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Download these updates'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($projects['manual'])) {
|
||||
$prefix = '<h2>' . $this->t('Manual updates required') . '</h2>';
|
||||
$prefix .= '<p>' . $this->t('Updates of Drupal core are not supported at this time.') . '</p>';
|
||||
$form['manual_updates'] = array(
|
||||
$form['manual_updates'] = [
|
||||
'#type' => 'table',
|
||||
'#header' => $headers,
|
||||
'#rows' => $projects['manual'],
|
||||
'#prefix' => $prefix,
|
||||
'#weight' => 120,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $form;
|
||||
@@ -311,29 +311,29 @@ class UpdateManagerUpdate extends FormBase {
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->moduleHandler->loadInclude('update', 'inc', 'update.manager');
|
||||
$projects = array();
|
||||
foreach (array('projects', 'disabled_projects') as $type) {
|
||||
$projects = [];
|
||||
foreach (['projects', 'disabled_projects'] as $type) {
|
||||
if (!$form_state->isValueEmpty($type)) {
|
||||
$projects = array_merge($projects, array_keys(array_filter($form_state->getValue($type))));
|
||||
}
|
||||
}
|
||||
$operations = array();
|
||||
$operations = [];
|
||||
foreach ($projects as $project) {
|
||||
$operations[] = array(
|
||||
$operations[] = [
|
||||
'update_manager_batch_project_get',
|
||||
array(
|
||||
[
|
||||
$project,
|
||||
$form_state->getValue(array('project_downloads', $project)),
|
||||
),
|
||||
);
|
||||
$form_state->getValue(['project_downloads', $project]),
|
||||
],
|
||||
];
|
||||
}
|
||||
$batch = array(
|
||||
$batch = [
|
||||
'title' => $this->t('Downloading updates'),
|
||||
'init_message' => $this->t('Preparing to download selected updates'),
|
||||
'operations' => $operations,
|
||||
'finished' => 'update_manager_download_batch_finished',
|
||||
'file' => drupal_get_path('module', 'update') . '/update.manager.inc',
|
||||
);
|
||||
];
|
||||
batch_set($batch);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class UpdateReady extends FormBase {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $sitePath;
|
||||
protected $sitePath;
|
||||
|
||||
/**
|
||||
* Constructs a new UpdateReady object.
|
||||
@@ -91,23 +91,23 @@ class UpdateReady extends FormBase {
|
||||
return $form;
|
||||
}
|
||||
|
||||
$form['backup'] = array(
|
||||
$form['backup'] = [
|
||||
'#prefix' => '<strong>',
|
||||
'#markup' => $this->t('Back up your database and site before you continue. <a href=":backup_url">Learn how</a>.', array(':backup_url' => 'https://www.drupal.org/node/22281')),
|
||||
'#markup' => $this->t('Back up your database and site before you continue. <a href=":backup_url">Learn how</a>.', [':backup_url' => 'https://www.drupal.org/node/22281']),
|
||||
'#suffix' => '</strong>',
|
||||
);
|
||||
];
|
||||
|
||||
$form['maintenance_mode'] = array(
|
||||
$form['maintenance_mode'] = [
|
||||
'#title' => $this->t('Perform updates with site in maintenance mode (strongly recommended)'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
$form['actions'] = ['#type' => 'actions'];
|
||||
$form['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Continue'),
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class UpdateReady extends FormBase {
|
||||
// Make sure the Updater registry is loaded.
|
||||
drupal_get_updaters();
|
||||
|
||||
$updates = array();
|
||||
$updates = [];
|
||||
$directory = _update_manager_extract_directory();
|
||||
|
||||
$projects = $_SESSION['update_manager_update_projects'];
|
||||
@@ -137,11 +137,11 @@ class UpdateReady extends FormBase {
|
||||
$project_location = $directory . '/' . $project;
|
||||
$updater = Updater::factory($project_location, $this->root);
|
||||
$project_real_location = drupal_realpath($project_location);
|
||||
$updates[] = array(
|
||||
$updates[] = [
|
||||
'project' => $project,
|
||||
'updater_name' => get_class($updater),
|
||||
'local_url' => $project_real_location,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// If the owner of the last directory we extracted is the same as the
|
||||
@@ -164,7 +164,7 @@ class UpdateReady extends FormBase {
|
||||
// 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', __DIR__ . '/../../update.authorize.inc', array($updates), $this->t('Update manager'));
|
||||
system_authorized_init('update_authorize_run_update', __DIR__ . '/../../update.authorize.inc', [$updates], $this->t('Update manager'));
|
||||
$form_state->setRedirectUrl(system_authorized_get_url());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
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\Url;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
@@ -22,6 +24,9 @@ use Drupal\simpletest\WebTestBase;
|
||||
* (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 Scheduled for removal in Drupal 9.0.0.
|
||||
* Use \Drupal\Tests\update\Functional\UpdateTestBase instead.
|
||||
*/
|
||||
abstract class UpdateTestBase extends WebTestBase {
|
||||
|
||||
@@ -58,12 +63,12 @@ abstract class UpdateTestBase extends WebTestBase {
|
||||
* (optional) A string containing the URL to fetch update data from.
|
||||
* Defaults to 'update-test'.
|
||||
*
|
||||
* @see Drupal\update_test\Controller\UpdateTestController::updateTest()
|
||||
* @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, array('absolute' => TRUE))->toString())->save();
|
||||
$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.
|
||||
|
||||
@@ -62,7 +62,7 @@ class UpdateFetcher implements UpdateFetcherInterface {
|
||||
$data = '';
|
||||
try {
|
||||
$data = (string) $this->httpClient
|
||||
->get($url, array('headers' => array('Accept' => 'text/xml')))
|
||||
->get($url, ['headers' => ['Accept' => 'text/xml']])
|
||||
->getBody();
|
||||
}
|
||||
catch (RequestException $exception) {
|
||||
|
||||
@@ -7,6 +7,26 @@ namespace Drupal\update;
|
||||
*/
|
||||
interface UpdateFetcherInterface {
|
||||
|
||||
/**
|
||||
* Project's status cannot be checked.
|
||||
*/
|
||||
const NOT_CHECKED = -1;
|
||||
|
||||
/**
|
||||
* No available update data was found for project.
|
||||
*/
|
||||
const UNKNOWN = -2;
|
||||
|
||||
/**
|
||||
* There was a failure fetching available update data for this project.
|
||||
*/
|
||||
const NOT_FETCHED = -3;
|
||||
|
||||
/**
|
||||
* We need to (re)fetch available update data for this project.
|
||||
*/
|
||||
const FETCH_PENDING = -4;
|
||||
|
||||
/**
|
||||
* Returns the base of the URL to fetch available update data for a project.
|
||||
*
|
||||
|
||||
@@ -91,7 +91,7 @@ class UpdateManager implements UpdateManagerInterface {
|
||||
$this->keyValueStore = $key_value_expirable_factory->get('update');
|
||||
$this->themeHandler = $theme_handler;
|
||||
$this->availableReleasesTempStore = $key_value_expirable_factory->get('update_available_releases');
|
||||
$this->projects = array();
|
||||
$this->projects = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,11 +151,11 @@ class UpdateManager implements UpdateManagerInterface {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function projectStorage($key) {
|
||||
$projects = array();
|
||||
$projects = [];
|
||||
|
||||
// On certain paths, we should clear the data and recompute the projects for
|
||||
// update status of the site to avoid presenting stale information.
|
||||
$route_names = array(
|
||||
$route_names = [
|
||||
'update.theme_update',
|
||||
'system.modules_list',
|
||||
'system.theme_install',
|
||||
@@ -169,12 +169,12 @@ class UpdateManager implements UpdateManagerInterface {
|
||||
'update.manual_status',
|
||||
'update.confirmation_page',
|
||||
'system.themes_page',
|
||||
);
|
||||
];
|
||||
if (in_array(\Drupal::routeMatch()->getRouteName(), $route_names)) {
|
||||
$this->keyValueStore->delete($key);
|
||||
}
|
||||
else {
|
||||
$projects = $this->keyValueStore->get($key, array());
|
||||
$projects = $this->keyValueStore->get($key, []);
|
||||
}
|
||||
return $projects;
|
||||
}
|
||||
@@ -198,10 +198,10 @@ class UpdateManager implements UpdateManagerInterface {
|
||||
if ($item = $this->updateProcessor->claimQueueItem()) {
|
||||
if ($this->updateProcessor->processFetchTask($item->data)) {
|
||||
$context['results']['updated']++;
|
||||
$context['message'] = $this->t('Checked available update data for %title.', array('%title' => $item->data['info']['name']));
|
||||
$context['message'] = $this->t('Checked available update data for %title.', ['%title' => $item->data['info']['name']]);
|
||||
}
|
||||
else {
|
||||
$context['message'] = $this->t('Failed to check available update data for %title.', array('%title' => $item->data['info']['name']));
|
||||
$context['message'] = $this->t('Failed to check available update data for %title.', ['%title' => $item->data['info']['name']]);
|
||||
$context['results']['failures']++;
|
||||
}
|
||||
$context['sandbox']['progress']++;
|
||||
|
||||
@@ -7,6 +7,31 @@ namespace Drupal\update;
|
||||
*/
|
||||
interface UpdateManagerInterface {
|
||||
|
||||
/**
|
||||
* Project is missing security update(s).
|
||||
*/
|
||||
const NOT_SECURE = 1;
|
||||
|
||||
/**
|
||||
* Current release has been unpublished and is no longer available.
|
||||
*/
|
||||
const REVOKED = 2;
|
||||
|
||||
/**
|
||||
* Current release is no longer supported by the project maintainer.
|
||||
*/
|
||||
const NOT_SUPPORTED = 3;
|
||||
|
||||
/**
|
||||
* Project has a new release available, but it is not a security release.
|
||||
*/
|
||||
const NOT_CURRENT = 4;
|
||||
|
||||
/**
|
||||
* Project is up to date.
|
||||
*/
|
||||
const CURRENT = 5;
|
||||
|
||||
/**
|
||||
* Fetches an array of installed and enabled projects.
|
||||
*
|
||||
|
||||
@@ -104,8 +104,8 @@ class UpdateProcessor implements UpdateProcessorInterface {
|
||||
$this->availableReleasesTempStore = $key_value_expirable_factory->get('update_available_releases');
|
||||
$this->stateStore = $state_store;
|
||||
$this->privateKey = $private_key;
|
||||
$this->fetchTasks = array();
|
||||
$this->failed = array();
|
||||
$this->fetchTasks = [];
|
||||
$this->failed = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,7 +151,7 @@ class UpdateProcessor implements UpdateProcessorInterface {
|
||||
$max_fetch_attempts = $this->updateSettings->get('fetch.max_attempts');
|
||||
|
||||
$success = FALSE;
|
||||
$available = array();
|
||||
$available = [];
|
||||
$site_key = Crypt::hmacBase64($base_url, $this->privateKey->get());
|
||||
$fetch_url_base = $this->updateFetcher->getFetchBaseUrl($project);
|
||||
$project_name = $project['name'];
|
||||
@@ -219,23 +219,23 @@ class UpdateProcessor implements UpdateProcessorInterface {
|
||||
if (!isset($xml->short_name)) {
|
||||
return NULL;
|
||||
}
|
||||
$data = array();
|
||||
$data = [];
|
||||
foreach ($xml as $k => $v) {
|
||||
$data[$k] = (string) $v;
|
||||
}
|
||||
$data['releases'] = array();
|
||||
$data['releases'] = [];
|
||||
if (isset($xml->releases)) {
|
||||
foreach ($xml->releases->children() as $release) {
|
||||
$version = (string) $release->version;
|
||||
$data['releases'][$version] = array();
|
||||
$data['releases'][$version] = [];
|
||||
foreach ($release->children() as $k => $v) {
|
||||
$data['releases'][$version][$k] = (string) $v;
|
||||
}
|
||||
$data['releases'][$version]['terms'] = array();
|
||||
$data['releases'][$version]['terms'] = [];
|
||||
if ($release->terms) {
|
||||
foreach ($release->terms->children() as $term) {
|
||||
if (!isset($data['releases'][$version]['terms'][(string) $term->name])) {
|
||||
$data['releases'][$version]['terms'][(string) $term->name] = array();
|
||||
$data['releases'][$version]['terms'][(string) $term->name] = [];
|
||||
}
|
||||
$data['releases'][$version]['terms'][(string) $term->name][] = (string) $term->value;
|
||||
}
|
||||
|
||||
@@ -59,42 +59,42 @@ class UpdateSettingsForm extends ConfigFormBase implements ContainerInjectionInt
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$config = $this->config('update.settings');
|
||||
|
||||
$form['update_check_frequency'] = array(
|
||||
$form['update_check_frequency'] = [
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Check for updates'),
|
||||
'#default_value' => $config->get('check.interval_days'),
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
'1' => t('Daily'),
|
||||
'7' => t('Weekly'),
|
||||
),
|
||||
],
|
||||
'#description' => t('Select how frequently you want to automatically check for new releases of your currently installed modules and themes.'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['update_check_disabled'] = array(
|
||||
$form['update_check_disabled'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Check for updates of uninstalled modules and themes'),
|
||||
'#default_value' => $config->get('check.disabled_extensions'),
|
||||
);
|
||||
];
|
||||
|
||||
$notification_emails = $config->get('notification.emails');
|
||||
$form['update_notify_emails'] = array(
|
||||
$form['update_notify_emails'] = [
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Email addresses to notify when updates are available'),
|
||||
'#rows' => 4,
|
||||
'#default_value' => implode("\n", $notification_emails),
|
||||
'#description' => t('Whenever your site checks for available updates and finds new releases, it can notify a list of users via email. Put each address on a separate line. If blank, no emails will be sent.'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['update_notification_threshold'] = array(
|
||||
$form['update_notification_threshold'] = [
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Email notification threshold'),
|
||||
'#default_value' => $config->get('notification.threshold'),
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
'all' => t('All newer versions'),
|
||||
'security' => t('Only security updates'),
|
||||
),
|
||||
'#description' => t('You can choose to send email only if a security update is available, or to be notified about all newer versions. If there are updates available of Drupal core or any of your installed modules and themes, your site will always print a message on the <a href=":status_report">status report</a> page, and will also display an error message on administration pages if there is a security update.', array(':status_report' => $this->url('system.status')))
|
||||
);
|
||||
],
|
||||
'#description' => t('You can choose to send email only if a security update is available, or to be notified about all newer versions. If there are updates available of Drupal core or any of your installed modules and themes, your site will always print a message on the <a href=":status_report">status report</a> page, and will also display an error message on administration pages if there is a security update.', [':status_report' => $this->url('system.status')])
|
||||
];
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
}
|
||||
@@ -105,8 +105,8 @@ class UpdateSettingsForm extends ConfigFormBase implements ContainerInjectionInt
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
$form_state->set('notify_emails', []);
|
||||
if (!$form_state->isValueEmpty('update_notify_emails')) {
|
||||
$valid = array();
|
||||
$invalid = array();
|
||||
$valid = [];
|
||||
$invalid = [];
|
||||
foreach (explode("\n", trim($form_state->getValue('update_notify_emails'))) as $email) {
|
||||
$email = trim($email);
|
||||
if (!empty($email)) {
|
||||
@@ -122,10 +122,10 @@ class UpdateSettingsForm extends ConfigFormBase implements ContainerInjectionInt
|
||||
$form_state->set('notify_emails', $valid);
|
||||
}
|
||||
elseif (count($invalid) == 1) {
|
||||
$form_state->setErrorByName('update_notify_emails', $this->t('%email is not a valid email address.', array('%email' => reset($invalid))));
|
||||
$form_state->setErrorByName('update_notify_emails', $this->t('%email is not a valid email address.', ['%email' => reset($invalid)]));
|
||||
}
|
||||
else {
|
||||
$form_state->setErrorByName('update_notify_emails', $this->t('%emails are not valid email addresses.', array('%emails' => implode(', ', $invalid))));
|
||||
$form_state->setErrorByName('update_notify_emails', $this->t('%emails are not valid email addresses.', ['%emails' => implode(', ', $invalid)]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ class UpdateSettingsForm extends ConfigFormBase implements ContainerInjectionInt
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$config = $this->config('update.settings');
|
||||
// See if the update_check_disabled setting is being changed, and if so,
|
||||
// See if the update_check_disabled setting is being changed, and if so,
|
||||
// invalidate all update status data.
|
||||
if ($form_state->getValue('update_check_disabled') != $config->get('check.disabled_extensions')) {
|
||||
update_storage_clear();
|
||||
|
||||
Reference in New Issue
Block a user