View source
<?php
define('ACQUIA_DRUPAL_MINIMUM_PHP_MEMORY', '32M');
if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update' && isset($_POST['start'])) {
acquia_agent_alter_module_updates($_POST['start']);
}
function acquia_agent_uninstall() {
variable_del('acquia_identifier');
variable_del('acquia_key');
variable_del('acquia_network_address');
variable_del('acquia_subscription_data');
variable_del('acquia_subscription_name');
variable_del('acquia_agent_cloud_migration');
variable_del('acquia_agent_debug');
variable_del('acquia_agent_verify_peer');
variable_del('acquia_dynamic_banner');
variable_del('acquia_migrate_files');
variable_del('acquia_banner_service');
variable_del('acquia_agent_hide_signup_messages');
}
function acquia_agent_disable() {
$mlid = db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_title = 'acquia_subscription_status' AND menu_name = 'admin_menu'"));
if ($mlid) {
menu_link_delete($mlid);
}
}
function acquia_agent_alter_module_updates(&$updates) {
uksort($updates, '_acquia_agent_alter_module_updates_cmp');
}
function _acquia_agent_alter_module_updates_cmp($a, $b) {
if ($a == 'system' || $b == 'system') {
return $a == 'system' ? -1 : 1;
}
elseif ($a == 'acquia_agent' || $b == 'acquia_agent') {
return $a == 'acquia_agent' ? -1 : 1;
}
return 0;
}
function acquia_agent_requirements($phase) {
include_once 'acquia_agent.module';
acquia_agent_load_versions();
$requirements = array();
$has_credentials = acquia_agent_has_credentials();
$is_active = acquia_agent_subscription_is_active();
$memory_limit = ini_get('memory_limit');
switch ($phase) {
case 'runtime':
if ($is_active) {
$requirements['acquia_subscription_status'] = array(
'title' => t('Acquia subscription status'),
'severity' => REQUIREMENT_OK,
'value' => t('Active'),
'description' => t('You can also <a href="@refresh-status">manually refresh the subscription status</a>.', array(
'@refresh-status' => url('admin/settings/acquia-agent/refresh-status', array(
'query' => drupal_get_destination(),
)),
)),
);
}
elseif (!$has_credentials) {
$requirements['acquia_subscription_status'] = array(
'title' => t('Acquia subscription status'),
'severity' => REQUIREMENT_WARNING,
'value' => t('Unknown'),
'description' => t('You did not complete your signup Acquia subscription signup. You can provide the subscription identifier and the subscription key at the <a href="@settings">Acquia settings</a> page or try to <a href="@refresh-status">manually refresh the subscription status</a>.', array(
'@settings' => url('admin/settings/acquia-agent'),
'@refresh-status' => url('admin/settings/acquia-agent/refresh-status', array(
'query' => drupal_get_destination(),
)),
)),
);
}
else {
$subscription = variable_get('acquia_subscription_data', array(
'active' => FALSE,
));
$href = isset($subscription['href']) ? $subscription['href'] . '/health' : 'http://acquia.com/network';
$requirements['acquia_subscription_status'] = array(
'title' => t('Acquia subscription status'),
'severity' => REQUIREMENT_WARNING,
'value' => t('Inactive'),
'description' => t('Your subscription is expired or you are using an invalid identifier and key pair. You can check the subscription identifier and the subscription key at the <a href="@settings">Acquia settings</a> page. Check <a href="@acquia-network">your Acquia Subscription</a> for further status information.', array(
'@settings' => url('admin/settings/acquia-agent'),
'@acquia-network' => $href,
)),
);
}
if (IS_ACQUIA_DRUPAL && $memory_limit && parse_size($memory_limit) < parse_size(ACQUIA_DRUPAL_MINIMUM_PHP_MEMORY)) {
$description = t('Drupal core requires @drupal_php_memory_limit, but to take advantage of all the features of Acquia Drupal, we recommend @acquia_php_memory_limit (or more).', array(
'@drupal_php_memory_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT,
'@acquia_php_memory_limit' => ACQUIA_DRUPAL_MINIMUM_PHP_MEMORY,
));
if (parse_size($memory_limit) >= parse_size(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)) {
if ($php_ini_path = get_cfg_var('cfg_file_path')) {
$description .= ' ' . t('Increase the memory limit by editing the memory_limit parameter in the file %configuration-file and then restart your web server (or contact your system administrator or hosting provider for assistance).', array(
'%configuration-file' => $php_ini_path,
));
}
else {
$description .= ' ' . t('Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.');
}
}
$requirements['acquia_php_memory_limit'] = array(
'title' => t('PHP memory limit (Acquia Drupal)'),
'description' => $description,
'severity' => REQUIREMENT_WARNING,
'value' => t('@memory_minimum_limit (or more) is recommended', array(
'@memory_minimum_limit' => ACQUIA_DRUPAL_MINIMUM_PHP_MEMORY,
)),
);
}
break;
case 'install':
$t = get_t();
if (IS_ACQUIA_DRUPAL && $memory_limit && parse_size($memory_limit) < parse_size(ACQUIA_DRUPAL_MINIMUM_PHP_MEMORY)) {
$description = $t('Your PHP memory limit is currently set at %current_memory_limit. Increasing this to %memory_minimum_limit (or more) is recommended to help prevent errors in the installation process and later during operation of the site.', array(
'%current_memory_limit' => $memory_limit,
'%memory_minimum_limit' => ACQUIA_DRUPAL_MINIMUM_PHP_MEMORY,
));
if ($php_ini_path = get_cfg_var('cfg_file_path')) {
$description .= ' ' . $t('Increase the memory limit by editing the memory_limit parameter in the file %configuration-file and then restart your web server (or contact your system administrator or hosting provider for assistance).', array(
'%configuration-file' => $php_ini_path,
));
}
else {
$description .= ' ' . $t('Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.');
}
$requirements['php_memory_limit'] = array(
'description' => $description,
'severity' => REQUIREMENT_WARNING,
);
}
if (version_compare(phpversion(), 5.0) < 0) {
$requirements['acquia_php_version'] = array(
'description' => $t('The Acquia Connector modules require a PHP version of at least 5.0.'),
'severity' => REQUIREMENT_ERROR,
);
}
break;
}
return $requirements;
}
function acquia_agent_update_6000() {
$ret = array();
$broken_filters = array();
if (module_exists('content') && module_exists('views') && function_exists('views_api_version') && views_api_version() == 2.0) {
$cck_schema_version = variable_get('content_schema_version', 0);
if ($cck_schema_version >= 6000 && $cck_schema_version <= 6008) {
if (function_exists('views_get_all_views') && ($views = views_get_all_views()) && is_array($views)) {
foreach ($views as $view) {
if (method_exists($view, 'init_display')) {
$view
->init_display();
if (is_array($view->display)) {
foreach ($view->display as $display_id => $display) {
if (method_exists($display->handler, 'is_defaulted') && !$display->handler
->is_defaulted('filter') && method_exists($display->handler, 'get_handlers')) {
$handlers = $display->handler
->get_handlers('filter');
if (is_array($handlers)) {
foreach ($handlers as $handler_id => $handler) {
if (isset($handler->content_field)) {
$field = $handler->content_field;
if (isset($field['type']) && in_array($field['type'], array(
'text',
'number_integer',
'number_decimal',
'number_float',
), TRUE)) {
if (function_exists('content_allowed_values')) {
$allowed_values = content_allowed_values($field);
if (count($allowed_values) && isset($view->type)) {
switch ($view->type) {
case t('Normal'):
$broken_filters['database'][$view->name][] = t('Content: @label', array(
'@label' => $field['widget']['label'],
));
break;
case t('Overriden'):
case t('Default'):
$broken_filters['code'][$view->name][] = $field['field_name'];
break;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
if (!empty($broken_filters)) {
foreach ($broken_filters as $type => $views) {
foreach ($views as $view => $fields) {
$view_replacement = $type == 'database' ? l($view, 'admin/build/views/edit/' . $view) : check_plain($view);
$broken_filters[$type][$view] = t('!view (broken filters: %filters)', array(
'!view' => $view_replacement,
'%filters' => implode(', ', array_unique($fields)),
));
}
}
$broken_database_filters = isset($broken_filters['database']) ? $broken_filters['database'] : array();
$broken_code_filters = isset($broken_filters['code']) ? $broken_filters['code'] : array();
$t_strings = array(
'!database_views' => '<li>' . implode('</li><li>', $broken_database_filters) . '</li>',
'!code_views' => '<li>' . implode('</li><li>', $broken_code_filters) . '</li>',
'@drupal_url' => 'http://drupal.org/node/330658',
);
if (!empty($broken_database_filters)) {
$text = 'The following Views on your site may not work correctly as a result of this upgrade:<ul>!database_views</ul>In particular, filters on CCK text or numeric fields that refer to a list of allowed values will need to be recreated. You may do this through the administrative interface by editing the "Filters" section of each View, removing the broken filters listed above, and replacing each with a new one of type "Content: ... Allowed values". Alternatively, you can edit an exported version of the View and then reimport it; <a href="@drupal_url">more information</a> on this option is available from the CCK issue queue on drupal.org.';
$message = t($text, $t_strings);
watchdog('acquia', $text, $t_strings, WATCHDOG_WARNING);
drupal_set_message($message, 'warning');
$ret[] = array(
'success' => TRUE,
'query' => $message,
);
}
if (!empty($broken_code_filters)) {
$text = 'The following Views on your site may not work correctly as a result of this upgrade:<ul>!code_views</ul>In particular, filters on CCK text or numeric fields that refer to a list of allowed values will need to be recreated. The Views listed above are defined in code and will need to be edited there. <a href="@drupal_url">More information</a> on how to do this is available from the CCK issue queue on drupal.org.';
$message = t($text, $t_strings);
watchdog('acquia', $text, $t_strings, WATCHDOG_WARNING);
drupal_set_message($message, 'warning');
$ret[] = array(
'success' => TRUE,
'query' => $message,
);
}
}
return $ret;
}