[MKDoc-commit] Patch from Sam - The search code now restarts each time it sees a

chris at mkdoc.demon.co.uk chris at mkdoc.demon.co.uk
Tue Aug 2 11:32:00 BST 2005


Log Message:
-----------
Patch from Sam - The search code now restarts each time it sees a redirect.

Tags:
----
mkdoc-1-6

Modified Files:
--------------
    mkd/MKDoc/Util:
        LinkParser.pm

-------------- next part --------------
Index: LinkParser.pm
===================================================================
RCS file: /var/spool/cvs/mkd/MKDoc/Util/Attic/LinkParser.pm,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -LMKDoc/Util/LinkParser.pm -LMKDoc/Util/LinkParser.pm -u -r1.1.2.3 -r1.1.2.4
--- MKDoc/Util/LinkParser.pm
+++ MKDoc/Util/LinkParser.pm
@@ -277,7 +277,9 @@
         # if we found something and it's not a direct link then base
         # the new path off that
         if ($path and $path ne $this_path) {
-            @new = grep { defined and length } split('/', $path);
+            # restart the search
+            @new = ();
+            @old = ((grep { defined and length } split('/', $path)), @old);
         }
     }
 
@@ -286,8 +288,8 @@
     return $self->{document_id} = $id;
 }
 
-# lookup a path in Document and Redirect.  Returns the ID and
-# corrected path, if one was found.
+# lookup a path in Document and Redirect.  Returns the ID or a
+# corrected path if a redirect was found.
 sub lookup_path {
     my ($self, $path, $dbh) = @_;
 
@@ -297,10 +299,9 @@
     return $self->{document_id} = $id if $id;
 
     # it wasn't in Document, but it might be in Redirect
-    ($id, $path) = $dbh->selectrow_array('SELECT d.ID, d.Full_Path
-                                          FROM Document d, Redirect r
-                                          WHERE d.Full_Path = r.New_Path AND
-                                                r.Old_Path = ?', undef, $path);
+    ($path) = $dbh->selectrow_array('SELECT New_Path
+                                     FROM Redirect
+                                     WHERE Old_Path = ?', undef, $path);
 
     return ($id, $path);
 }


More information about the MKDoc-commit mailing list