If expire_include_base_url is set to TRUE then ExpireAPI::executeExpiration() calls url() to turn the url into a string. $urls is then an array of url strings.

If expire_include_base_url is FALSE, then url() is *not* called and $urls is passed to hook_expire_cache() as an array of arrays, with each url array containing at least the 'path' and 'query' keys.

This defies the documentation for the hook.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

azinck created an issue. See original summary.

azinck’s picture

Title: Inconsistent data type used for $urls in hook_expire_cache() » Inconsistent type used for $urls in hook_expire_cache()
azinck’s picture

Status: Active » Needs review
FileSize
998 bytes

Here's a stab at a patch.

DamienMcKenna’s picture

FileSize
1.08 KB

On top of that, it converts the URLs to an absolute path, whereas the documentation shows:

 *   Example of array (when base url include option is disabled):
 *   array(
 *     'node/1' => 'node/1',
 *     'news' => 'news',
 *   );

This patch converts them to relative paths, though I still wonder if that is the correct approach to take.

DamienMcKenna’s picture

I'm starting to think that the base_path() should not be added to the front of the paths, that it should be stripped off the front. What do you think?

DamienMcKenna’s picture

FileSize
1.14 KB

This removes the base_path().

DamienMcKenna’s picture

The question is - should it use url() at all, or should it just manually combine $path['path'] and $url['query']? The $language string throws some confusion into this..

erwangel’s picture

Indeed URL displays empty in debugLog and this makes the Expire module unusable when used in conjunction with varnish module as in configuration it is stated "Enabling this setting (Include base URL in expires) when Varnish or Acquia Purge modules are used as a cache backend is *not* recommended."

Of course the change suggested by Damien's patch at #6 could be done inside hook_expire_cache of the Varnish module but in such case Expire will continue to complain throwing "strpos() expects parameter 1 to be string, array given". So I think #6 gives the right place to patch.

As for the $language string (see #7), I think we need to keep it in case sites have more than one language activated. From the url() API documentation "$options['language'] is used to look up the alias for the URL".

pobster’s picture

FileSize
1.66 KB

How about this instead?

Bit confused why we're dropping the absolute part though?

ron_s’s picture

pobster’s picture

Status: Needs review » Closed (duplicate)

Agreed, closing this as a duplicate. I don't agree with the patch in that issue though ... It absolutely should take query strings and language into account. I'll open it up for discussion with an altered patch.