diff --git a/expire.api.php b/expire.api.php index 9c811e34a13cd54d4e63eba081cc9190b3983688..ea89183357de7368e78776c57f8cb0dcaa839878 100644 --- a/expire.api.php +++ b/expire.api.php @@ -54,6 +54,36 @@ function hook_expire_cache($urls, $wildcards, $object_type, $object) { * @param $urls * List of internal paths and/or absolute URLs that should be flushed. * + * Example of array: + * array( + * 'node-1' => 'node/1', + * 'reference-user-17' => 'user/17', + * ); + * + * @param $object_type + * Name of object type ('node', 'comment', 'user', etc). + * + * @param $object + * Object (node, comment, user, etc) for which expiration is executes. + * + * @param $absolute_urls_passed + * Indicates whether absolute urls were passed (TRUE or FALSE). + * Currently this flag can be set to TRUE only from drush command or rules action. + * + * @see expire.api.inc + */ +function hook_expire_cache_alter(&$urls, $object_type, $object, $absolute_urls_passed) { + if (!$absolute_urls_passed && isset($urls['node-1'])) { + unset($urls['node-1']); // Do not expire node with nid 1. + } +} + +/** + * Provides possibility to change urls right before they are expired. + * + * @param $urls + * List of internal paths and/or absolute URLs that should be flushed. + * * Example of array (when base url include option is enabled): * array( * 'node/1' => 'http://example.com/node/1', @@ -74,9 +104,8 @@ function hook_expire_cache($urls, $wildcards, $object_type, $object) { * * @see expire.api.inc */ -function hook_expire_cache_alter(&$urls, $object_type, $object) { - if ($object_type == 'node') { - unset($urls['node-' . $object->nid]); - $urls['example'] = 'custom_page/' . $object->uid . '/' . $object->nid; +function hook_expire_urls_alter(&$urls, $object_type, $object) { + if ($object_type == 'node' && isset($urls['node-' . $object->nid])) { + $urls['node-' . $object->nid] = 'custom-url'; } } diff --git a/includes/expire.api.inc b/includes/expire.api.inc index 464843d57d4494ed75f90be048f60536112e13c0..6966bb41c1111d888bfc147d5724dac7a4948f63 100644 --- a/includes/expire.api.inc +++ b/includes/expire.api.inc @@ -24,6 +24,9 @@ class ExpireAPI { */ public static function executeExpiration($urls, $object_type = '', $object = NULL, $absolute_urls_passed = FALSE) { + // Allow other modules to modify the list prior to expiring. + drupal_alter('expire_cache', $urls, $object_type, $object, $absolute_urls_passed); + // Nothing to expire, so exit. if (empty($urls)) { return; @@ -68,12 +71,13 @@ class ExpireAPI { } } - // Allow other modules to modify the list prior to expiring. - drupal_alter('expire_cache', $urls, $object_type, $object); + // Latest possibility to change urls that should be expired. + drupal_alter('expire_urls', $urls, $object_type, $object); // Write some debug information. self::debugLog($urls, $wildcards, $object_type); + // Execute internal or external expiration. $status = variable_get('expire_status', EXPIRE_STATUS_DISABLED); if ($status == EXPIRE_STATUS_ENABLED_INTERNAL) { self::executeInternalExpiration($urls, $wildcards);