Ability to specify URL alias as well

hongbo - June 7, 2008 - 05:22
Project:CacheExclude
Version:6.x-2.0
Component:Code
Category:feature request
Priority:normal
Assigned:mbutcher
Status:closed
Description

Currently we can only exclude pages using Drupal path, such as node/10, blog/23, etc..

Would it be easier if we can exclude pages using URL alias, such as 'my-dynamic-page'.

I have the code for it, here is the new cacheexclude_init() for file cacheexclude.module.
Added: OR drupal_match_path(substr($_SERVER['QUERY_STRING'],2), $pages)

function cacheexclude_init() {
  $pages = trim(variable_get('cacheexclude_list', ''));
  // If the current page is one we want to exclude from the cache,
  // set the page caching to false temporarily.
 
//if (strlen($pages) && drupal_match_path($_GET['q'], $pages)) { //replace this with next 2 lines
  if (strlen($pages) && (drupal_match_path($_GET['q'], $pages) ||
      drupal_match_path(substr($_SERVER['QUERY_STRING'],2), $pages) )) {
    $GLOBALS['conf']['cache'] = FALSE;
  }
}

#1

hongbo - June 7, 2008 - 05:24
Version:6.x-2.x-dev» 6.x-2.0

#2

Crell - June 16, 2008 - 16:20
Status:needs review» active

Can you file a proper patch? Thanks. http://drupal.org/diffandpatch

#3

hongbo - June 20, 2008 - 00:52
Status:active» needs review

Here is proper patch, and it only change ONE line.

--- cacheexclude.module.old     2008-02-22 06:38:00.000000000 +1000
+++ cacheexclude.module 2008-06-20 10:26:10.000000000 +1000
@@ -38,7 +38,8 @@ function cacheexclude_init() {
   $pages = trim(variable_get('cacheexclude_list', ''));
   // If the current page is one we want to exclude from the cache,
   // set the page caching to false temporarily.
-  if (strlen($pages) && drupal_match_path($_GET['q'], $pages)) {
+  if (strlen($pages) && (drupal_match_path($_GET['q'], $pages) ||
+                         drupal_match_path(substr($_SERVER['QUERY_STRING'],2), $pages) )) {
     $GLOBALS['conf']['cache'] = FALSE;
   }
}

#4

Crell - June 20, 2008 - 14:58
Status:needs review» needs work

Don't access $_SERVER['QUERY_STRING'] directly. That's more error-prone. It's better and more portable to call drupal_get_path_alias($_GET['q']), as that ties into the aliasing system directly.

#5

hongbo - June 21, 2008 - 05:10
Status:needs work» needs review

Ok, drupal_get_path_alias($_GET['q']) works. Here is the modified patch

--- cacheexclude.module.old     2008-02-22 06:38:00.000000000 +1000
+++ cacheexclude.module 2008-06-21 15:10:00.000000000 +1000
@@ -38,7 +38,8 @@ function cacheexclude_init() {
   $pages = trim(variable_get('cacheexclude_list', ''));
   // If the current page is one we want to exclude from the cache,
   // set the page caching to false temporarily.
-  if (strlen($pages) && drupal_match_path($_GET['q'], $pages)) {
+  if (strlen($pages) && (drupal_match_path($_GET['q'], $pages) ||
+                         drupal_match_path(drupal_get_path_alias($_GET['q']), $pages) )) {
     $GLOBALS['conf']['cache'] = FALSE;
   }
}

#6

Crell - June 23, 2008 - 01:16
Status:needs review» active

Do not copy and paste a patch into the form. Create a patch file and attach it.

#7

hongbo - June 27, 2008 - 03:44

Ok, patch attached.

AttachmentSize
cacheexclude.module-alias.patch.txt 633 bytes

#8

Crell - June 27, 2008 - 14:45
Status:active» needs review

#9

JoepH - January 15, 2009 - 09:03

There was an error when pathing the file.

patch unexpectedly ends in middle of line
Hunk #1 succeeded at 38 with fuzz 2.

The code itself works fine when manually applied.
Here is a new patch file with the same code but without the error.

AttachmentSize
cacheexclude.module-alias.patch 773 bytes

#10

mbutcher - February 24, 2009 - 18:23
Assigned to:Anonymous» mbutcher
Status:needs review» fixed

A minor variation of JoepH's patch has been committed, and will be available in 6.x-2.1. Thanks hongbo and JoepH!

#11

System Message - March 10, 2009 - 21:00
Status:fixed» closed

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

#12

lemudesign.com - March 25, 2009 - 21:26
Version:6.x-2.0» 5.x-2.x-dev
Status:closed» patch (to be ported)

Please add this patch to Drupal 5 version;
No codes changes required I'm using the patch for Drupal 6 and it's working fine;
Thanks...

#13

lemudesign.com - March 25, 2009 - 21:48

well... it needs to do a drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH) to get the function drupal_get_path_alias declared otherwise you are going to face a undefined function call;

#14

Crell - March 26, 2009 - 17:29
Version:5.x-2.x-dev» 6.x-2.0
Status:patch (to be ported)» fixed

The 5.x release is in maintenance mode only and is not taking new features.

#15

System Message - April 9, 2009 - 17:30
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.