Kill old paths from cache if a 301 was given

mikeytown2 - November 9, 2009 - 17:26
Project:Boost
Version:6.x-1.x-dev
Component:Expiration logic
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

If the path of a node has changed & "Do not flush expired content on cron run, instead re-crawl and overwrite it" is set and the old path gives a 301 due to Path Redirect then the old path will still give a 200 instead of a 301. There are several ways to fix the issue.

* Put a fix in boost_exit so any call to drupal_goto flushes the cache. Because hook_exit does not give me the redirect code I need to recreate the conditions that created the redirect via code from path_redirect_init() & globalredirect_init(). Other option is to assume if the code doesn't have destination=X then it was created by a module.

* Flush the file, then crawl the url, from inside the crawler.

* Detect path changes and kill the old file from boost_nodeapi

#1

mikeytown2 - November 9, 2009 - 19:08

This detects path changes... I should add it in. Runs under case 'presave': in nodeapi.

<?php
/**
* Implementation of hook_node_presave().
*
* Creates automatic redirects when URL aliases are manually changed.
*/
function path_redirect_node_presave($node) {
  if (
path_redirect_var('auto_redirect') && !empty($node->path)) {
   
$node_path = 'node/'. $node->nid;
   
$old_alias = drupal_get_path_alias($node_path, ($node->language ? $node->language : ''));
    if (
$old_alias != $node_path && $node->path != $old_alias) {
     
// If the user is manually changing the path alias, add a redirect from the old alias to the node.
     
path_redirect_save(array('path' => $old_alias, 'redirect' => $node_path));
    }
  }
}
?>

#2

mikeytown2 - November 9, 2009 - 22:36
Status:active» needs review

This does #1 & #3 from the original post

AttachmentSize
boost-627844.patch 2.92 KB

#3

mikeytown2 - November 9, 2009 - 23:12

Does all 3. Will commit soon to make the 4pm dev build time.

AttachmentSize
boost-627844.1.patch 8.04 KB

#4

mikeytown2 - November 9, 2009 - 23:47
Status:needs review» fixed

committed

#5

System Message - November 23, 2009 - 23:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.