r99570 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99569‎ | r99570 | r99571 >
Date:21:08, 11 October 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
Contest: Fix version check. Has to check for >1.18 rather than >=1.19 because version_compare() behaves strangely for versions like 1.19alpha and 1.19wmf1
Modified paths:
  • /trunk/extensions/Contest/includes/ContestantPager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/includes/ContestantPager.php
@@ -102,7 +102,7 @@
103103 * @return OutputPage
104104 */
105105 public function getOutput() {
106 - return version_compare( $GLOBALS['wgVersion'], '1.19', '>=' ) ? parent::getOutput() : $GLOBALS['wgOut'];
 106+ return version_compare( $GLOBALS['wgVersion'], '1.18', '>' ) ? parent::getOutput() : $GLOBALS['wgOut'];
107107 }
108108
109109 /**
@@ -114,7 +114,7 @@
115115 * @return Language
116116 */
117117 public function getLang() {
118 - return version_compare( $GLOBALS['wgVersion'], '1.19', '>=' ) ? parent::getLang() : $GLOBALS['wgLang'];
 118+ return version_compare( $GLOBALS['wgVersion'], '1.18', '>' ) ? parent::getLang() : $GLOBALS['wgLang'];
119119 }
120120
121121 public function getFieldNames() {

Comments

#Comment by Dantman (talk | contribs)   21:20, 11 October 2011

It's not exactly strange, 1.19alpha is earlier than 1.19 release so php treats it that way. Hence a lot of comparisons actually use version_compare( $wgVersion, '1.19alpha', '>=' ); though I admit it's a little strange with the wmf1.

In any case, in this situation you should be feature testing not version testing.

method_exists( 'TablePager', 'getLang' );

Status & tagging log