Index: wikitools.pages.inc
===================================================================
--- wikitools.pages.inc	(revision 2105)
+++ wikitools.pages.inc	(working copy)
@@ -57,7 +57,7 @@
     // Try to find the current page with this name, limit the query by node types
     $params = $node_types;
     $params[] = $page_name;
-    $result = db_query("SELECT nid, type FROM {node} WHERE type IN (". db_placeholders($node_types, 'varchar') .") AND LOWER(title) = LOWER('%s')", $params);
+    $result = db_query(db_rewrite_sql("SELECT n.nid, n.type FROM {node} n WHERE n.type IN (". db_placeholders($node_types, 'varchar') .") AND LOWER(n.title) = LOWER('%s')"), $params);
     $found_nodes = array();
     while ($node = db_fetch_object($result)) {
       if (wikitools_type_affected($node->type)) {
@@ -81,7 +81,7 @@
     }
     else {
       // No match for title. Try to find an old page with this name
-      $result = db_query("SELECT n.nid, n.type, n.title FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid WHERE LOWER(r.title) = LOWER('%s') ORDER BY n.vid DESC", $page_name);
+      $result = db_query(db_rewrite_sql("SELECT n.nid, n.type, n.title FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid WHERE LOWER(r.title) = LOWER('%s') ORDER BY n.vid DESC"), $page_name);
       $moved_nodes = array();
       while ($node = db_fetch_object($result)) {
         if (wikitools_type_affected($node->type)) {
