Legoktm has uploaded a new change for review.

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

Change subject: Short-circuit LinkBegin hook if no title is set in the main 
context
......................................................................

Short-circuit LinkBegin hook if no title is set in the main context

If there is no title set in the main context, this hook won't do
anything, so skip early on. Notably, this will prevent any code in the
LinkBeginHookHandler class from accessing User/session related functions
in MW_NO_SESSION mode.

Bug: T131176
Change-Id: I67b7c5a325560f8fcbaa8bf261ff8b8ceb259a8d
---
M repo/includes/Hooks/LinkBeginHookHandler.php
1 file changed, 6 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/64/282064/1

diff --git a/repo/includes/Hooks/LinkBeginHookHandler.php 
b/repo/includes/Hooks/LinkBeginHookHandler.php
index 422ad3d..1017a6e 100644
--- a/repo/includes/Hooks/LinkBeginHookHandler.php
+++ b/repo/includes/Hooks/LinkBeginHookHandler.php
@@ -94,9 +94,14 @@
        public static function onLinkBegin( $skin, $target, &$html, array 
&$customAttribs, &$query,
                &$options, &$ret
        ) {
-               $handler = self::newFromGlobalState();
                $context = RequestContext::getMain();
+               if ( !$context->hasTitle() ) {
+                       // Short-circuit this hook if no title is
+                       // set in the main context (T131176)
+                       return true;
+               }
 
+               $handler = self::newFromGlobalState();
                $handler->doOnLinkBegin( $target, $html, $customAttribs, 
$context );
 
                return true;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I67b7c5a325560f8fcbaa8bf261ff8b8ceb259a8d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

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

Reply via email to