Chris@0: createQueue(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_uninstall(). Chris@0: */ Chris@0: function update_uninstall() { Chris@0: \Drupal::state()->delete('update.last_check'); Chris@0: \Drupal::state()->delete('update.last_email_notification'); Chris@0: Chris@0: $queue = \Drupal::queue('update_fetch_tasks'); Chris@0: $queue->deleteQueue(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Fills in the requirements array. Chris@0: * Chris@0: * This is shared for both core and contrib to generate the right elements in Chris@0: * the array for hook_requirements(). Chris@0: * Chris@0: * @param $project Chris@0: * Array of information about the project we're testing as returned by Chris@0: * update_calculate_project_data(). Chris@0: * @param $type Chris@0: * What kind of project this is ('core' or 'contrib'). Chris@0: * Chris@0: * @return Chris@0: * An array to be included in the nested $requirements array. Chris@0: * Chris@0: * @see hook_requirements() Chris@0: * @see update_requirements() Chris@0: * @see update_calculate_project_data() Chris@0: */ Chris@0: function _update_requirement_check($project, $type) { Chris@0: $requirement = []; Chris@0: if ($type == 'core') { Chris@0: $requirement['title'] = t('Drupal core update status'); Chris@0: } Chris@0: else { Chris@0: $requirement['title'] = t('Module and theme update status'); Chris@0: } Chris@0: $status = $project['status']; Chris@0: if ($status != UPDATE_CURRENT) { Chris@0: $requirement['reason'] = $status; Chris@0: $requirement['severity'] = REQUIREMENT_ERROR; Chris@12: // When updates are available, append the available updates link to the Chris@12: // message from _update_message_text(), and format the two translated Chris@12: // strings together in a single paragraph. Chris@0: $requirement['description'][] = ['#markup' => _update_message_text($type, $status)]; Chris@12: if (!in_array($status, [UPDATE_UNKNOWN, UPDATE_NOT_CHECKED, UPDATE_NOT_FETCHED, UPDATE_FETCH_PENDING])) { Chris@12: if (_update_manager_access()) { Chris@18: $requirement['description'][] = ['#prefix' => ' ', '#markup' => t('See the available updates page for more information and to install your missing updates.', [':available_updates' => Url::fromRoute('update.report_update')->toString()])]; Chris@12: } Chris@12: else { Chris@18: $requirement['description'][] = ['#prefix' => ' ', '#markup' => t('See the available updates page for more information.', [':available_updates' => Url::fromRoute('update.status')->toString()])]; Chris@12: } Chris@0: } Chris@0: } Chris@0: switch ($status) { Chris@0: case UPDATE_NOT_SECURE: Chris@0: $requirement_label = t('Not secure!'); Chris@0: break; Chris@0: case UPDATE_REVOKED: Chris@0: $requirement_label = t('Revoked!'); Chris@0: break; Chris@0: case UPDATE_NOT_SUPPORTED: Chris@0: $requirement_label = t('Unsupported release'); Chris@0: break; Chris@0: case UPDATE_NOT_CURRENT: Chris@0: $requirement_label = t('Out of date'); Chris@0: $requirement['severity'] = REQUIREMENT_WARNING; Chris@0: break; Chris@0: case UPDATE_UNKNOWN: Chris@0: case UPDATE_NOT_CHECKED: Chris@0: case UPDATE_NOT_FETCHED: Chris@12: case UPDATE_FETCH_PENDING: Chris@0: $requirement_label = isset($project['reason']) ? $project['reason'] : t('Can not determine status'); Chris@0: $requirement['severity'] = REQUIREMENT_WARNING; Chris@0: break; Chris@0: default: Chris@0: $requirement_label = t('Up to date'); Chris@0: } Chris@0: if ($status != UPDATE_CURRENT && $type == 'core' && isset($project['recommended'])) { Chris@0: $requirement_label .= ' ' . t('(version @version available)', ['@version' => $project['recommended']]); Chris@0: } Chris@0: $requirement['value'] = \Drupal::l($requirement_label, new Url(_update_manager_access() ? 'update.report_update' : 'update.status')); Chris@0: return $requirement; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Rebuild the router to ensure admin/reports/updates/check has CSRF protection. Chris@0: */ Chris@0: function update_update_8001() { Chris@0: // Empty update forces a call to drupal_flush_all_caches() which rebuilds the Chris@0: // router. Chris@17: Chris@17: // Use hook_post_update_NAME() instead to clear the cache.The use Chris@17: // of hook_update_N to clear the cache has been deprecated see Chris@17: // https://www.drupal.org/node/2960601 for more details. Chris@0: }