Remove patch-log_search-rename-index.sql from MW 1.16 updaters
[lhc/web/wiklou.git] / includes / Title.php
index 0a2f868..0687a15 100644 (file)
@@ -748,6 +748,8 @@ class Title implements LinkTarget {
        /**
         * Escape a text fragment, say from a link, for a URL
         *
+        * @deprecated since 1.30, use Sanitizer::escapeIdForLink() or escapeIdForExternalInterwiki()
+        *
         * @param string $fragment Containing a URL or link fragment (after the "#")
         * @return string Escaped string
         */
@@ -1034,6 +1036,7 @@ class Title implements LinkTarget {
         * Can this title have a corresponding talk page?
         *
         * @see MWNamespace::hasTalkNamespace
+        * @since 1.30
         *
         * @return bool True if this title either is a talk page or can have a talk page associated.
         */
@@ -1320,7 +1323,9 @@ class Title implements LinkTarget {
         * Get a Title object associated with the talk page of this article,
         * if such a talk page can exist.
         *
-        * @return Title The object for the talk page,
+        * @since 1.30
+        *
+        * @return Title|null The object for the talk page,
         *         or null if no associated talk page can exist, according to canHaveTalkPage().
         */
        public function getTalkPageIfDefined() {
@@ -1397,14 +1402,16 @@ class Title implements LinkTarget {
 
        /**
         * Get the fragment in URL form, including the "#" character if there is one
+        *
         * @return string Fragment in URL form
         */
        public function getFragmentForURL() {
                if ( !$this->hasFragment() ) {
                        return '';
-               } else {
-                       return '#' . self::escapeFragmentForURL( $this->getFragment() );
+               } elseif ( $this->isExternal() && !$this->getTransWikiID() ) {
+                       return '#' . Sanitizer::escapeIdForExternalInterwiki( $this->getFragment() );
                }
+               return '#' . Sanitizer::escapeIdForLink( $this->getFragment() );
        }
 
        /**
@@ -1890,6 +1897,8 @@ class Title implements LinkTarget {
         * protocol-relative, the URL will be expanded to http://
         *
         * @see self::getLocalURL for the arguments.
+        * @param string $query
+        * @param string|bool $query2
         * @return string The URL
         */
        public function getInternalURL( $query = '', $query2 = false ) {
@@ -2661,24 +2670,33 @@ class Title implements LinkTarget {
 
                if ( $this->mTitleProtection === null ) {
                        $dbr = wfGetDB( DB_REPLICA );
+                       $commentStore = new CommentStore( 'pt_reason' );
+                       $commentQuery = $commentStore->getJoin();
                        $res = $dbr->select(
-                               'protected_titles',
+                               [ 'protected_titles' ] + $commentQuery['tables'],
                                [
                                        'user' => 'pt_user',
-                                       'reason' => 'pt_reason',
                                        'expiry' => 'pt_expiry',
                                        'permission' => 'pt_create_perm'
-                               ],
+                               ] + $commentQuery['fields'],
                                [ 'pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey() ],
-                               __METHOD__
+                               __METHOD__,
+                               [],
+                               $commentQuery['joins']
                        );
 
                        // fetchRow returns false if there are no rows.
                        $row = $dbr->fetchRow( $res );
                        if ( $row ) {
-                               $row['expiry'] = $dbr->decodeExpiry( $row['expiry'] );
+                               $this->mTitleProtection = [
+                                       'user' => $row['user'],
+                                       'expiry' => $dbr->decodeExpiry( $row['expiry'] ),
+                                       'permission' => $row['permission'],
+                                       'reason' => $commentStore->getComment( $row )->text,
+                               ];
+                       } else {
+                               $this->mTitleProtection = false;
                        }
-                       $this->mTitleProtection = $row;
                }
                return $this->mTitleProtection;
        }
@@ -3687,7 +3705,7 @@ class Title implements LinkTarget {
         * Returns true if ok, or a getUserPermissionsErrors()-like array otherwise
         *
         * @deprecated since 1.25, use MovePage's methods instead
-        * @param Title $nt The new title
+        * @param Title &$nt The new title
         * @param bool $auth Whether to check user permissions (uses $wgUser)
         * @param string $reason Is the log summary of the move, used for spam checking
         * @return array|bool True on success, getUserPermissionsErrors()-like array on failure
@@ -3739,7 +3757,7 @@ class Title implements LinkTarget {
         * Move a title to a new location
         *
         * @deprecated since 1.25, use the MovePage class instead
-        * @param Title $nt The new title
+        * @param Title &$nt The new title
         * @param bool $auth Indicates whether $wgUser's permissions
         *  should be checked
         * @param string $reason The reason for the move