- fetch_prev_revision() should now work as desired
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 22 Jan 2006 22:03:34 +0000 (22:03 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 22 Jan 2006 22:03:34 +0000 (22:03 +0000)
- Added an optional override parameter to fetch_node() to specify a node

includes/cachev.php

index 04b9593d516248fdfdd7895779789c819dbbfcc7..d257978c6d58ae0448f798f0341200f94150e131 100644 (file)
@@ -138,17 +138,21 @@ class cacheV
        */
        function fetch_prev_revision($revision)
        {
-               $data = $this->fetch_node();
-               $data = $data['history'];
-               
+               $data = $this->fetch_node(($this->controller->path == '/' ? $this->controller->repos : $this->controller->path));
+               $data = $data['history'];               
                if (sizeof($data) < 1)
                {
                        return $this->fetch_revision(0);
                }
                
                $list = array_keys($data);
-
                $key = array_search($revision, $list);
+               
+               if ($revision == 'HEAD')
+               {
+                       $key = 0;
+               }
+               
                $key++; // go to the next earliest revision
                if (!isset($list["$key"]))
                {
@@ -180,11 +184,13 @@ class cacheV
        *
        * @access       public
        *
+       * @param        string  Node override
+       *
        * @return       integer Latest revision; FALSE if none (not in HEAD)
        */
-       function fetch_node()
+       function fetch_node($node = false)
        {
-               $node = $this->fetch_node_string($this->controller->path);
+               $node = $this->fetch_node_string(($node === false ? $this->controller->path : $node));
                if (!isset($this->memcache['nodes']["$node"]))
                {
                        $result = $this->controller->registry->db->query_first("SELECT * FROM {$this->hash}_nodes WHERE name = '" . $this->controller->registry->escape($node) . "'");