Posted by mikeytown2 on April 24, 2009 at 10:14am
| Project: | Boost |
| Version: | 6.x-1.x-dev |
| Component: | Expiration logic |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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.
Comments
#1
Alternative solution to this problem is a db table, much like Cache Static.
#2
Modified Version Of Path Redirect() -> path_redirect_load() #451790: API - Reverse Lookup. path_redirect_load()
<?php
/**
* 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().
<?phpif (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
#3
#4
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.
#5
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.
#6
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
superand the other one namedsuper_duper; because of_whensupergets flushedsuper_dupergets 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.#7
committed
#8
Automatically closed -- issue fixed for 2 weeks with no activity.