comparison core/modules/update/update.module @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
183 module_load_install('update'); 183 module_load_install('update');
184 $status = update_requirements('runtime'); 184 $status = update_requirements('runtime');
185 foreach (['core', 'contrib'] as $report_type) { 185 foreach (['core', 'contrib'] as $report_type) {
186 $type = 'update_' . $report_type; 186 $type = 'update_' . $report_type;
187 // hook_requirements() supports render arrays therefore we need to render 187 // hook_requirements() supports render arrays therefore we need to render
188 // them before using drupal_set_message(). 188 // them before using
189 // \Drupal\Core\Messenger\MessengerInterface::addStatus().
189 if (isset($status[$type]['description']) && is_array($status[$type]['description'])) { 190 if (isset($status[$type]['description']) && is_array($status[$type]['description'])) {
190 $status[$type]['description'] = \Drupal::service('renderer')->renderPlain($status[$type]['description']); 191 $status[$type]['description'] = \Drupal::service('renderer')->renderPlain($status[$type]['description']);
191 } 192 }
192 if (!empty($verbose)) { 193 if (!empty($verbose)) {
193 if (isset($status[$type]['severity'])) { 194 if (isset($status[$type]['severity'])) {
194 if ($status[$type]['severity'] == REQUIREMENT_ERROR) { 195 if ($status[$type]['severity'] == REQUIREMENT_ERROR) {
195 drupal_set_message($status[$type]['description'], 'error'); 196 \Drupal::messenger()->addError($status[$type]['description']);
196 } 197 }
197 elseif ($status[$type]['severity'] == REQUIREMENT_WARNING) { 198 elseif ($status[$type]['severity'] == REQUIREMENT_WARNING) {
198 drupal_set_message($status[$type]['description'], 'warning'); 199 \Drupal::messenger()->addWarning($status[$type]['description']);
199 } 200 }
200 } 201 }
201 } 202 }
202 // Otherwise, if we're on *any* admin page and there's a security 203 // Otherwise, if we're on *any* admin page and there's a security
203 // update missing, print an error message about it. 204 // update missing, print an error message about it.
204 else { 205 else {
205 if (isset($status[$type]) 206 if (isset($status[$type])
206 && isset($status[$type]['reason']) 207 && isset($status[$type]['reason'])
207 && $status[$type]['reason'] === UPDATE_NOT_SECURE) { 208 && $status[$type]['reason'] === UPDATE_NOT_SECURE) {
208 drupal_set_message($status[$type]['description'], 'error'); 209 \Drupal::messenger()->addError($status[$type]['description']);
209 } 210 }
210 } 211 }
211 } 212 }
212 } 213 }
213 } 214 }
406 407
407 return $available; 408 return $available;
408 } 409 }
409 410
410 /** 411 /**
412 * Identifies equivalent security releases with a hardcoded list.
413 *
414 * Generally, only the latest minor version of Drupal 8 is supported. However,
415 * when security fixes are backported to an old branch, and the site owner
416 * updates to the release containing the backported fix, they should not
417 * see "Security update required!" again if the only other security releases
418 * are releases for the same advisories.
419 *
420 * @return string[]
421 * A list of security release numbers that are equivalent to this release
422 * (i.e. covered by the same advisory), for backported security fixes only.
423 *
424 * @internal
425 *
426 * @deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Use the
427 * 'Insecure' release type tag in update XML provided by Drupal.org to
428 * determine if releases are insecure.
429 */
430 function _update_equivalent_security_releases() {
431 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);
432 switch (\Drupal::VERSION) {
433 case '8.3.8':
434 return ['8.4.5', '8.5.0-rc1'];
435 case '8.3.9':
436 return ['8.4.6', '8.5.1'];
437 case '8.4.5':
438 return ['8.5.0-rc1'];
439 case '8.4.6':
440 return ['8.5.1'];
441 case '8.4.7':
442 return ['8.5.2'];
443 case '8.4.8':
444 return ['8.5.3'];
445 }
446
447 return [];
448 }
449
450 /**
411 * Adds a task to the queue for fetching release history data for a project. 451 * Adds a task to the queue for fetching release history data for a project.
412 * 452 *
413 * We only create a new fetch task if there's no task already in the queue for 453 * We only create a new fetch task if there's no task already in the queue for
414 * this particular project (based on 'update_fetch_task' key-value collection). 454 * this particular project (based on 'update_fetch_task' key-value collection).
415 * 455 *
453 */ 493 */
454 function update_fetch_data_finished($success, $results) { 494 function update_fetch_data_finished($success, $results) {
455 if ($success) { 495 if ($success) {
456 if (!empty($results)) { 496 if (!empty($results)) {
457 if (!empty($results['updated'])) { 497 if (!empty($results['updated'])) {
458 drupal_set_message(\Drupal::translation()->formatPlural($results['updated'], 'Checked available update data for one project.', 'Checked available update data for @count projects.')); 498 \Drupal::messenger()->addStatus(\Drupal::translation()->formatPlural($results['updated'], 'Checked available update data for one project.', 'Checked available update data for @count projects.'));
459 } 499 }
460 if (!empty($results['failures'])) { 500 if (!empty($results['failures'])) {
461 drupal_set_message(\Drupal::translation()->formatPlural($results['failures'], 'Failed to get available update data for one project.', 'Failed to get available update data for @count projects.'), 'error'); 501 \Drupal::messenger()->addError(\Drupal::translation()->formatPlural($results['failures'], 'Failed to get available update data for one project.', 'Failed to get available update data for @count projects.'));
462 } 502 }
463 } 503 }
464 } 504 }
465 else { 505 else {
466 drupal_set_message(t('An error occurred trying to get available update data.'), 'error'); 506 \Drupal::messenger()->addError(t('An error occurred trying to get available update data.'), 'error');
467 } 507 }
468 } 508 }
469 509
470 /** 510 /**
471 * Implements hook_mail(). 511 * Implements hook_mail().
623 * Then, we make sure that at least one module included in the archive file has 663 * Then, we make sure that at least one module included in the archive file has
624 * an .info.yml file which claims that the code is compatible with the current 664 * an .info.yml file which claims that the code is compatible with the current
625 * version of Drupal core. 665 * version of Drupal core.
626 * 666 *
627 * @see \Drupal\Core\Extension\ExtensionDiscovery 667 * @see \Drupal\Core\Extension\ExtensionDiscovery
628 * @see _system_rebuild_module_data()
629 */ 668 */
630 function update_verify_update_archive($project, $archive_file, $directory) { 669 function update_verify_update_archive($project, $archive_file, $directory) {
631 $errors = []; 670 $errors = [];
632 671
633 // Make sure this isn't a tarball of Drupal core. 672 // Make sure this isn't a tarball of Drupal core.