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

Issue #3466111: Remove Drush support

parent e448414a
No related branches found
No related tags found
1 merge request!59Issue #3466111: Remove Drush support
Pipeline #246689 passed
<?php
/**
* @file
* Drush hook implementations for the Alternative PHP Cache module.
*/
/**
* Implements hook_drush_exit().
*/
function apc_drush_exit() {
global $base_url;
if (class_exists('DrupalApcCache')) {
$requests = DrupalApcCache::pendingRequests();
if (!empty($requests) && is_array($requests)) {
if (!function_exists('module_exists')) {
// Drupal bootstrap did not reach the DRUPAL_BOOTSTRAP_VARIABLES phase,
// or module_exists() would be defined. This means it is not possible to
// check if the Alternative PHP Cache module is available.
// Exit silently.
return;
}
if (!module_exists('apc')) {
drush_log(
dt('You need to enable the Alternative PHP Cache module to clear the cache on the server.'),
'error'
);
return;
}
$star = serialize('*');
foreach (array_keys($requests) as $key) {
if (!empty($requests[$key][$star])) {
// If there is a request to clear all the entries for a bin, that is
// the only request which needs to be passed.
$requests[$key] = array($star => TRUE);
}
}
$args = array(
'apc.clear_cache' => array(
variable_get('cron_key', 'drupal'),
$requests,
),
);
$uri = $base_url . '/xmlrpc.php';
$response = xmlrpc($uri, $args);
if ($response === FALSE) {
drush_log(
dt(
'apc.clear_cache: %err_msg (%err_no)',
array('%err_msg' => xmlrpc_error(), '%err_no' => xmlrpc_errno())
),
'error'
);
if ($base_url == 'http://' . basename(conf_path())) {
drush_log(
dt('$base_url might not be set correctly.'),
'warning'
);
}
}
else {
drush_log(
dt("apc.clear_cache: The cache has been cleared."),
'success'
);
}
}
}
}
......@@ -88,44 +88,3 @@ function apc_clear_apcu_cache() {
drupal_set_message(t('APCu is not enabled.'), 'warning');
}
}
/**
* Implements hook_xmlrpc().
*/
function apc_xmlrpc() {
$methods[] = array(
'apc.clear_cache',
'apc_clear_cache',
array(
'boolean',
'string',
'array',
),
t('Clears the APCu cache.'),
);
return $methods;
}
/**
* XML-RPC callback to clear the cache.
*
* @see apc_xmlrpc()
*/
function apc_clear_cache($key, $bins = array()) {
if (empty($key) || variable_get('cron_key', 'drupal') != $key) {
watchdog('apc', 'An invalid auth key was passed to apc_clear_cache().', array(), WATCHDOG_ERROR);
return xmlrpc_error(-32602, t('Invalid auth key for apc.clear_cache.'));
}
// Clear the APCu cache.
foreach ($bins as $bin => $cids) {
foreach ($cids as $cid => $wildcard) {
// $cid has been serialized in DrupalAPCCache::clear().
cache_clear_all(unserialize($cid), $bin, $wildcard);
}
}
return TRUE;
}
......@@ -15,13 +15,6 @@
*/
class DrupalApcCache implements DrupalCacheInterface {
/**
* Requests to clear the cache to send via XML-RPC to the server.
*
* @var array
*/
protected static $pendingRequests = array();
/**
* The list of all the operations done to the cache.
*
......@@ -390,14 +383,6 @@ protected function deleteKeys($prefix = NULL) {
* {@inheritdoc}
*/
public function clear($cid = NULL, $wildcard = FALSE) {
if (drupal_is_cli()) {
// APCu uses a separate storage for CLI. Store these requests to be sent
// to the server via XML-RPC.
self::$pendingRequests[$this->bin][serialize($cid)] = $wildcard;
return;
}
if (empty($cid)) {
$this->deleteKeys();
}
......@@ -435,19 +420,6 @@ public function isEmpty() {
return TRUE;
}
/**
* Retrieves the requests that should be sent to the server via XML-RPC.
*
* @return array
* An array of requests.
* The array contains a key for each bin which must be cleared. The value
* for those keys is an array of cache IDs, whose value is TRUE if the cache
* ID is a wildcard string or FALSE otherwise.
*/
public static function pendingRequests() {
return self::$pendingRequests;
}
/**
* Retrieves the list of operations done on the cache.
*
......
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