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_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. pm_release_recommended($project);
  8. $project['updateable'] = FALSE;
  9. break;
  10. case UPDATE_NOT_CURRENT:
  11. $status = dt('Update available');
  12. pm_release_recommended($project);
  13. break;
  14. case UPDATE_NOT_SECURE:
  15. $status = dt('SECURITY UPDATE available');
  16. pm_release_recommended($project);
  17. break;
  18. case UPDATE_REVOKED:
  19. $status = dt('Installed version REVOKED');
  20. pm_release_recommended($project);
  21. break;
  22. case UPDATE_NOT_SUPPORTED:
  23. $status = dt('Installed version not supported');
  24. pm_release_recommended($project);
  25. break;
  26. case UPDATE_NOT_CHECKED:
  27. $status = dt('Unable to check status');
  28. break;
  29. default:
  30. $status = dt('Unknown');
  31. break;
  32. }
  33. return $status;
  34. }
  35. function pm_update_last_check() {
  36. return variable_get('update_last_check', 0);
  37. }
  38. /**
  39. * Command callback. Refresh update status information.
  40. */
  41. function _pm_refresh() {
  42. drush_print(dt("Refreshing update status information ..."));
  43. update_refresh();
  44. drush_print(dt("Done."));
  45. }
  46. /**
  47. * Get update information for all installed projects.
  48. *
  49. * @see update_get_available().
  50. * @see update_manual_status().
  51. *
  52. * @return An array containing remote and local versions for all installed
  53. * projects
  54. */
  55. function _pm_get_update_info($projects) {
  56. // Force to invalidate some caches that are only cleared
  57. // when visiting update status report page. This allow to detect changes in
  58. // .info files.
  59. _update_cache_clear('update_project_data');
  60. _update_cache_clear('update_project_projects');
  61. // From update_get_available(): Iterate all projects and create a fetch task
  62. // for those we have no information or is obsolete.
  63. module_load_include('inc', 'update', 'update.compare');
  64. $available = _update_get_cached_available_releases();
  65. $update_projects = update_get_projects();
  66. foreach ($update_projects as $key => $project) {
  67. if (empty($available[$key])) {
  68. update_create_fetch_task($project);
  69. continue;
  70. }
  71. if ($project['info']['_info_file_ctime'] > $available[$key]['last_fetch']) {
  72. $available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
  73. }
  74. if (empty($available[$key]['releases'])) {
  75. $available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
  76. }
  77. if (!empty($available[$key]['fetch_status']) && $available[$key]['fetch_status'] == UPDATE_FETCH_PENDING) {
  78. update_create_fetch_task($project);
  79. }
  80. }
  81. // Set a batch to process all pending tasks.
  82. $batch = array(
  83. 'operations' => array(
  84. array('update_fetch_data_batch', array()),
  85. ),
  86. 'finished' => 'update_fetch_data_finished',
  87. 'file' => drupal_get_path('module', 'update') . '/update.fetch.inc',
  88. );
  89. batch_set($batch);
  90. drush_backend_batch_process();
  91. // Clear any error set by a failed update fetch task. This avoid rollbacks.
  92. drush_clear_error();
  93. // Calculate update status data.
  94. $available = _update_get_cached_available_releases();
  95. $data = update_calculate_project_data($available);
  96. foreach ($data as $project_name => $project) {
  97. // Discard custom projects.
  98. if ($project['status'] == UPDATE_UNKNOWN) {
  99. unset($data[$project_name]);
  100. continue;
  101. }
  102. // Discard projects with unknown installation path.
  103. if ($project_name != 'drupal' && !isset($projects[$project_name]['path'])) {
  104. unset($data[$project_name]);
  105. continue;
  106. }
  107. // Allow to update disabled projects.
  108. if (in_array($project['project_type'], array('module-disabled', 'theme-disabled'))) {
  109. $data[$project_name]['project_type'] = substr($project['project_type'], 0, strpos($project['project_type'], '-'));
  110. }
  111. // Add some info from the project to $data.
  112. $data[$project_name] += array(
  113. 'path' => $projects[$project_name]['path'],
  114. 'label' => $projects[$project_name]['label'],
  115. );
  116. // Store all releases, not just the ones selected by update.module.
  117. $data[$project_name]['releases'] = $available[$project_name]['releases'];
  118. }
  119. return $data;
  120. }