r104011 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104010‎ | r104011 | r104012 >
Date:09:53, 23 November 2011
Author:johnduhart
Status:ok
Tags:
Comment:
Followup r103817, backing out ContextSource changes to SpecialPage and Action
Modified paths:
  • /trunk/phase3/includes/Action.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPage.php
@@ -27,7 +27,7 @@
2828 * page list.
2929 * @ingroup SpecialPage
3030 */
31 -class SpecialPage extends ContextSource {
 31+class SpecialPage {
3232
3333 // The canonical name of this special page
3434 // Also used for the default <h1> heading, @see getDescription()
@@ -612,6 +612,92 @@
613613 }
614614
615615 /**
 616+ * Sets the context this SpecialPage is executed in
 617+ *
 618+ * @param $context IContextSource
 619+ * @since 1.18
 620+ */
 621+ public function setContext( $context ) {
 622+ $this->mContext = $context;
 623+ }
 624+
 625+ /**
 626+ * Gets the context this SpecialPage is executed in
 627+ *
 628+ * @return IContextSource
 629+ * @since 1.18
 630+ */
 631+ public function getContext() {
 632+ if ( $this->mContext instanceof IContextSource ) {
 633+ return $this->mContext;
 634+ } else {
 635+ wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
 636+ return RequestContext::getMain();
 637+ }
 638+ }
 639+
 640+ /**
 641+ * Get the WebRequest being used for this instance
 642+ *
 643+ * @return WebRequest
 644+ * @since 1.18
 645+ */
 646+ public function getRequest() {
 647+ return $this->getContext()->getRequest();
 648+ }
 649+
 650+ /**
 651+ * Get the OutputPage being used for this instance
 652+ *
 653+ * @return OutputPage
 654+ * @since 1.18
 655+ */
 656+ public function getOutput() {
 657+ return $this->getContext()->getOutput();
 658+ }
 659+
 660+ /**
 661+ * Shortcut to get the User executing this instance
 662+ *
 663+ * @return User
 664+ * @since 1.18
 665+ */
 666+ public function getUser() {
 667+ return $this->getContext()->getUser();
 668+ }
 669+
 670+ /**
 671+ * Shortcut to get the skin being used for this instance
 672+ *
 673+ * @return Skin
 674+ * @since 1.18
 675+ */
 676+ public function getSkin() {
 677+ return $this->getContext()->getSkin();
 678+ }
 679+
 680+ /**
 681+ * Shortcut to get user's language
 682+ *
 683+ * @deprecated 1.19 Use getLanguage instead
 684+ * @return Language
 685+ * @since 1.18
 686+ */
 687+ public function getLang() {
 688+ return $this->getLanguage();
 689+ }
 690+
 691+ /**
 692+ * Shortcut to get user's language
 693+ *
 694+ * @return Language
 695+ * @since 1.19
 696+ */
 697+ public function getLanguage() {
 698+ return $this->getContext()->getLanguage();
 699+ }
 700+
 701+ /**
616702 * Return the full title, including $par
617703 *
618704 * @return Title
Index: trunk/phase3/includes/Action.php
@@ -23,7 +23,7 @@
2424 *
2525 * @file
2626 */
27 -abstract class Action extends ContextSource {
 27+abstract class Action {
2828
2929 /**
3030 * Page on which we're performing the action
@@ -96,6 +96,91 @@
9797 }
9898
9999 /**
 100+ * Get the IContextSource in use here
 101+ * @return IContextSource
 102+ */
 103+ public final function getContext() {
 104+ if ( $this->context instanceof IContextSource ) {
 105+ return $this->context;
 106+ }
 107+ return $this->page->getContext();
 108+ }
 109+
 110+ /**
 111+ * Get the WebRequest being used for this instance
 112+ *
 113+ * @return WebRequest
 114+ */
 115+ public final function getRequest() {
 116+ return $this->getContext()->getRequest();
 117+ }
 118+
 119+ /**
 120+ * Get the OutputPage being used for this instance
 121+ *
 122+ * @return OutputPage
 123+ */
 124+ public final function getOutput() {
 125+ return $this->getContext()->getOutput();
 126+ }
 127+
 128+ /**
 129+ * Shortcut to get the User being used for this instance
 130+ *
 131+ * @return User
 132+ */
 133+ public final function getUser() {
 134+ return $this->getContext()->getUser();
 135+ }
 136+
 137+ /**
 138+ * Shortcut to get the Skin being used for this instance
 139+ *
 140+ * @return Skin
 141+ */
 142+ public final function getSkin() {
 143+ return $this->getContext()->getSkin();
 144+ }
 145+
 146+ /**
 147+ * Shortcut to get the user Language being used for this instance
 148+ *
 149+ * @return Skin
 150+ */
 151+ public final function getLanguage() {
 152+ return $this->getContext()->getLanguage();
 153+ }
 154+
 155+ /**
 156+ * Shortcut to get the user Language being used for this instance
 157+ *
 158+ * @deprecated 1.19 Use getLanguage instead
 159+ * @return Skin
 160+ */
 161+ public final function getLang() {
 162+ return $this->getLanguage();
 163+ }
 164+
 165+ /**
 166+ * Shortcut to get the Title object from the page
 167+ * @return Title
 168+ */
 169+ public final function getTitle() {
 170+ return $this->page->getTitle();
 171+ }
 172+
 173+ /**
 174+ * Get a Message object with context set
 175+ * Parameters are the same as wfMessage()
 176+ *
 177+ * @return Message object
 178+ */
 179+ public final function msg() {
 180+ $params = func_get_args();
 181+ return call_user_func_array( array( $this->getContext(), 'msg' ), $params );
 182+ }
 183+
 184+ /**
100185 * Protected constructor: use Action::factory( $action, $page ) to actually build
101186 * these things in the real world
102187 * @param Page $page

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103817Bug 29524 - Rename RequestContext::getLang to getLanguage...johnduhart16:13, 21 November 2011

Status & tagging log