TTO has uploaded a new change for review.

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

Change subject: Remove some uses of $wgTitle in core
......................................................................

Remove some uses of $wgTitle in core

- EditPage no longer uses $wgTitle. It now always uses the $this->mTitle
  member variable.

  In core, the code that read $wgTitle was only used by action=edit itself.
  As far as I can tell, $wgTitle and $this->mTitle always point to the same
  title in this scenario.

  No extensions in Git are affected.

- Linker::makeExternalLink no longer uses $wgTitle. This means that if
  the optional $title parameter is not passed in, the value of
  $wgNoFollowNsExceptions will not be checked when deciding whether or not
  to add rel="nofollow" to the link. Arguably $title should be made a
  mandatory parameter, but its place in the argument list makes this
  problematic.

  Uses of this function in core are updated to take account of this change.

  Extensions using this function are doing so from a special page
  or other non-user-content context, so do not require any change.

- Parser::transformMsg no longer uses $wgTitle if the $title parameter is
  null, instead using the $mTitle member variable.

  This doesn't affect core, but does affect the SemanticForms and
  Intersection extensions. (SemanticForms is still using $wgParser, so I'm
  not going to bother patching it. They can figure it out themselves.)

  Patch for Intersection is I17cb16fc3f9912cff1832d7eec09c4d9048f146c

Bug: T25307
Change-Id: I69ae09dabfcadafc1f964e2770ee184e2b34116e
---
M RELEASE-NOTES-1.27
M includes/EditPage.php
M includes/Linker.php
M includes/api/ApiEditPage.php
M includes/api/ApiParse.php
M includes/parser/Parser.php
6 files changed, 36 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/30/263030/1

diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27
index 9b12b72..329db8e 100644
--- a/RELEASE-NOTES-1.27
+++ b/RELEASE-NOTES-1.27
@@ -61,6 +61,7 @@
   $wgSharedDB and $wgSharedTables are properly set even on the "central" wiki
   that all others are sharing from and that $wgLocalDatabases is set to the
   full list of sharing wikis on all those wikis.
+* Adding NS_SPECIAL (-1) to $wgNoFollowNsExceptions no longer has any effect.
 
 === New features in 1.27 ===
 * $wgDataCenterId and $wgDataCenterRoles where added, which will serve as
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 47912cb..c3c23b3 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -436,15 +436,12 @@
 
        /**
         * Get the context title object.
-        * If not set, $wgTitle will be returned. This behavior might change in
-        * the future to return $this->mTitle instead.
         *
         * @return Title
         */
        public function getContextTitle() {
                if ( is_null( $this->mContextTitle ) ) {
-                       global $wgTitle;
-                       return $wgTitle;
+                       return $this->mTitle;
                } else {
                        return $this->mContextTitle;
                }
diff --git a/includes/Linker.php b/includes/Linker.php
index 80e4c62..6df37c9 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -1038,13 +1038,14 @@
         * @param bool $escape Do we escape the link text?
         * @param string $linktype Type of external link. Gets added to the 
classes
         * @param array $attribs Array of extra attributes to <a>
-        * @param Title|null $title Title object used for title specific link 
attributes
+        * @param Title|null $title Title object used for title specific link
+        * attributes. This parameter is only relevant when the external link is
+        * in page content, and should be left null for links in the UI
         * @return string
         */
        public static function makeExternalLink( $url, $text, $escape = true,
                $linktype = '', $attribs = array(), $title = null
        ) {
-               global $wgTitle;
                $class = "external";
                if ( $linktype ) {
                        $class .= " $linktype";
@@ -1058,9 +1059,6 @@
                        $text = htmlspecialchars( $text );
                }
 
-               if ( !$title ) {
-                       $title = $wgTitle;
-               }
                $attribs['rel'] = Parser::getExternalLinkRel( $url, $title );
                $link = '';
                $success = Hooks::run( 'LinkerMakeExternalLink',
@@ -1509,7 +1507,10 @@
                                        $title->getFragment()
                                ),
                                $text,
-                               /* escape = */ false // Already escaped
+                               /* escape = */ false, // Already escaped
+                               /* linktype = */ '',
+                               /* attribs = */ array(),
+                               $title
                        );
                } else {
                        $link = Linker::link( $title, $text, array(), array(), 
$options );
diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php
index 59264e8..a98aca9 100644
--- a/includes/api/ApiEditPage.php
+++ b/includes/api/ApiEditPage.php
@@ -378,7 +378,7 @@
 
                $req = new DerivativeRequest( $this->getRequest(), 
$requestArray, true );
 
-               // Some functions depend on $wgTitle == $ep->mTitle
+               // Some hooks might possibly depend on $wgTitle == $ep->mTitle
                // TODO: Make them not or check if they still do
                $wgTitle = $titleObj;
 
diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index 5754c23..4d7996f 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -79,7 +79,7 @@
                        $this->section = false;
                }
 
-               // The parser needs $wgTitle to be set, apparently the
+               // Some parser hooks may still require $wgTitle to be set, 
apparently the
                // $title parameter in Parser::parse isn't enough *sigh*
                // TODO: Does this still need $wgTitle?
                global $wgParser, $wgTitle;
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 7b4a650..4fb54d0 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -1444,7 +1444,14 @@
                                        substr( $m[0], 0, 20 ) . '"' );
                        }
                        $url = wfMessage( $urlmsg, $id 
)->inContentLanguage()->text();
-                       return Linker::makeExternalLink( $url, "{$keyword} 
{$id}", true, $cssClass );
+                       return Linker::makeExternalLink(
+                               $url,
+                               "{$keyword} {$id}",
+                               true,
+                               $cssClass,
+                               array(),
+                               $this->getTitle()
+                       );
                } elseif ( isset( $m[6] ) && $m[6] !== '' ) {
                        # ISBN
                        $isbn = $m[6];
@@ -1529,10 +1536,14 @@
                $text = $this->maybeMakeExternalImage( $url );
                if ( $text === false ) {
                        # Not an image, make a link
-                       $text = Linker::makeExternalLink( $url,
+                       $text = Linker::makeExternalLink(
+                               $url,
                                
$this->getConverterLanguage()->markNoConversion( $url, true ),
-                               true, 'free',
-                               $this->getExternalLinkAttribs( $url ) );
+                               true,
+                               'free',
+                               $this->getExternalLinkAttribs( $url ),
+                               $this->getTitle()
+                       );
                        # Register it in the output object...
                        # Replace unnecessary URL escape codes with their 
equivalent characters
                        $pasteurized = self::normalizeLinkUrl( $url );
@@ -1828,8 +1839,14 @@
                        # This means that users can paste URLs directly into 
the text
                        # Funny characters like รถ aren't valid in URLs anyway
                        # This was changed in August 2004
-                       $s .= Linker::makeExternalLink( $url, $text, false, 
$linktype,
-                               $this->getExternalLinkAttribs( $url ) ) . 
$dtrail . $trail;
+                       $s .= Linker::makeExternalLink(
+                               $url,
+                               $text,
+                               false,
+                               $linktype,
+                               $this->getExternalLinkAttribs( $url ),
+                               $this->getTitle()
+                       ) . $dtrail . $trail;
 
                        # Register link in the output object.
                        # Replace unnecessary URL escape codes with the 
referenced character
@@ -5066,7 +5083,7 @@
         *
         * @param string $text The text to preprocess
         * @param ParserOptions $options Options
-        * @param Title|null $title Title object or null to use $wgTitle
+        * @param Title|null $title Title object
         * @return string
         */
        public function transformMsg( $text, $options, $title = null ) {
@@ -5079,8 +5096,7 @@
                $executing = true;
 
                if ( !$title ) {
-                       global $wgTitle;
-                       $title = $wgTitle;
+                       $title = $this->getTitle();
                }
 
                $text = $this->preprocess( $text, $title, $options );

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

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

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

Reply via email to