r89009 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89008‎ | r89009 | r89010 >
Date:23:16, 27 May 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
followup r89006: use feature detection instead of MW version check
Modified paths:
  • /trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php
@@ -1086,15 +1086,17 @@
10871087 }
10881088
10891089 global $wgVersion;
 1090+$uceMethod = new ReflectionMethod( 'SpecialPage', 'userCanExecute' );
 1091+$uceParams = $uceMethod->getParameters();
10901092 // @TODO The "User" class was added to the function header
10911093 // for SpecialPage::userCanExecute in MW 1.18 (r86407) - somehow
10921094 // both the old and new signatures need to be supported. When support
10931095 // is dropped for MW below 1.18 this should be reintegrated into one
10941096 // class.
1095 -if ( version_compare( $wgVersion, '1.18alpha', '<' )) {
 1097+if ( $uceParams[0]->getClass() ) { // found a class definition for param $user
10961098
10971099 /**
1098 - * Class variant for MW up to 1.17
 1100+ * Class variant for MW 1.18+
10991101 */
11001102 class SFUploadWindow2 extends SFUploadWindow2Proto {
11011103 /**
@@ -1105,7 +1107,7 @@
11061108 * @param User $user
11071109 * @return bool
11081110 */
1109 - public function userCanExecute( $user ) {
 1111+ public function userCanExecute( User $user ) {
11101112 return UploadBase::isEnabled() && parent::userCanExecute( $user );
11111113 }
11121114
@@ -1115,7 +1117,7 @@
11161118 } else {
11171119
11181120 /**
1119 - * Class variant for MW 1.18+
 1121+ * Class variant for MW up to 1.17
11201122 */
11211123 class SFUploadWindow2 extends SFUploadWindow2Proto {
11221124 /**
@@ -1126,7 +1128,7 @@
11271129 * @param User $user
11281130 * @return bool
11291131 */
1130 - public function userCanExecute( User $user ) {
 1132+ public function userCanExecute( $user ) {
11311133 return UploadBase::isEnabled() && parent::userCanExecute( $user );
11321134 }
11331135 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89006followup r89002: nasty trick to support both the old and the new signatures f...foxtrott22:44, 27 May 2011