Daniel Kinzler has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/84965


Change subject: Fix initialization of Context in Action class.
......................................................................

Fix initialization of Context in Action class.

When Action::getActionName calls Action::factory, $context
must be passed explicitly, since WikiPage does not have a getContext()
method (only Article does).

As a failsafe in Article::getContext(), use $this->page->getContext()
only if $this->page is an Article. If $this->context is null and $this->page
is not an article, fall back to RequestContext::getMain()

Change-Id: I6d8db29dfd1aaa68f3de4f8f418841205c2379af
---
M includes/Action.php
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/65/84965/1

diff --git a/includes/Action.php b/includes/Action.php
index 23b648f..f387855 100644
--- a/includes/Action.php
+++ b/includes/Action.php
@@ -142,7 +142,7 @@
                        return 'view';
                }
 
-               $action = Action::factory( $actionName, $context->getWikiPage() 
);
+               $action = Action::factory( $actionName, 
$context->getWikiPage(), $context );
                if ( $action instanceof Action ) {
                        return $action->getName();
                }
@@ -167,8 +167,11 @@
        final public function getContext() {
                if ( $this->context instanceof IContextSource ) {
                        return $this->context;
+               } else if ( $this->page instanceof Article ) {
+                       return $this->page->getContext();
                }
-               return $this->page->getContext();
+
+               return RequestContext::getMain();
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/84965
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d8db29dfd1aaa68f3de4f8f418841205c2379af
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to