Index: includes/path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.28
diff -u -p -r1.28 path.inc
--- includes/path.inc	14 Oct 2008 11:01:08 -0000	1.28
+++ includes/path.inc	19 Nov 2008 18:53:26 -0000
@@ -46,21 +46,20 @@ function drupal_init_path() {
 function drupal_lookup_path($action, $path = '', $path_language = '') {
   global $language;
   // $map is an array with language keys, holding arrays of Drupal paths to alias relations
-  static $map = array(), $no_src = array(), $count;
+  static $map = array(), $no_src = array(), $paths_enabled = NULL;
 
-  $path_language = $path_language ? $path_language : $language->language;
-
-  // 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 (!isset($paths_enabled)) {
+    // @todo Replace db_table_exists() with module_exists() when it can work here.
+    $paths_enabled = db_table_exists('url_alias');
   }
 
+  $path_language = $path_language ? $path_language : $language->language;
+
   if ($action == 'wipe') {
     $map = array();
     $no_src = array();
-    $count = NULL;
   }
-  elseif ($count > 0 && $path != '') {
+  elseif ($paths_enabled && $path != '') {
     if ($action == 'alias') {
       if (isset($map[$path_language][$path])) {
         return $map[$path_language][$path];
Index: modules/path/path.install
===================================================================
RCS file: modules/path/path.install
diff -N modules/path/path.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/path/path.install	19 Nov 2008 18:53:27 -0000
@@ -0,0 +1,65 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_schema().
+ */
+function path_schema() {
+  $schema['url_alias'] = array(
+    'description' => 'A list of URL aliases for Drupal paths; a user may visit either the source or destination path.',
+    'fields' => array(
+      'pid' => array(
+        'description' => 'A unique path alias identifier.',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'src' => array(
+        'description' => 'The Drupal path this alias is for; e.g. node/12.',
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'dst' => array(
+        'description' => 'The alias for this path; e.g. title-of-the-story.',
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'language' => array(
+        'description' => 'The language this alias is for; if blank, the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.',
+        'type' => 'varchar',
+        'length' => 12,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+    ),
+    'unique keys' => array(
+      'dst_language' => array('dst', 'language'),
+    ),
+    'primary key' => array('pid'),
+    'indexes' => array(
+      'src' => array('src'),
+    ),
+  );
+
+  return $schema;
+}
+
+/**
+ * Implementation of hook_install().
+ */
+function path_install() {
+  if (!db_table_exists('url_alias')) {
+    drupal_install_schema('path');
+  }
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function path_uninstall() {
+  drupal_uninstall_schema('path');
+}
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.280
diff -u -p -r1.280 system.install
--- modules/system/system.install	15 Nov 2008 13:01:10 -0000	1.280
+++ modules/system/system.install	19 Nov 2008 18:53:33 -0000
@@ -1247,46 +1247,6 @@ function system_schema() {
     ),
   );
 
-  $schema['url_alias'] = array(
-    'description' => 'A list of URL aliases for Drupal paths; a user may visit either the source or destination path.',
-    'fields' => array(
-      'pid' => array(
-        'description' => 'A unique path alias identifier.',
-        'type' => 'serial',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-      ),
-      'src' => array(
-        'description' => 'The Drupal path this alias is for; e.g. node/12.',
-        'type' => 'varchar',
-        'length' => 128,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'dst' => array(
-        'description' => 'The alias for this path; e.g. title-of-the-story.',
-        'type' => 'varchar',
-        'length' => 128,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'language' => array(
-        'description' => 'The language this alias is for; if blank, the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.',
-        'type' => 'varchar',
-        'length' => 12,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-    ),
-    'unique keys' => array(
-      'dst_language' => array('dst', 'language'),
-    ),
-    'primary key' => array('pid'),
-    'indexes' => array(
-      'src' => array('src'),
-    ),
-  );
-
   return $schema;
 }
 
