5 * Install, update, and uninstall functions for the Update Manager module.
9 * Implements hook_requirements().
12 * An array describing the status of the site regarding available updates. If
13 * there is no update data, only one record will be returned, indicating that
14 * the status of core can't be determined. If data is available, there will be
15 * two records: one for core, and another for all of contrib (assuming there
16 * are any contributed modules or themes enabled on the site). In addition to
17 * the fields expected by hook_requirements ('value', 'severity', and
18 * optionally 'description'), this array will contain a 'reason' attribute,
19 * which is an integer constant to indicate why the given status is being
20 * returned (UPDATE_NOT_SECURE, UPDATE_NOT_CURRENT, or UPDATE_UNKNOWN). This
21 * is used for generating the appropriate e-mail notification messages during
22 * update_cron(), and might be useful for other modules that invoke
23 * update_requirements() to find out if the site is up to date or not.
25 * @see _update_message_text()
26 * @see _update_cron_notify()
28 function update_requirements($phase) {
29 $requirements = array();
30 if ($phase == 'runtime') {
31 if ($available = update_get_available(FALSE)) {
32 module_load_include('inc', 'update', 'update.compare');
33 $data = update_calculate_project_data($available);
34 // First, populate the requirements for core:
35 $requirements['update_core'] = _update_requirement_check($data['drupal'], 'core');
36 // We don't want to check drupal a second time.
37 unset($data['drupal']);
39 // Now, sort our $data array based on each project's status. The
40 // status constants are numbered in the right order of precedence, so
41 // we just need to make sure the projects are sorted in ascending
42 // order of status, and we can look at the first project we find.
43 uasort($data, '_update_project_status_sort');
44 $first_project = reset($data);
45 $requirements['update_contrib'] = _update_requirement_check($first_project, 'contrib');
49 $requirements['update_core']['title'] = t('Drupal core update status');
50 $requirements['update_core']['value'] = t('No update data available');
51 $requirements['update_core']['severity'] = REQUIREMENT_WARNING;
52 $requirements['update_core']['reason'] = UPDATE_UNKNOWN;
53 $requirements['update_core']['description'] = _update_no_data();
60 * Implements hook_schema().
62 function update_schema() {
63 $schema['cache_update'] = drupal_get_schema_unprocessed('system', 'cache');
64 $schema['cache_update']['description'] = 'Cache table for the Update module to store information about available releases, fetched from central server.';
69 * Implements hook_install().
71 function update_install() {
72 $queue = DrupalQueue::get('update_fetch_tasks', TRUE);
73 $queue->createQueue();
77 * Implements hook_uninstall().
79 function update_uninstall() {
80 // Clear any variables that might be in use
82 'update_check_frequency',
85 'update_last_email_notification',
86 'update_notification_threshold',
87 'update_notify_emails',
88 'update_max_fetch_attempts',
89 'update_max_fetch_time',
91 foreach ($variables as $variable) {
92 variable_del($variable);
94 $queue = DrupalQueue::get('update_fetch_tasks');
95 $queue->deleteQueue();
99 * Fills in the requirements array.
101 * This is shared for both core and contrib to generate the right elements in
102 * the array for hook_requirements().
105 * Array of information about the project we're testing as returned by
106 * update_calculate_project_data().
108 * What kind of project this is ('core' or 'contrib').
111 * An array to be included in the nested $requirements array.
113 * @see hook_requirements()
114 * @see update_requirements()
115 * @see update_calculate_project_data()
117 function _update_requirement_check($project, $type) {
118 $requirement = array();
119 if ($type == 'core') {
120 $requirement['title'] = t('Drupal core update status');
123 $requirement['title'] = t('Module and theme update status');
125 $status = $project['status'];
126 if ($status != UPDATE_CURRENT) {
127 $requirement['reason'] = $status;
128 $requirement['description'] = _update_message_text($type, $status, TRUE);
129 $requirement['severity'] = REQUIREMENT_ERROR;
132 case UPDATE_NOT_SECURE:
133 $requirement_label = t('Not secure!');
136 $requirement_label = t('Revoked!');
138 case UPDATE_NOT_SUPPORTED:
139 $requirement_label = t('Unsupported release');
141 case UPDATE_NOT_CURRENT:
142 $requirement_label = t('Out of date');
143 $requirement['severity'] = REQUIREMENT_WARNING;
146 case UPDATE_NOT_CHECKED:
147 case UPDATE_NOT_FETCHED:
148 $requirement_label = isset($project['reason']) ? $project['reason'] : t('Can not determine status');
149 $requirement['severity'] = REQUIREMENT_WARNING;
152 $requirement_label = t('Up to date');
154 if ($status != UPDATE_CURRENT && $type == 'core' && isset($project['recommended'])) {
155 $requirement_label .= ' ' . t('(version @version available)', array('@version' => $project['recommended']));
157 $requirement['value'] = l($requirement_label, update_manager_access() ? 'admin/reports/updates/update' : 'admin/reports/updates');
162 * @addtogroup updates-6.x-to-7.x
167 * Create a queue to store tasks for requests to fetch available update data.
169 function update_update_7000() {
170 module_load_include('inc', 'system', 'system.queue');
171 $queue = DrupalQueue::get('update_fetch_tasks');
172 $queue->createQueue();
176 * Recreates cache_update table.
178 * Converts fields that hold serialized variables from text to blob.
179 * Removes 'headers' column.
181 function update_update_7001() {
182 $schema = system_schema_cache_7054();
184 db_drop_table('cache_update');
185 db_create_table('cache_update', $schema);
189 * @} End of "addtogroup updates-6.x-to-7.x".