r49890 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49889‎ | r49890 | r49891 >
Date:05:22, 26 April 2009
Author:shinjiman
Status:deferred (Comments)
Tags:
Comment:
* (bug 18242) Show the Subversion revision number per extensions in Special:Version (currently applied on some extensions to get the entries file)
Modified paths:
  • /trunk/extensions/ABC/ABC.php (modified) (history)
  • /trunk/extensions/APC/ViewAPC.php (modified) (history)
  • /trunk/extensions/AbsenteeLandlord/AbsenteeLandlord.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.php (modified) (history)
  • /trunk/extensions/AdvancedRandom/SpecialAdvancedRandom.php (modified) (history)
  • /trunk/extensions/AdvancedSearch/AdvancedSearch.setup.php (modified) (history)
  • /trunk/extensions/AjaxLogin/AjaxLogin.php (modified) (history)
  • /trunk/extensions/AjaxQueryPages/Load.php (modified) (history)
  • /trunk/extensions/AjaxShowEditors/Load.php (modified) (history)
  • /trunk/extensions/AjaxTest/AjaxTest.php (modified) (history)
  • /trunk/extensions/AmazonPlus/AmazonPlus.php (modified) (history)
  • /trunk/extensions/AntiBot/AntiBot.php (modified) (history)
  • /trunk/extensions/AntiSpoof/AntiSpoof.php (modified) (history)
  • /trunk/extensions/Asksql/Asksql.php (modified) (history)
  • /trunk/extensions/AssertEdit/AssertEdit.php (modified) (history)
  • /trunk/extensions/AuthorProtect/AuthorProtect.php (modified) (history)
  • /trunk/extensions/Autoincrement/Autoincrement.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTree.php (modified) (history)
  • /trunk/extensions/CrossNamespaceLinks/SpecialCrossNamespaceLinks.php (modified) (history)
  • /trunk/extensions/Nuke/SpecialNuke.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions.php (modified) (history)
  • /trunk/extensions/Renameuser/SpecialRenameuser.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialVersion.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesLzh.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesYue.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh_hans.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh_hant.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -2913,6 +2913,7 @@
29142914 'version-hook-name',
29152915 'version-hook-subscribedby',
29162916 'version-version',
 2917+ 'version-revision',
29172918 'version-license',
29182919 'version-software',
29192920 'version-software-product',
Index: trunk/phase3/includes/specials/SpecialVersion.php
@@ -114,7 +114,7 @@
115115 public static function getVersion() {
116116 global $wgVersion, $IP;
117117 wfProfileIn( __METHOD__ );
118 - $svn = self::getSvnRevision( $IP );
 118+ $svn = self::getSvnRevision( $IP, false );
119119 $version = $svn ? "$wgVersion (r$svn)" : $wgVersion;
120120 wfProfileOut( __METHOD__ );
121121 return $version;
@@ -129,7 +129,7 @@
130130 public static function getVersionLinked() {
131131 global $wgVersion, $IP;
132132 wfProfileIn( __METHOD__ );
133 - $svn = self::getSvnRevision( $IP );
 133+ $svn = self::getSvnRevision( $IP, false );
134134 $viewvc = 'http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/?pathrev=';
135135 $version = $svn ? "$wgVersion ([{$viewvc}{$svn} r$svn])" : $wgVersion;
136136 wfProfileOut( __METHOD__ );
@@ -163,7 +163,9 @@
164164
165165 foreach ( $wgExtensionCredits[$type] as $extension ) {
166166 $version = null;
167 - $subVersion = '';
 167+ $subVersion = null;
 168+ if (isset($extension['path']))
 169+ $subVersion = self::getSvnRevision(dirname($extension['path']), true);
168170 if ( isset( $extension['version'] ) ) {
169171 $version = $extension['version'];
170172 }
@@ -171,6 +173,7 @@
172174 $out .= $this->formatCredits(
173175 isset ( $extension['name'] ) ? $extension['name'] : '',
174176 $version,
 177+ $subVersion,
175178 isset ( $extension['author'] ) ? $extension['author'] : '',
176179 isset ( $extension['url'] ) ? $extension['url'] : null,
177180 isset ( $extension['description'] ) ? $extension['description'] : '',
@@ -217,9 +220,10 @@
218221 }
219222 }
220223
221 - function formatCredits( $name, $version = null, $author = null, $url = null, $description = null, $descriptionMsg = null ) {
 224+ function formatCredits( $name, $version = null, $subVersion = null, $author = null, $url = null, $description = null, $descriptionMsg = null ) {
222225 $extension = isset( $url ) ? "[$url $name]" : $name;
223 - $version = isset( $version ) ? "(" . wfMsg( 'version-version' ) . " $version)" : '';
 226+ $version = isset( $version ) ? "(" . wfMsg( 'version-version' ) . " $version)" : '';
 227+ $subVersion = isset( $subVersion ) ? "(" . wfMsg( 'version-revision' ) . " r$subVersion)" : '';
224228
225229 # Look for a localized description
226230 if( isset( $descriptionMsg ) ) {
@@ -230,7 +234,7 @@
231235 }
232236
233237 return "<tr>
234 - <td><em>$extension $version</em></td>
 238+ <td><em>$extension $version $subVersion</em></td>
235239 <td>$description</td>
236240 <td>" . $this->listToText( (array)$author ) . "</td>
237241 </tr>\n";
@@ -337,7 +341,7 @@
338342 * @param string $dir
339343 * @return mixed revision number as int, or false if not a SVN checkout
340344 */
341 - public static function getSvnRevision( $dir ) {
 345+ public static function getSvnRevision( $dir , $extension = false) {
342346 // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html
343347 $entries = $dir . '/.svn/entries';
344348
@@ -372,8 +376,13 @@
373377 }
374378 return false;
375379 } else {
376 - // subversion is release 1.4
377 - return intval( $content[3] );
 380+ // subversion is release 1.4 or above
 381+ if ($extension)
 382+ // get the last file revsion number
 383+ return intval( $content[10]) ;
 384+ else
 385+ // get the directory revsion number
 386+ return intval( $content[3] );
378387 }
379388 }
380389
Index: trunk/phase3/languages/messages/MessagesZh_hans.php
@@ -3026,6 +3026,7 @@
30273027 'version-hook-name' => '钩名',
30283028 'version-hook-subscribedby' => '署名',
30293029 'version-version' => '版本',
 3030+'version-revision' => '修订',
30303031 'version-license' => '授权',
30313032 'version-software' => '已安装软件',
30323033 'version-software-product' => '产品',
Index: trunk/phase3/languages/messages/MessagesYue.php
@@ -2975,6 +2975,7 @@
29762976 'version-hook-name' => '鈎名',
29772977 'version-hook-subscribedby' => '利用於',
29782978 'version-version' => '版本',
 2979+'version-revision' => '修訂',
29792980 'version-license' => '牌照',
29802981 'version-software' => '裝咗嘅軟件',
29812982 'version-software-product' => '產品',
Index: trunk/phase3/languages/messages/MessagesZh_hant.php
@@ -3002,6 +3002,7 @@
30033003 'version-hook-name' => '鈎名',
30043004 'version-hook-subscribedby' => '利用於',
30053005 'version-version' => '版本',
 3006+'version-revision' => '修訂',
30063007 'version-license' => '授權',
30073008 'version-software' => '已經安裝的軟件',
30083009 'version-software-product' => '產品',
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -3834,6 +3834,7 @@
38353835 'version-hook-name' => 'Hook name',
38363836 'version-hook-subscribedby' => 'Subscribed by',
38373837 'version-version' => 'Version',
 3838+'version-revision' => 'Revision',
38383839 'version-license' => 'License',
38393840 'version-software' => 'Installed software',
38403841 'version-software-product' => 'Product',
Index: trunk/phase3/languages/messages/MessagesLzh.php
@@ -2431,6 +2431,7 @@
24322432 'version-hook-name' => '鈎名',
24332433 'version-hook-subscribedby' => '用於',
24342434 'version-version' => '版',
 2435+'version-revision' => '訂',
24352436 'version-license' => '牌',
24362437 'version-software' => '裝件',
24372438 'version-software-product' => '品',
Index: trunk/phase3/RELEASE-NOTES
@@ -177,6 +177,8 @@
178178 * Added $wgExtPGAlteredFields to allow extensions to easily alter the data
179179 type of columns when using the Postgres backend.
180180 * (bug 16950) Show move log when viewing/creating a deleted page
 181+* (bug 18242) Show the Subversion revision number per extensions in
 182+ Special:Version
181183
182184
183185 === Bug fixes in 1.15 ===
Index: trunk/extensions/Renameuser/SpecialRenameuser.php
@@ -15,6 +15,7 @@
1616 $wgGroupPermissions['bureaucrat']['renameuser'] = true;
1717
1818 $wgExtensionCredits['specialpage'][] = array(
 19+ 'path' => __FILE__,
1920 'name' => 'Renameuser',
2021 'author' => array( 'Ævar Arnfjörð Bjarmason', 'Aaron Schulz' ),
2122 'url' => 'http://www.mediawiki.org/wiki/Extension:Renameuser',
Index: trunk/extensions/AdvancedSearch/AdvancedSearch.setup.php
@@ -24,6 +24,7 @@
2525 }
2626
2727 $wgExtensionCredits['specialpage'][] = array(
 28+ 'path' => __FILE__,
2829 'name' => 'AdvancedSearch',
2930 'author' => 'Roan Kattouw',
3031 'url' => 'http://www.mediawiki.org/wiki/Extension:AdvancedSearch',
Index: trunk/extensions/AuthorProtect/AuthorProtect.php
@@ -10,6 +10,7 @@
1111 }
1212
1313 $wgExtensionCredits['other'][] = array(
 14+ 'path' => __FILE__,
1415 'name' => 'Author Protect',
1516 'author' => 'Ryan Schmidt',
1617 'url' => 'http://www.mediawiki.org/wiki/Extension:AuthorProtect',
Index: trunk/extensions/AmazonPlus/AmazonPlus.php
@@ -44,6 +44,7 @@
4545 }
4646
4747 $wgExtensionCredits['other'][] = array(
 48+ 'path' => __FILE__,
4849 'name' => 'AmazonPlus',
4950 'description' => 'A highly customizable extension to display Amazon information',
5051 'descriptionmsg' => 'amazonplus-desc',
@@ -468,4 +469,4 @@
469470 }
470471 return 'com';
471472 }
472 -}
\ No newline at end of file
 473+}
Index: trunk/extensions/AntiSpoof/AntiSpoof.php
@@ -1,6 +1,7 @@
22 <?php
33
44 $wgExtensionCredits['other'][] = array(
 5+ 'path' => __FILE__,
56 'name' => 'AntiSpoof',
67 'url' => 'http://www.mediawiki.org/wiki/Extension:AntiSpoof',
78 'author' => 'Brion Vibber',
Index: trunk/extensions/AdvancedRandom/SpecialAdvancedRandom.php
@@ -19,6 +19,7 @@
2020 */
2121
2222 $wgExtensionCredits['specialpage'][] = array(
 23+ 'path' => __FILE__,
2324 'name' => 'AdvancedRandom',
2425 'url' => 'http://www.mediawiki.org/wiki/Extension:AdvancedRandom',
2526 'description' => 'Get a random page from any namespace, the talk or subjectpage ' .
Index: trunk/extensions/AjaxShowEditors/Load.php
@@ -3,6 +3,7 @@
44 $wgAjaxShowEditorsTimeout = 60;
55
66 $wgExtensionCredits['other'][] = array(
 7+ 'path' => __FILE__,
78 'name' => 'Ajax Show Editors',
89 'url' => 'http://www.mediawiki.org/wiki/Extension:AjaxShowEditors',
910 'author' => 'Ashar Voultoiz',
Index: trunk/extensions/Autoincrement/Autoincrement.php
@@ -12,6 +12,7 @@
1313 */
1414
1515 $wgExtensionCredits['variable'][] = array(
 16+ 'path' => __FILE__,
1617 'name' => 'Autoincrement',
1718 'description' => 'a variable hook that adds an autoincrementing variable, <nowiki>{{AUTOINCREMENT}}</nowiki>',
1819 'author' => 'Ævar Arnfjörð Bjarmason',
Index: trunk/extensions/ParserFunctions/ParserFunctions.php
@@ -6,6 +6,7 @@
77
88 $wgExtensionFunctions[] = 'wfSetupParserFunctions';
99 $wgExtensionCredits['parserhook'][] = array(
 10+ 'path' => __FILE__,
1011 'name' => 'ParserFunctions',
1112 'version' => '1.1.1',
1213 'url' => 'http://www.mediawiki.org/wiki/Extension:ParserFunctions',
Index: trunk/extensions/APC/ViewAPC.php
@@ -10,6 +10,7 @@
1111 */
1212
1313 $wgExtensionCredits['specialpage'][] = array(
 14+ 'path' => __FILE__,
1415 'name' => 'Apc',
1516 'version' => '2008-09-04',
1617 'author' => 'Niklas Laxström',
Index: trunk/extensions/AjaxTest/AjaxTest.php
@@ -27,6 +27,7 @@
2828 * Register extension setup hook and credits
2929 */
3030 $wgExtensionCredits['specialpage'][] = array(
 31+ 'path' => __FILE__,
3132 'name' => 'AjaxTest',
3233 'author' => 'Daniel Kinzler',
3334 'description' => 'AjaxTest extension',
Index: trunk/extensions/ABC/ABC.php
@@ -53,6 +53,7 @@
5454 $abcDelayedRendering = false;
5555
5656 $wgExtensionCredits['parserhooks'][] = array(
 57+ 'path' => __FILE__,
5758 'name' => 'ABC',
5859 'author' => 'River Tarnell',
5960 'url' => 'http://www.mediawiki.org/wiki/Extension:ABC',
Index: trunk/extensions/CategoryTree/CategoryTree.php
@@ -109,6 +109,7 @@
110110 */
111111 $wgExtensionFunctions[] = 'efCategoryTree';
112112 $wgExtensionCredits['specialpage'][] = array(
 113+ 'path' => __FILE__,
113114 'name' => 'CategoryTree',
114115 'author' => 'Daniel Kinzler',
115116 'url' => 'http://www.mediawiki.org/wiki/Extension:CategoryTree',
@@ -116,6 +117,7 @@
117118 'descriptionmsg' => 'categorytree-desc',
118119 );
119120 $wgExtensionCredits['parserhook'][] = array(
 121+ 'path' => __FILE__,
120122 'name' => 'CategoryTree',
121123 'author' => 'Daniel Kinzler',
122124 'url' => 'http://www.mediawiki.org/wiki/Extension:CategoryTree',
@@ -389,4 +391,4 @@
390392 $result = $embed . implode ( "{$pop} {$sep} {$embed}" , $links ) . $pop;
391393
392394 return false;
393 -}
\ No newline at end of file
 395+}
Index: trunk/extensions/Nuke/SpecialNuke.php
@@ -9,6 +9,7 @@
1010 $wgExtensionAliasesFiles['Nuke'] = $dir . 'SpecialNuke.alias.php';
1111
1212 $wgExtensionCredits['specialpage'][] = array(
 13+ 'path' => __FILE__,
1314 'name' => 'Nuke',
1415 'description' => 'Gives sysops the ability to mass delete pages',
1516 'descriptionmsg' => 'nuke-desc',
Index: trunk/extensions/AbsenteeLandlord/AbsenteeLandlord.php
@@ -11,6 +11,7 @@
1212 $wgAbsenteeLandlordMaxDays = 90; //how many days do the sysops have to be inactive for?
1313
1414 $wgExtensionCredits['other'][] = array(
 15+ 'path' => __FILE__,
1516 'name' => 'Absentee Landlord',
1617 'author' => array( 'Ryan Schmidt', 'Tim Laqua' ),
1718 'version' => '1.1',
Index: trunk/extensions/AjaxLogin/AjaxLogin.php
@@ -16,6 +16,7 @@
1717
1818 // Extension credits that will show up on Special:Version
1919 $wgExtensionCredits['other'][] = array(
 20+ 'path' => __FILE__,
2021 'name' => 'AjaxLogin',
2122 'version' => '1.1.1',
2223 'author' => array( 'Inez Korczyński', 'Jack Phoenix' ),
@@ -134,4 +135,4 @@
135136 </div>' );
136137 }
137138 return true;
138 -}
\ No newline at end of file
 139+}
Index: trunk/extensions/Asksql/Asksql.php
@@ -15,6 +15,7 @@
1616 exit;
1717
1818 $wgExtensionCredits['specialpage'][] = array(
 19+ 'path' => __FILE__,
1920 'name' => 'Ask SQL',
2021 'description' => 'Do SQL queries through a [[Special:Asksql|special page]]',
2122 'descriptionmsg' => 'asksql-desc',
Index: trunk/extensions/AbuseFilter/AbuseFilter.php
@@ -17,6 +17,7 @@
1818
1919 $dir = dirname(__FILE__);
2020 $wgExtensionCredits['other'][] = array(
 21+ 'path' => __FILE__,
2122 'name' => 'Abuse Filter',
2223 'author' => array('Andrew Garrett','River Tarnell', 'Victor Vasiliev'),
2324 'description' => 'Applies automatic heuristics to edits.',
Index: trunk/extensions/Translate/Translate.php
@@ -14,6 +14,7 @@
1515 define( 'TRANSLATE_VERSION', '11:2009-04-24' );
1616
1717 $wgExtensionCredits['specialpage'][] = array(
 18+ 'path' => __FILE__,
1819 'name' => 'Translate',
1920 'version' => TRANSLATE_VERSION,
2021 'author' => array( 'Niklas Laxström', 'Siebrand Mazeland' ),
Index: trunk/extensions/AssertEdit/AssertEdit.php
@@ -18,6 +18,7 @@
1919 */
2020
2121 $wgExtensionCredits['other'][] = array(
 22+ 'path' => __FILE__,
2223 'name' => 'AssertEdit',
2324 'author' => 'Steve Sanbeg',
2425 'description' => 'Adds edit assertions for use by bots',
Index: trunk/extensions/CrossNamespaceLinks/SpecialCrossNamespaceLinks.php
@@ -12,6 +12,7 @@
1313 */
1414
1515 $wgExtensionCredits['specialpage'][] = array(
 16+ 'path' => __FILE__,
1617 'name' => 'Cross-namespace links',
1718 'description' => 'lists links across namespaces that shouldn\'t exist on Wikimedia projects',
1819 'descriptionmsg' => 'crossnamespacelinks-desc',
Index: trunk/extensions/AjaxQueryPages/Load.php
@@ -12,6 +12,7 @@
1313 );
1414 } else {
1515 $wgExtensionCredits['other'][] = array(
 16+ 'path' => __FILE__,
1617 'name' => 'Ajax Query Pages',
1718 'url' => 'http://www.mediawiki.org/wiki/Extension:AjaxQueryPages',
1819 'author' => 'Ashar Voultoiz',
Index: trunk/extensions/AntiBot/AntiBot.php
@@ -32,6 +32,7 @@
3333 /** END CONFIGURATION */
3434
3535 $wgExtensionCredits['other'][] = array(
 36+ 'path' => __FILE__,
3637 'name' => 'AntiBot',
3738 'url' => 'http://www.mediawiki.org/wiki/Extension:AntiBot',
3839 'author' => 'Tim Starling',

Follow-up revisions

RevisionCommit summaryAuthorDate
r49924Follows up r49890, adding file location itself to obtaining the revision numb...shinjiman03:15, 27 April 2009
r49926Follows up r49890, adding file location itself to obtaining the revision numb...shinjiman03:53, 27 April 2009
r49927Follows up r49890, adding file location itself to obtaining the revision numb...shinjiman04:45, 27 April 2009
r49992Follows up r49890, adding file location itself to obtaining the revision numb...shinjiman02:35, 28 April 2009

Comments

#Comment by Simetrical (talk | contribs)   19:50, 26 April 2009

Boolean parameters aren't ideal. self::getSvnRevision( $IP, true/false ) is pretty opaque. self::getSvnRevision( $IP, 'extension'/null ) would be much more readable. Also, you should add the new parameter to the getSvnRevision() documentation.

Good solution, though.  :)

Status & tagging log