drupal.inc

  1. 8.0.x includes/drupal.inc
  2. 6.x commands/pm/update_info/drupal.inc
  3. 6.x includes/drupal.inc
  4. 7.x includes/drupal.inc
  5. 4.x commands/pm/update_info/drupal.inc
  6. 5.x commands/pm/update_info/drupal.inc
  7. 5.x includes/drupal.inc
  8. master includes/drupal.inc

Functions

Namesort descending Description
pm_get_project_info
pm_update_filter
pm_update_last_check
_pm_get_update_info Get update information for all installed projects.
_pm_refresh Command callback. Refresh update status information.

File

commands/pm/update_info/drupal.inc
View source
  1. <?php
  2. function pm_update_filter(&$project) {
  3. $update = FALSE;
  4. switch($project['status']) {
  5. case UPDATE_CURRENT:
  6. $status = dt('Up to date');
  7. $project['candidate_version'] = $project['recommended'];
  8. break;
  9. case UPDATE_NOT_CURRENT:
  10. $status = dt('Update available');
  11. pm_release_recommended($project);
  12. break;
  13. case UPDATE_NOT_SECURE:
  14. $status = dt('SECURITY UPDATE available');
  15. pm_release_recommended($project);
  16. break;
  17. case UPDATE_REVOKED:
  18. $status = dt('Installed version REVOKED');
  19. pm_release_recommended($project);
  20. break;
  21. case UPDATE_NOT_SUPPORTED:
  22. $status = dt('Installed version not supported');
  23. pm_release_recommended($project);
  24. break;
  25. case UPDATE_NOT_CHECKED:
  26. $status = dt('Unable to check status');
  27. break;
  28. default:
  29. $status = dt('Unknown');
  30. break;
  31. }
  32. return $status;
  33. }
  34. function pm_update_last_check() {
  35. return variable_get('update_last_check', 0);
  36. }
  37. /**
  38. * Command callback. Refresh update status information.
  39. */
  40. function _pm_refresh() {
  41. drush_print(dt("Refreshing update status information ..."));
  42. update_refresh();
  43. drush_print(dt("Done."));
  44. }
  45. /**
  46. * Get update information for all installed projects.
  47. *
  48. * @see update_get_available().
  49. * @see update_manual_status().
  50. *
  51. * @return An array containing remote and local versions for all installed
  52. * projects
  53. */
  54. function _pm_get_update_info($projects) {
  55. // Force to invalidate some caches that are only cleared
  56. // when visiting update status report page. This allow to detect changes in
  57. // .info files.
  58. _update_cache_clear('update_project_data');
  59. _update_cache_clear('update_project_projects');
  60. // From update_get_available(): Iterate all projects and create a fetch task
  61. // for those we have no information or is obsolete.
  62. module_load_include('inc', 'update', 'update.compare');
  63. $available = _update_get_cached_available_releases();
  64. $update_projects = update_get_projects();
  65. foreach ($update_projects as $key => $project) {
  66. if (empty($available[$key])) {
  67. update_create_fetch_task($project);
  68. continue;
  69. }
  70. if ($project['info']['_info_file_ctime'] > $available[$key]['last_fetch']) {
  71. $available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
  72. }
  73. if (empty($available[$key]['releases'])) {
  74. $available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
  75. }
  76. if (!empty($available[$key]['fetch_status']) && $available[$key]['fetch_status'] == UPDATE_FETCH_PENDING) {
  77. update_create_fetch_task($project);
  78. }
  79. }
  80. // Set a batch to process all pending tasks.
  81. $batch = array(
  82. 'operations' => array(
  83. array('update_fetch_data_batch', array()),
  84. ),
  85. 'finished' => 'update_fetch_data_finished',
  86. 'file' => drupal_get_path('module', 'update') . '/update.fetch.inc',
  87. );
  88. batch_set($batch);
  89. drush_backend_batch_process();
  90. // Clear any error set by a failed update fetch task. This avoid rollbacks.
  91. drush_clear_error();
  92. // Calculate update status data.
  93. $available = _update_get_cached_available_releases();
  94. $data = update_calculate_project_data($available);
  95. foreach ($data as $project_name => $project) {
  96. // Discard custom projects.
  97. if ($project['status'] == UPDATE_UNKNOWN) {
  98. unset($data[$project_name]);
  99. continue;
  100. }
  101. // Allow to update disabled projects.
  102. if (in_array($project['project_type'], array('module-disabled', 'theme-disabled'))) {
  103. $data[$project_name]['project_type'] = substr($project['project_type'], 0, strpos($project['project_type'], '-'));
  104. }
  105. // Set 'includes' key to all extensions. By default it only contain enabled
  106. // extensions and _pm_get_project_path() needs all of them.
  107. $data[$project_name]['includes'] = drupal_map_assoc($projects[$project_name]['extensions']);
  108. // Store all releases, not just the ones selected by update.module.
  109. $data[$project_name]['releases'] = $available[$project_name]['releases'];
  110. }
  111. $data = _pm_get_project_path($data, 'includes');
  112. return $data;
  113. }
  114. function pm_get_project_info($projects) {
  115. $data = array();
  116. include_once drupal_get_path('module', 'update') .'/update.fetch.inc';
  117. foreach ($projects as $project_name => $project) {
  118. $url = UPDATE_DEFAULT_URL. "/$project_name/". drush_drupal_major_version() . '.x';
  119. $xml = drupal_http_request($url);
  120. if (isset($xml->error)) {
  121. drush_set_error(dt(
  122. 'HTTP Request to @request has failed. @error',
  123. array('@request' => $xml->request, '@error' => $xml->error)
  124. ));
  125. }
  126. elseif (!$info = update_parse_xml($xml->data)) {
  127. drush_set_error(dt(
  128. 'No release history found for @project_name',
  129. array('@project_name' => $project_name)
  130. ));
  131. }
  132. else {
  133. $data[$project_name] = $info;
  134. }
  135. }
  136. return $data;
  137. }