r89006 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89005‎ | r89006 | r89007 >
Date:22:44, 27 May 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
followup r89002: nasty trick to support both the old and the new signatures for the userCanExecute() method
Modified paths:
  • /trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php
@@ -14,7 +14,7 @@
1515 /**
1616 * @ingroup SFSpecialPages
1717 */
18 -class SFUploadWindow2 extends UnlistedSpecialPage {
 18+class SFUploadWindow2Proto extends UnlistedSpecialPage {
1919 /**
2020 * Constructor : initialise object
2121 * Get data POSTed through the form and assign them to the object
@@ -105,23 +105,6 @@
106106 }
107107
108108 /**
109 - * This page can be shown if uploading is enabled.
110 - * Handle permission checking elsewhere in order to be able to show
111 - * custom error messages.
112 - *
113 - * @param User $user
114 - * @return bool
115 - */
116 - // @TODO The "User" class was added to the function header
117 - // for SpecialPage::userCanExecute in MW 1.19 (r86407) - somehow
118 - // both the old and new signatures need to be supported. For now,
119 - // though, support only the old signature, since that's used by
120 - // the vast majority of users.
121 - public function userCanExecute( $user ) {
122 - return UploadBase::isEnabled() && parent::userCanExecute( $user );
123 - }
124 -
125 - /**
126109 * Special page entry point
127110 */
128111 public function execute( $par ) {
@@ -1101,3 +1084,51 @@
11021085 }
11031086
11041087 }
 1088+
 1089+global $wgVersion;
 1090+// @TODO The "User" class was added to the function header
 1091+// for SpecialPage::userCanExecute in MW 1.19 (r86407) - somehow
 1092+// both the old and new signatures need to be supported. When support
 1093+// is dropped for MW below 1.19 this should be reintegrated into one
 1094+// class.
 1095+if ( version_compare( $wgVersion, '1.18alpha', '<' )) {
 1096+
 1097+ /**
 1098+ * Class variant for MW up to 1.17
 1099+ */
 1100+ class SFUploadWindow2 extends SFUploadWindow2Proto {
 1101+ /**
 1102+ * This page can be shown if uploading is enabled.
 1103+ * Handle permission checking elsewhere in order to be able to show
 1104+ * custom error messages.
 1105+ *
 1106+ * @param User $user
 1107+ * @return bool
 1108+ */
 1109+ public function userCanExecute( $user ) {
 1110+ return UploadBase::isEnabled() && parent::userCanExecute( $user );
 1111+ }
 1112+
 1113+
 1114+ }
 1115+
 1116+} else {
 1117+
 1118+ /**
 1119+ * Class variant for MW 1.18+
 1120+ */
 1121+ class SFUploadWindow2 extends SFUploadWindow2Proto {
 1122+ /**
 1123+ * This page can be shown if uploading is enabled.
 1124+ * Handle permission checking elsewhere in order to be able to show
 1125+ * custom error messages.
 1126+ *
 1127+ * @param User $user
 1128+ * @return bool
 1129+ */
 1130+ public function userCanExecute( User $user ) {
 1131+ return UploadBase::isEnabled() && parent::userCanExecute( $user );
 1132+ }
 1133+ }
 1134+
 1135+}
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r89007followup r89006: fix commentfoxtrott22:45, 27 May 2011
r89009followup r89006: use feature detection instead of MW version checkfoxtrott23:16, 27 May 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89002Undoing r86505 - unfortunately, it's beyond my PHP abilities to support both ...yaron22:23, 27 May 2011