diff --git a/clear.php b/clear.php new file mode 100644 index 0000000..0f5872a --- /dev/null +++ b/clear.php @@ -0,0 +1,5 @@ +bin . '(' . $cid . ') was not cleared. APC cli uses a different memory storage then the webserver. For more info see: http://drupal.org/node/1278232', 'warning'); + global $base_url; + $urldata = @parse_url($base_url); + $servers = variable_get('apc_servers', array('127.0.0.1')); + $clearpath = drupal_get_path('module', 'apc') . '/clear.php'; + foreach ($servers as $k => $server) { + if (in_array('curl', get_loaded_extensions())) { + $clearurl = 'http://' . $server . '/' . $clearpath; + // Use cURL to clear the APC cache for Drupal + $cc = curl_init(); + // Force the request to use the specified server with the site's domain + $headers = array("Host: " . $urldata['host']); + curl_setopt($cc, CURLOPT_HTTPHEADER, $headers); + curl_setopt($cc, CURLOPT_HEADER, 0); + curl_setopt($cc, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($cc, CURLOPT_URL, $clearurl); + $cr = curl_exec($cc); + $status = curl_getinfo($cc, CURLINFO_HTTP_CODE); + curl_close($cc); + + if (drush_get_context('DRUSH_DEBUG') && !drush_get_context('DRUSH_QUIET')) { + if (200 == $status) { + drush_log($this->bin . '(' . $cid . ') was cleared on server ' . $server . '.', 'notice'); + } + else { + drush_log($this->bin . '(' . $cid . ') was not cleared. APC cli uses a different memory storage than the webserver. In order to clear APC via Drush, your PHP installation must have cURL support enabled. For more information, see http://drupal.org/node/1278232', 'warning'); + } + } + } + else { + drush_log($this->bin . '(' . $cid . ') was not cleared. APC cli uses a different memory storage than the webserver. In order to clear APC via Drush, your PHP installation must have cURL support enabled. For more information, see http://drupal.org/node/1278232', 'warning'); + } + } return; }