From 92e161f548f0e7776059e55dab27bb68872878d9 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 12 Jan 2006 18:10:35 +0000 Subject: [PATCH] Created fetch_prev_revision() and warnings-- --- includes/cachev.php | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/includes/cachev.php b/includes/cachev.php index 6c6da80..16d9460 100644 --- a/includes/cachev.php +++ b/includes/cachev.php @@ -61,7 +61,7 @@ class cacheV * Memcache for all fetched revisions so we don't have to query-dupe * @var array */ - var $memcache = array(); + var $memcache = array('revs' => array(), 'nodes' => array()); // ################################################################### /** @@ -129,29 +129,19 @@ class cacheV * * @access public * + * @param string Node path * @param integer Revision number * * @return array Complete revision/commit entry */ - function fetch_prev_revision($revision) + function fetch_prev_revision($node, $revision) { - static $prevrevs; + $data = $this->fetch_node($node); + $data = $data['history']; - $revision = $this->registry->clean($revision, TYPE_UINT); + unset($data[ max(array_keys($data)) ]); - if (!isset($prevrevs["$revision"])) - { - $result = $this->registry->db->query_first("SELECT * FROM {$this->hash}_revs ORDER BY revision DESC LIMIT 1 WHERE revision < $revision"); - $revision = $result['revision']; - $this->memcache['revs']["$revision"] = $result; - $this->memcache['revs']["$revision"]['files'] = unserialize($this->memcache['revs']["$revision"]['files']); - } - else - { - $revision = $prevrevs["$revision"]; - } - - return $this->memcache['revs']["$revision"]; + return $this->fetch_revision(max(array_keys($data))); } // ################################################################### @@ -169,7 +159,14 @@ class cacheV $node = $this->fetch_node_string($node); if (!isset($this->memcache['nodes']["$node"])) { - $this->memcache['nodes']["$node"] = $this->registry->db->query_first("SELECT * FROM {$this->hash}_nodes WHERE name = '" . $this->registry->escape($node) . "'"); + $result = $this->registry->db->query_first("SELECT * FROM {$this->hash}_nodes WHERE name = '" . $this->registry->escape($node) . "'"); + if ($result == false) + { + return false; + } + + $this->memcache['nodes']["$node"] = $result; + $this->memcache['nodes']["$node"]['history'] = unserialize($this->memcache['nodes']["$node"]['history']); } return $this->memcache['nodes']["$node"]; @@ -255,6 +252,7 @@ class cacheV // other part of _nodes: properties $output = $this->registry->svn->svn('proplist -v -R ' . ($revision !== null ? ' -r' . $revision . ':HEAD ' : '') . $this->registry->repos->fetch_path($this->registry->paths->repos)); + $index = null; foreach ($output AS $line) { if (preg_match('#^Properties on \'(.*?)\':$#', $line, $bits)) -- 2.22.5