r63914 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63913‎ | r63914 | r63915 >
Date:16:41, 18 March 2010
Author:demon
Status:ok (Comments)
Tags:
Comment:
Refactor MergeHistory to subclass SpecialPage. Ohai unloved code :)
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMergeHistory.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/AutoLoader.php
@@ -560,6 +560,7 @@
561561 'SpecialExport' => 'includes/specials/SpecialExport.php',
562562 'SpecialImport' => 'includes/specials/SpecialImport.php',
563563 'SpecialListGroupRights' => 'includes/specials/SpecialListgrouprights.php',
 564+ 'SpecialMergeHistory' => 'includes/specials/SpecialMergeHistory.php',
564565 'SpecialMostlinkedtemplates' => 'includes/specials/SpecialMostlinkedtemplates.php',
565566 'SpecialPreferences' => 'includes/specials/SpecialPreferences.php',
566567 'SpecialPrefixindex' => 'includes/specials/SpecialPrefixindex.php',
Index: trunk/phase3/includes/specials/SpecialMergeHistory.php
@@ -3,32 +3,18 @@
44 * Special page allowing users with the appropriate permissions to
55 * merge article histories, with some restrictions
66 *
7 - * @file
87 * @ingroup SpecialPage
98 */
10 -
11 -/**
12 - * Constructor
13 - */
14 -function wfSpecialMergehistory( $par ) {
15 - global $wgRequest;
16 -
17 - $form = new MergehistoryForm( $wgRequest, $par );
18 - $form->execute();
19 -}
20 -
21 -/**
22 - * The HTML form for Special:MergeHistory, which allows users with the appropriate
23 - * permissions to view and restore deleted content.
24 - * @ingroup SpecialPage
25 - */
26 -class MergehistoryForm {
 9+class SpecialMergeHistory extends SpecialPage {
2710 var $mAction, $mTarget, $mDest, $mTimestamp, $mTargetID, $mDestID, $mComment;
2811 var $mTargetObj, $mDestObj;
2912
30 - function MergehistoryForm( $request, $par = "" ) {
31 - global $wgUser;
 13+ public function __construct() {
 14+ parent::__construct( 'MergeHistory', 'mergehistory' );
 15+ }
3216
 17+ private function loadRequestParams( $request ) {
 18+ global $wgUser;
3319 $this->mAction = $request->getVal( 'action' );
3420 $this->mTarget = $request->getVal( 'target' );
3521 $this->mDest = $request->getVal( 'dest' );
@@ -51,7 +37,6 @@
5238 $this->mTargetObj = null;
5339 $this->mDestObj = null;
5440 }
55 -
5641 $this->preCacheMessages();
5742 }
5843
@@ -66,9 +51,16 @@
6752 }
6853 }
6954
70 - function execute() {
71 - global $wgOut;
 55+ function execute( $par = '' ) {
 56+ global $wgOut, $wgRequest, $wgUser;
7257
 58+ if( !$wgUser->isAllowed( 'mergehistory' ) ) {
 59+ $wgOut->permissionRequired( 'mergehistory' );
 60+ return;
 61+ }
 62+
 63+ $this->loadRequestParams( $wgRequest );
 64+
7365 $wgOut->setPagetitle( wfMsgHtml( "mergehistory" ) );
7466
7567 if( $this->mTargetID && $this->mDestID && $this->mAction=="submit" && $this->mMerge ) {
@@ -122,8 +114,7 @@
123115 '<fieldset>' .
124116 Xml::element( 'legend', array(),
125117 wfMsg( 'mergehistory-box' ) ) .
126 - Xml::hidden( 'title',
127 - SpecialPage::getTitleFor( 'Mergehistory' )->getPrefixedDbKey() ) .
 118+ Xml::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
128119 Xml::hidden( 'submitted', '1' ) .
129120 Xml::hidden( 'mergepoint', $this->mTimestamp ) .
130121 Xml::openElement( 'table' ) .
@@ -154,7 +145,7 @@
155146 $revisions = new MergeHistoryPager( $this, array(), $this->mTargetObj, $this->mDestObj );
156147 $haveRevisions = $revisions && $revisions->getNumRows() > 0;
157148
158 - $titleObj = SpecialPage::getTitleFor( "Mergehistory" );
 149+ $titleObj = $this->getTitle();
159150 $action = $titleObj->getLocalURL( array( 'action' => 'submit' ) );
160151 # Start the form here
161152 $top = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'merge' ) );
Index: trunk/phase3/includes/SpecialPage.php
@@ -168,7 +168,7 @@
169169 'Import' => 'SpecialImport',
170170 'Undelete' => array( 'SpecialPage', 'Undelete', 'deletedhistory' ),
171171 'Whatlinkshere' => 'SpecialWhatlinkshere',
172 - 'MergeHistory' => array( 'SpecialPage', 'MergeHistory', 'mergehistory' ),
 172+ 'MergeHistory' => 'SpecialMergeHistory',
173173
174174 # Other
175175 'Booksources' => 'SpecialBookSources',

Follow-up revisions

RevisionCommit summaryAuthorDate
r63916* Follow-up r63914: SpecialPage has methods for that, use them ;)...ialex17:36, 18 March 2010
r63959Followup r63914, function must match parentdemon21:18, 19 March 2010

Comments

#Comment by Raymond (talk | contribs)   06:46, 19 March 2010

Seen at translatewiki today:

  • PHP Strict Standards: Declaration of SpecialMergeHistory::execute() should be compatible with that of SpecialPage::execute() in /www/w/includes/specials/SpecialMergeHistory.php on line 387
  • PHP Strict Standards: Declaration of SpecialMergeHistory::execute() should be compatible with that of SpecialPage::execute() in /www/w/includes/AutoLoader.php on line 655
#Comment by 😂 (talk | contribs)   21:19, 19 March 2010

Fix this in r63959.

Status & tagging log