From: Brion Vibber Date: Fri, 7 Apr 2006 00:00:50 +0000 (+0000) Subject: * Include subversion revision number in Special:Version if available X-Git-Tag: 1.31.0-rc.0~57556 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=1f6215fbc498cb6515f24f37e56b628fe1282efd;p=lhc%2Fweb%2Fwiklou.git * Include subversion revision number in Special:Version if available Currently requires SimpleXML extension (available by default on PHP5) --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 9f06a38815..a4514950a2 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -31,6 +31,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 5476) Invalid xhtml in German localization * (bug 5479) Id translation for preferences tabs caption * Added skinname and style path parameters to CBT version of MonoBook +* Include subversion revision number in Special:Version if available == Compatibility == diff --git a/includes/SpecialVersion.php b/includes/SpecialVersion.php index 66c4e3e1fe..1369a5423a 100644 --- a/includes/SpecialVersion.php +++ b/includes/SpecialVersion.php @@ -45,8 +45,7 @@ class SpecialVersion { * @static */ function MediaWikiCredits() { - global $wgVersion; - + $version = $this->getVersion(); $dbr =& wfGetDB( DB_SLAVE ); $ret = @@ -71,12 +70,18 @@ class SpecialVersion { Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. or [http://www.gnu.org/copyleft/gpl.html read it online] - * [http://www.mediawiki.org/ MediaWiki]: $wgVersion + * [http://www.mediawiki.org/ MediaWiki]: $version * [http://www.php.net/ PHP]: " . phpversion() . " (" . php_sapi_name() . ") * " . $dbr->getSoftwareLink() . ": " . $dbr->getServerVersion(); return str_replace( "\t\t", '', $ret ); } + + function getVersion() { + global $wgVersion, $IP; + $svn = $this->getSvnRevision( $IP ); + return $svn ? "$wgVersion (r$svn)" : $wgVersion; + } function extensionCredits() { global $wgExtensionCredits, $wgExtensionFunctions, $wgParser, $wgSkinExtensionFunction; @@ -225,6 +230,39 @@ class SpecialVersion { } } + /** + * Retrieve the revision number of a Subversion working directory. + * + * @param string $dir + * @return mixed revision number as int, or false if not a SVN checkout + */ + 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'] ); + } + } + } + } + return false; + } + /**#@-*/ }