Fixed fetch_prev_revision()
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 22 Jan 2006 20:11:38 +0000 (20:11 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 22 Jan 2006 20:11:38 +0000 (20:11 +0000)
includes/cachev.php

index a6a8b5ab778e46b205abe9595af29842a13e8a7e..04b9593d516248fdfdd7895779789c819dbbfcc7 100644 (file)
@@ -141,14 +141,21 @@ class cacheV
                $data = $this->fetch_node();
                $data = $data['history'];
                
-               if (sizeof($data['history']) < 1)
+               if (sizeof($data) < 1)
                {
                        return $this->fetch_revision(0);
                }
                
-               unset($data[ max(array_keys($data)) ]);
+               $list = array_keys($data);
+
+               $key = array_search($revision, $list);
+               $key++; // go to the next earliest revision
+               if (!isset($list["$key"]))
+               {
+                       return -1;
+               }
                
-               return $this->fetch_revision(max(array_keys($data)));
+               return $this->fetch_revision($list["$key"]);
        }
        
        // ###################################################################