← Back to team overview

registry team mailing list archive

[Merge] lp:~catch-drupal/pressflow/path_slow_query into lp:pressflow

 

Nathaniel Catchpole has proposed merging lp:~catch-drupal/pressflow/path_slow_query into lp:pressflow.

Requested reviews:
  Pressflow Administrators (pressflow)


Backporting selective full rebuilding of the path alias whitelist from Drupal 7.

 - update fixed an omission that meant the new code never actually stopped the slow query from running.
 - added a default argument for the whitelist rebuild.
-- 
https://code.launchpad.net/~catch-drupal/pressflow/path_slow_query/+merge/42333
Your team Registry Administrators is subscribed to branch lp:pressflow.
=== modified file 'includes/common.inc'
--- includes/common.inc	2010-08-11 21:05:18 +0000
+++ includes/common.inc	2010-12-01 05:06:28 +0000
@@ -128,8 +128,13 @@
 /**
  * Reset the static variable which holds the aliases mapped for this request.
  */
-function drupal_clear_path_cache() {
+function drupal_clear_path_cache($path = NULL) {
   drupal_lookup_path('wipe');
+  $modules = module_implements('lookup_path');
+  if (!empty($modules)) {
+    $module = reset($modules);
+    module_invoke($module, 'path_alias_whitelist_rebuild', $path);
+  }
 }
 
 /*

=== modified file 'modules/path/path.module'
--- modules/path/path.module	2008-12-11 04:56:37 +0000
+++ modules/path/path.module	2010-12-01 05:06:28 +0000
@@ -121,7 +121,7 @@
       db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path);
     }
   }
-  drupal_clear_path_cache();
+  drupal_clear_path_cache($path);
 }
 
 

=== modified file 'modules/path_alias_cache/path_alias_cache.module'
--- modules/path_alias_cache/path_alias_cache.module	2010-10-22 15:37:23 +0000
+++ modules/path_alias_cache/path_alias_cache.module	2010-12-01 05:06:28 +0000
@@ -39,7 +39,6 @@
 
   if ($action == 'wipe') {
     $cache = array();
-    $cache['whitelist'] = path_alias_cache_path_alias_whitelist_rebuild();
   }
   elseif ($cache['whitelist'] && $path != '') {
     if ($action == 'alias') {
@@ -198,7 +197,14 @@
  * @return
  *   An array containing a white list of path aliases.
  */
-function path_alias_cache_path_alias_whitelist_rebuild() {
+function path_alias_cache_path_alias_whitelist_rebuild($path  = NULL) {
+  if (!empty($path) && $cached = cache_get('path_alias_whitelist', 'cache_path')) {
+    $whitelist = $cached->data;
+    if (isset($whitelist[strtok($path, '/')])) {
+      return TRUE;
+    }
+  }
+
   // For each alias in the database, get the top level component of the system
   // path it corresponds to. This is the portion of the path before the first "/"
   // if present, otherwise the whole path itself.


Follow ups