Merge "Split out doBlockLevels() into its own class"
[lhc/web/wiklou.git] / includes / Title.php
index 3fd4631..65b2d3a 100644 (file)
@@ -21,6 +21,9 @@
  *
  * @file
  */
+use MediaWiki\Linker\LinkTarget;
+
+use MediaWiki\MediaWikiServices;
 
 /**
  * Represents a title within MediaWiki.
@@ -255,7 +258,9 @@ class Title implements LinkTarget {
                return self::makeTitle(
                        $linkTarget->getNamespace(),
                        $linkTarget->getText(),
-                       $linkTarget->getFragment() );
+                       $linkTarget->getFragment(),
+                       $linkTarget->getInterwiki()
+               );
        }
 
        /**
@@ -870,7 +875,9 @@ class Title implements LinkTarget {
                                $this->mTitleValue = new TitleValue(
                                        $this->getNamespace(),
                                        $this->getDBkey(),
-                                       $this->getFragment() );
+                                       $this->getFragment(),
+                                       $this->getInterwiki()
+                               );
                        } catch ( InvalidArgumentException $ex ) {
                                wfDebug( __METHOD__ . ': Can\'t create a TitleValue for [[' .
                                        $this->getPrefixedText() . ']]: ' . $ex->getMessage() . "\n" );
@@ -1376,7 +1383,8 @@ class Title implements LinkTarget {
         * specified fragment before setting, so it assumes you're passing it with
         * an initial "#".
         *
-        * Deprecated for public use, use Title::makeTitle() with fragment parameter.
+        * Deprecated for public use, use Title::makeTitle() with fragment parameter,
+        * or Title::createFragmentTarget().
         * Still in active use privately.
         *
         * @private
@@ -1386,6 +1394,23 @@ class Title implements LinkTarget {
                $this->mFragment = strtr( substr( $fragment, 1 ), '_', ' ' );
        }
 
+       /**
+        * Creates a new Title for a different fragment of the same page.
+        *
+        * @since 1.27
+        * @param string $fragment
+        * @return Title
+        */
+       public function createFragmentTarget( $fragment ) {
+               return self::makeTitle(
+                       $this->getNamespace(),
+                       $this->getText(),
+                       $fragment,
+                       $this->getInterwiki()
+               );
+
+       }
+
        /**
         * Prefix some arbitrary text with the namespace or interwiki prefix
         * of this object
@@ -4415,7 +4440,8 @@ class Title implements LinkTarget {
                        $this->mNotificationTimestamp = [];
                }
 
-               $watchedItem = WatchedItemStore::getDefaultInstance()->getWatchedItem( $user, $this );
+               $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+               $watchedItem = $store->getWatchedItem( $user, $this );
                if ( $watchedItem ) {
                        $this->mNotificationTimestamp[$uid] = $watchedItem->getNotificationTimestamp();
                } else {