aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Action.php
diff options
context:
space:
mode:
authorSiebrand Mazeland <siebrand@users.mediawiki.org>2011-04-25 18:20:53 +0000
committerSiebrand Mazeland <siebrand@users.mediawiki.org>2011-04-25 18:20:53 +0000
commit02e44a71b036783edc6ffba29068f9ea9d311fbc (patch)
tree1753bd044269e29b987cb2a753f95fa89ecfb89f /includes/Action.php
parent70bdc008c4d977bc6df47c516709cde23770aca2 (diff)
downloadmediawikicore-02e44a71b036783edc6ffba29068f9ea9d311fbc.tar.gz
mediawikicore-02e44a71b036783edc6ffba29068f9ea9d311fbc.zip
Revert r86872: Breaks LiquidThreads page moves with the below failure. Threads are lost and nowhere to be found any more.
[25-Apr-2011 18:12:45] /wiki/Special:MoveThread/Thread:User_talk:Siebrand/test/One_new_message: Exception: MWNamespace::getTalk does not make any sense for given namespace -1 #0 /www/w/includes/Namespace.php(81): MWNamespace::isMethodValidFor(-1, 'MWNamespace::ge...') #1 /www/w/includes/WatchedItem.php(73): MWNamespace::getTalk(-1) #2 /www/w/includes/User.php(2304): WatchedItem->addWatch() #3 /www/w/includes/actions/WatchAction.php(53): User->addWatch(Object(Title)) #4 /www/w/includes/Action.php(376): WatchAction->onView() #5 /www/w/extensions/LiquidThreads/classes/Thread.php(115): FormlessAction->execute() #6 /www/w/extensions/LiquidThreads/classes/Thread.php(435): Thread::create(Object(Article), Object(Article), NULL, 1, 'One new message') #7 /www/w/extensions/LiquidThreads/classes/Thread.php(414): Thread->leaveTrace('move test', Object(Title), Object(Title)) #8 /www/w/extensions/LiquidThreads/pages/SpecialMoveThread.php(107): Thread->moveToPage(Object(Title), 'move test', true) #9 [internal function]: SpecialMoveThread->trySubmit(Array) #10 /www/w/includes/HTMLForm.php(279): call_user_func(Array, Array) #11 /www/w/includes/HTMLForm.php(228): HTMLForm->trySubmit() #12 /www/w/includes/HTMLForm.php(242): HTMLForm->tryAuthorizedSubmit() #13 /www/w/extensions/LiquidThreads/pages/ThreadActionPage.php(37): HTMLForm->show() #14 /www/w/includes/SpecialPageFactory.php(459): ThreadActionPage->execute('Thread:User_tal...') #15 /www/w/includes/Wiki.php(252): SpecialPageFactory::executePath(Object(Title), Object(RequestContext)) #16 /www/w/includes/Wiki.php(98): MediaWiki->handleSpecialCases() #17 /www/w/index.php(145): MediaWiki->performRequestForTitle(NULL) #18 {main}
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/86875
Diffstat (limited to 'includes/Action.php')
-rw-r--r--includes/Action.php78
1 files changed, 72 insertions, 6 deletions
diff --git a/includes/Action.php b/includes/Action.php
index 032d0949b586..5fbb5c701331 100644
--- a/includes/Action.php
+++ b/includes/Action.php
@@ -23,12 +23,16 @@
*
* @file
*/
-abstract class Action extends ContextSource {
+abstract class Action {
// Page on which we're performing the action
// @var Article
protected $page;
+ // RequestContext if specified; otherwise we'll use the Context from the Page
+ // @var RequestContext
+ protected $context;
+
// The fields used to create the HTMLForm
// @var Array
protected $fields;
@@ -87,13 +91,76 @@ abstract class Action extends ContextSource {
}
/**
+ * Get the RequestContext in use here
+ * @return RequestContext
+ */
+ protected final function getContext() {
+ if ( $this->context instanceof RequestContext ) {
+ return $this->context;
+ }
+ return $this->page->getContext();
+ }
+
+ /**
+ * Get the WebRequest being used for this instance
+ *
+ * @return WebRequest
+ */
+ protected final function getRequest() {
+ return $this->getContext()->request;
+ }
+
+ /**
+ * Get the OutputPage being used for this instance
+ *
+ * @return OutputPage
+ */
+ protected final function getOutput() {
+ return $this->getContext()->output;
+ }
+
+ /**
+ * Shortcut to get the User being used for this instance
+ *
+ * @return User
+ */
+ protected final function getUser() {
+ return $this->getContext()->user;
+ }
+
+ /**
+ * Shortcut to get the Skin being used for this instance
+ *
+ * @return Skin
+ */
+ protected final function getSkin() {
+ return $this->getContext()->skin;
+ }
+
+ /**
+ * Shortcut to get the user Language being used for this instance
+ *
+ * @return Skin
+ */
+ protected final function getLang() {
+ return $this->getContext()->lang;
+ }
+
+ /**
+ * Shortcut to get the Title object from the page
+ * @return Title
+ */
+ protected final function getTitle() {
+ return $this->page->getTitle();
+ }
+
+ /**
* Protected constructor: use Action::factory( $action, $page ) to actually build
* these things in the real world
* @param Article $page
*/
protected function __construct( Article $page ) {
$this->page = $page;
- $this->setContext( $page->getContext() );
}
/**
@@ -282,7 +349,7 @@ abstract class FormAction extends Action {
public function execute( array $data = null, $captureErrors = true ) {
try {
// Set a new context so output doesn't leak.
- $this->setContext( clone $this->page->getContext() );
+ $this->context = clone $this->page->getContext();
// This will throw exceptions if there's a problem
$this->checkCanExecute( $this->getUser() );
@@ -364,11 +431,10 @@ abstract class FormlessAction extends Action {
public function execute( array $data = null, $captureErrors = true ) {
try {
// Set a new context so output doesn't leak.
- $context = clone $this->page->getContext();
+ $this->context = clone $this->page->getContext();
if ( is_array( $data ) ) {
- $context->setRequest( new FauxRequest( $data, false ) );
+ $this->context->setRequest( new FauxRequest( $data, false ) );
}
- $this->setContext( $context );
// This will throw exceptions if there's a problem
$this->checkCanExecute( $this->getUser() );