* (bug 7335) SVN revision check in Special:Version fails on SVN 1.4 working copy
authorJimmy Collins <collinj@users.mediawiki.org>
Thu, 21 Sep 2006 15:06:17 +0000 (15:06 +0000)
committerJimmy Collins <collinj@users.mediawiki.org>
Thu, 21 Sep 2006 15:06:17 +0000 (15:06 +0000)
RELEASE-NOTES
includes/SpecialVersion.php

index ba99533..e242e1f 100644 (file)
@@ -220,6 +220,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Updates to language variant code for Serbian et al
 * (bug 6756) Enabling RTL direction for kk-cn
 * (bug 6701) Kazakh language variants in MessagesEn.php
+* (bug 7335) SVN revision check in Special:Version fails on SVN 1.4 working copy
 
 
 == Languages updated ==
index da654e6..8744597 100644 (file)
@@ -237,34 +237,51 @@ class SpecialVersion {
 
        /**
         * Retrieve the revision number of a Subversion working directory.
+        * 
+        * @bug 7335
         *
         * @param string $dir
         * @return mixed revision number as int, or false if not a SVN checkout
         */
        public static function getSvnRevision( $dir ) {
-               if( !function_exists( 'simplexml_load_file' ) ) {
-                       // We could fall back to expat... YUCK
-                       return false;
-               }
-               
                // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html
                $entries = $dir . '/.svn/entries';
-               
-               // SimpleXml whines about the xmlns...
-               wfSuppressWarnings();
-               $xml = simplexml_load_file( $entries );
-               wfRestoreWarnings();
-               
-               if( $xml ) {
-                       foreach( $xml->entry as $entry ) {
-                               if( $xml->entry[0]['name'] == '' ) {
-                                       // The directory entry should always have a revision marker.
-                                       if( $entry['revision'] ) {
-                                               return intval( $entry['revision'] );
+
+               if( !file_exists( $entries ) ) {
+                       return false;
+               }
+
+               $content = file( $entries );
+
+               // check if file is xml (subversion release <= 1.3) or not (subversion release = 1.4)
+               if( preg_match( '/^<\?xml/', $content[0] ) ) {
+                       // subversion is release <= 1.3
+                       if( !function_exists( 'simplexml_load_file' ) ) {
+                               // We could fall back to expat... YUCK
+                               return false;
+                       }
+
+                       // SimpleXml whines about the xmlns...
+                       wfSuppressWarnings();
+                       $xml = simplexml_load_file( $entries );
+                       wfRestoreWarnings();
+
+                       if( $xml ) {
+                               foreach( $xml->entry as $entry ) {
+                                       if( $xml->entry[0]['name'] == '' ) {
+                                               // The directory entry should always have a revision marker.
+                                               if( $entry['revision'] ) {
+                                                       return intval( $entry['revision'] );
+                                               }
                                        }
                                }
                        }
+                       return false;
+               } else {
+                       // subversion is release 1.4
+                       return intval( $content[3] );
                }
+
                return false;
        }