function _acquia_purge_input_path_variations in Acquia Purge 7
Make up variations on the given paths for lazier administrative cleaning.
As every URL gets uniquely cached, purging a path like 'news' will not purge potentially existing variations like 'news/' or 'news?page=0'. This helper is only meant to be used in places where an administrator is manually purging a few paths, for instance through Drush or the manual purge form.
Parameters
array $paths: Non-associative array with Drupal paths like '<front>' or 'user/1'.
string $path: (optional) INTERNAL, don't use directly! Used to add made up variations to the list by reference and to prevent duplicate paths.
See also
acquia_purge_manualpurge_form_submit()
2 calls to _acquia_purge_input_path_variations()
- drush_acquia_purge_ap_purge in ./
acquia_purge.drush.inc - Purge a specified path from your balancers.
- __acquia_purge_manualpurge_submit in ./
acquia_purge.admin.inc - Form submit callback.
File
- ./
acquia_purge.module, line 467 - Acquia Purge, Top-notch Varnish purging on Acquia Cloud!
Code
function _acquia_purge_input_path_variations(array &$paths, $path = NULL) {
// Are we supposed to just add a path to $paths? This only happens as we call
// ourselves here, a closure would have been better but that's PHP 5.3 :(.
if (!is_null($path)) {
if (!in_array($path, $paths)) {
$paths[] = $path;
}
return;
}
// Alias this function as $add, which reads better because of what it does.
$add = __FUNCTION__;
// Iterate all paths, build up $variations for every path and allow other
// modules to alter the variations. Then add all variations to $paths_new.
$paths_new = array();
foreach ($paths as $path) {
$path_original = $path;
$path_has_wildcard = strpos($path_original, '*') !== FALSE;
$variations = array();
// Begin all the madness by splitting the path by parameter.
$path = explode('?', _acquia_purge_input_clean($path));
$path[0] = rtrim($path[0], '/');
$add($variations, $path[0]);
if (!$path_has_wildcard) {
$add($variations, $path[0] . '/');
}
if (module_exists('path')) {
$add($variations, drupal_get_path_alias($path[0]));
$add($variations, drupal_get_normal_path($path[0]));
if (!$path_has_wildcard) {
$add($variations, drupal_get_path_alias($path[0]) . '/');
$add($variations, drupal_get_normal_path($path[0]) . '/');
}
}
if (isset($path[1])) {
$add($variations, implode('?', $path));
$add($variations, str_replace('?', '/?', implode('?', $path)));
$path_0 = $path[0];
$path[0] = drupal_get_path_alias($path_0);
$add($variations, implode('?', $path));
$path[0] = drupal_get_normal_path($path_0);
$add($variations, implode('?', $path));
if (!$path_has_wildcard) {
$path[0] = drupal_get_path_alias($path_0) . '/';
$add($variations, implode('?', $path));
$path[0] = drupal_get_normal_path($path_0) . '/';
$add($variations, implode('?', $path));
}
}
// Let hook_acquia_purge_variations_alter() implementations edit the list.
foreach (module_implements('acquia_purge_variations_alter') as $module) {
$function = $module . '_acquia_purge_variations_alter';
$function($path_original, $variations);
}
// Now pump all those variations over into $paths_new.
foreach ($variations as $variation) {
$add($paths_new, $variation);
}
}
$paths = $paths_new;
}