5 * Implementation of 'drupal' update_status engine for Drupal 7.
8 namespace Drush\UpdateService;
10 class StatusInfoDrupal7 extends StatusInfoDrupal8 {
15 function lastCheck() {
16 return variable_get('update_last_check', 0);
22 function beforeGetStatus(&$projects, $check_disabled) {
23 // If check-disabled option was provided, alter Drupal settings temporarily.
24 // There's no other way to hook into this.
25 if (!is_null($check_disabled)) {
27 $this->update_check_disabled = $conf['update_check_disabled'];
28 $conf['update_check_disabled'] = $check_disabled;
35 function afterGetStatus(&$update_info, $projects, $check_disabled) {
36 // Restore Drupal settings.
37 if (!is_null($check_disabled)) {
39 $conf['update_check_disabled'] = $this->update_check_disabled;
40 unset($this->update_check_disabled);
43 // update.module sets a different project type
44 // for disabled projects. Here we normalize it.
45 if ($check_disabled) {
46 foreach ($update_info as $key => $project) {
47 if (in_array($project['project_type'], array('module-disabled', 'theme-disabled'))) {
48 $update_info[$key]['project_type'] = substr($project['project_type'], 0, strpos($project['project_type'], '-'));
55 * Obtains release info for all installed projects via update.module.
57 * @see update_get_available().
58 * @see update_manual_status().
60 protected function getAvailableReleases() {
61 // Force to invalidate some caches that are only cleared
62 // when visiting update status report page. This allow to detect changes in
64 _update_cache_clear('update_project_data');
65 _update_cache_clear('update_project_projects');
67 // From update_get_available(): Iterate all projects and create a fetch task
68 // for those we have no information or is obsolete.
69 $available = _update_get_cached_available_releases();
71 module_load_include('inc', 'update', 'update.compare');
72 $update_projects = update_get_projects();
74 foreach ($update_projects as $key => $project) {
75 if (empty($available[$key])) {
76 update_create_fetch_task($project);
79 if ($project['info']['_info_file_ctime'] > $available[$key]['last_fetch']) {
80 $available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
82 if (empty($available[$key]['releases'])) {
83 $available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
85 if (!empty($available[$key]['fetch_status']) && $available[$key]['fetch_status'] == UPDATE_FETCH_PENDING) {
86 update_create_fetch_task($project);
90 // Set a batch to process all pending tasks.
92 'operations' => array(
93 array('update_fetch_data_batch', array()),
95 'finished' => 'update_fetch_data_finished',
96 'file' => drupal_get_path('module', 'update') . '/update.fetch.inc',
99 drush_backend_batch_process();
101 // Clear any error set by a failed update fetch task. This avoid rollbacks.
104 // Calculate update status data.
105 $available = _update_get_cached_available_releases();