--- domain.module.orig	2008-01-10 21:09:30.560970200 +0100
+++ domain.module	2008-01-10 22:03:12.993528400 +0100
@@ -1191,36 +1191,40 @@ function domain_url_alter(&$path, &$quer
  */
 function domain_grant_all($reset= FALSE) {
   static $grant;
-  if (!isset($grant['set']) || $reset) {
+  if (!isset($grant) || $reset) {
+    $grant = FALSE;
+
     // Search is the easy case, so we check it first.
-    $search = variable_get('domain_search', 0);
-    if ($search && arg(0) == 'search') {
+    if (variable_get('domain_search', 0) && arg(0) == 'search') {
       $grant = TRUE;
     }
+
     // On cron runs, we normally have to disable Domain Access.  See http://drupal.org/node/197488.
-    else if (variable_get('domain_cron_rule', 1)) {
+    if (!$grant && variable_get('domain_cron_rule', 1)) {
+      $script = array_pop(explode('/', request_uri()));
       if ($script == 'cron.php') {
         $grant = TRUE;
       }
     }
-    else {
+
+    if (!$grant) {
       // We check the paths registered by the special pages setting.
-      $grant = FALSE;
       $pages = variable_get('domain_grant_all', "user/*/track");
-      $path = drupal_get_path_alias($_GET['q']);
       $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($pages, '/')) .')$/';
       // Compare with the internal and path alias (if any).
-      $page_match = preg_match($regexp, $path);
-      if ($path != $_GET['q']) {
-        $page_match || preg_match($regexp, $_GET['q']);
+      $page_match = preg_match($regexp, $_GET['q']);
+      if (!$page_match) {
+        $path = drupal_get_path_alias($_GET['q']);
+        if ($path != $_GET['q']) {
+          $page_match = preg_match($regexp, $path);
+        }
       }    
       if ($page_match) {
         $grant = TRUE;
       }
     }  
-    $grant['set'] = $grant;
   }  
-  return $grant['set'];
+  return $grant;
 }
 
 /**
