Skip to content
Snippets Groups Projects
Commit 67463567 authored by Alberto Paderno's avatar Alberto Paderno
Browse files

Issue #3462649: Use xmlrpc_error() to return errors

parent 888e87f4
No related branches found
No related tags found
1 merge request!11Issue #3462649: Use xmlrpc_error() to return errors
Pipeline #228919 passed
......@@ -67,7 +67,7 @@ function apc_xmlrpc() {
'apc.clear_cache',
'apc_clear_cache',
array(
'array',
'boolean',
'string',
'array',
),
......@@ -84,12 +84,9 @@ function apc_xmlrpc() {
*/
function apc_clear_cache($key, $bins = array()) {
if (empty($key) || variable_get('cron_key', 'drupal') != $key) {
watchdog('apc', 'An invalid key was passed to apc_clear_cache().', array(), WATCHDOG_ERROR);
watchdog('apc', 'An invalid auth key was passed to apc_clear_cache().', array(), WATCHDOG_ERROR);
return array(
'success' => FALSE,
'message' => t('Invalid key for apc.clear_cache.'),
);
return xmlrpc_error(-32602, t('Invalid auth key for apc.clear_cache.'));
}
// Clear the APCu cache.
......@@ -100,10 +97,7 @@ function apc_clear_cache($key, $bins = array()) {
}
}
return array(
'success' => TRUE,
'message' => t('The cache has been cleared.'),
);
return TRUE;
}
/**
......
......@@ -385,6 +385,10 @@ public static function remoteFlush() {
}
if (!empty(self::$remoteRequests)) {
if ($base_url == 'http://' . basename(conf_path())) {
drush_log('$base_url might not be set correctly. Try using the -l/--uri option for Drush.', 'warning');
}
// Optimize '*' clears.
$star = serialize('*');
......@@ -405,16 +409,10 @@ public static function remoteFlush() {
$response = xmlrpc($uri, $args);
if ($response === FALSE) {
drush_log('xmlrpc() error: (' . xmlrpc_errno() . ') ' . xmlrpc_error_msg(), 'error');
if ($base_url == 'http://' . basename(conf_path())) {
drush_log('The base_url might not be set correctly try using the -l/--uri option for drush.', 'warning');
}
}
elseif (!$response['success']) {
drush_log('APC could not flush cache(s) because ' . $uri . ' returned code ' . $response['message'], 'error');
drush_log('apc.clear_cache: ' . xmlrpc_error_msg() . ' (' . xmlrpc_errno() . ')', 'error');
}
else {
drush_log("APC-Remote $uri: {$response['message']}", 'success');
drush_log("apc.clear_cache: The cache has been cleared.", 'success');
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment