Cache the SVN version so we're not doing a filesystem read every time Special:Version...
authorChad Horohoe <demon@users.mediawiki.org>
Mon, 7 Jul 2008 12:55:42 +0000 (12:55 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Mon, 7 Jul 2008 12:55:42 +0000 (12:55 +0000)
includes/specials/SpecialVersion.php

index 8c8e386..fc7d844 100644 (file)
@@ -346,6 +346,14 @@ class SpecialVersion {
         * @return mixed revision number as int, or false if not a SVN checkout
         */
        public static function getSvnRevision( $dir ) {
+               global $wgMemc;
+               
+               $key = wfMemcKey('svn-version');
+               if ( $svnver = $wgMemc->get( $key ) ) {
+                       wfDebug("Got SVN version from cache.\n");
+                       return $svnver;
+               }
+               
                // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html
                $entries = $dir . '/.svn/entries';
 
@@ -373,6 +381,7 @@ class SpecialVersion {
                                        if( $xml->entry[0]['name'] == '' ) {
                                                // The directory entry should always have a revision marker.
                                                if( $entry['revision'] ) {
+                                                       $wgMemc->set($key, intval($entry['revision']), 3600 );
                                                        return intval( $entry['revision'] );
                                                }
                                        }
@@ -381,6 +390,7 @@ class SpecialVersion {
                        return false;
                } else {
                        // subversion is release 1.4
+                       $wgMemc->set($key, intval($content[3]), 3600 );
                        return intval( $content[3] );
                }
        }