This is a tricky bug... will most likely require a database lookup of the url_alias & path_redirect tables. Then do a search and destroy for any matching cached files. This method will only work if Pathauto is configured to automatically generate path redirects via Path Redirect.

How to trigger this bug - Rename a node's path. Stale file still there, thus a good chance of it being served. It will be cleared on cron though so this isn't critical.

CommentFileSizeAuthor
#6 boost.module.patch4.5 KBmikeytown2
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

Alternative solution to this problem is a db table, much like Cache Static.

mikeytown2’s picture

Modified Version Of Path Redirect() -> path_redirect_load() #451790: API - Reverse Lookup. path_redirect_load()

/**
 * Retrieve a specific URL redirect from the database.
 */
function boost_path_redirect_load($where = array(), $args = array(), $sort = array()) {
  $redirects = array();
  if (is_numeric($where)) {
    $where = array('rid' => $where);
  }

  foreach ($where as $key => $value) {
    if (is_string($key)) {
      $args[] = $value;
      $where[$key] = $key .' = '. (is_numeric($value) ? '%d' : "'%s'");
    }
  }

  if ($where && $args) {
    $sql = "SELECT * FROM {path_redirect} WHERE ". implode(' AND ', $where);
    if ($sort) {
      $sql .= ' ORDER BY '. implode(' ,', $sort);
    }
    $result = db_query($sql, $args);
    while($redirect = db_fetch_array($result)) {
      $redirects[] = $redirect;
    }
    return $redirects;
  }
}

Add this to a new function that sits in between the calls made to boost_cache_expire() and the actual boost_cache_expire().

if (module_exists('path_redirect')){
  $redirects = boost_path_redirect_load(array('redirect' => $path));
  foreach($redirects as $redirect) {
    boost_cache_expire($redirect['path']);
  }
}
boost_cache_expire($path);

While we are here, implementing wildcard support so files with url variables can be expired when the base file gets expired is a good idea.
http://www.php.net/fnmatch
http://www.php.net/glob

mikeytown2’s picture

Title: boost_cache_expire() doesn't work when path changed » Smarter boost_cache_expire(). Path Changes & Wildcard Support
Status: Active » Needs work
Dracolyte’s picture

Thanks for your reply to my other post. I made a quick change in the boost module nodeapi() function to use my user-friendly URLs the expired pages, like so:

switch ($op) {
   case 'insert':
   case 'update':
   case 'delete':
      // Expire all relevant node pages from the static page cache to prevent serving stale content:
     if (!empty($node->nid)) {

	// This was the original code:	
     	// boost_cache_expire('node/' . $node->nid, TRUE);
		
	// Instead I use this code, which works:
	boost_cache_expire(url('node/'. $node->nid, array('absolute' => FALSE)), TRUE);
     }
     break;
 }

This module is a lifesaver, BTW.

mikeytown2’s picture

Priority: Normal » Critical

It's now very important that the cache gets expired correctly, since the cache doesn't get cleared on every cron run with the latest set of patches.

mikeytown2’s picture

Status: Needs work » Needs review
FileSize
4.5 KB

Patch should flush all derivative paths (node, alias, redirects), including url variables. Using wildcards, for the sole purpose of flushing cached url variables from the base node. One minor issue with this is if there are 2 node paths, one named super and the other one named super_duper; because of _ when super gets flushed super_duper gets flushed as well. _ is generally not used for path naming, - is the preferred method, so this isn't a major issue; but suggestions would be very very handy on how to solve this potential issue. I need a character or group of characters that drupal will not allow to be used in a path, but apache & the file system understands.

mikeytown2’s picture

Status: Needs review » Fixed

committed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.