--- path.inc	2006-12-23 23:04:52.000000000 +0100
+++ path.inc	2008-10-11 09:47:22.345127800 +0200
@@ -42,16 +42,17 @@
 function drupal_lookup_path($action, $path = '') {
   // $map keys are Drupal paths and the values are the corresponding aliases
   static $map = array(), $no_src = array();
-  static $count;
+  static $count = NULL;
 
   // Use $count to avoid looking up paths in subsequent calls if there simply are no aliases
-  if (!isset($count)) {
-    $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
+  if (is_null($count)) {
+    $count = (int)db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
   }
 
   if ($action == 'wipe') {
     $map = array();
     $no_src = array();
+    if(!$count) $count = NULL;
   }
   elseif ($count > 0 && $path != '') {
     if ($action == 'alias') {
