Merge "Expand the protocol for proto-relative links when printing"
[lhc/web/wiklou.git] / includes / Title.php
index 995deeb..54a0839 100644 (file)
@@ -662,34 +662,6 @@ class Title {
                return $out;
        }
 
-       /**
-        * Get a string representation of a title suitable for
-        * including in a search index
-        *
-        * @param int $ns a namespace index
-        * @param string $title text-form main part
-        * @return String a stripped-down title string ready for the search index
-        */
-       public static function indexTitle( $ns, $title ) {
-               global $wgContLang;
-
-               $lc = SearchEngine::legalSearchChars() . '&#;';
-               $t = $wgContLang->normalizeForSearch( $title );
-               $t = preg_replace( "/[^{$lc}]+/", ' ', $t );
-               $t = $wgContLang->lc( $t );
-
-               # Handle 's, s'
-               $t = preg_replace( "/([{$lc}]+)'s( |$)/", "\\1 \\1's ", $t );
-               $t = preg_replace( "/([{$lc}]+)s'( |$)/", "\\1s ", $t );
-
-               $t = preg_replace( "/\\s+/", ' ', $t );
-
-               if ( $ns == NS_FILE ) {
-                       $t = preg_replace( "/ (png|gif|jpg|jpeg|ogg)$/", "", $t );
-               }
-               return trim( $t );
-       }
-
        /**
         * Make a prefixed DB key from a DB key and a namespace index
         *
@@ -1271,16 +1243,6 @@ class Title {
                return $this->mDefaultNamespace;
        }
 
-       /**
-        * Get title for search index
-        *
-        * @return String a stripped-down title string ready for the
-        *  search index
-        */
-       public function getIndexTitle() {
-               return Title::indexTitle( $this->mNamespace, $this->mTextform );
-       }
-
        /**
         * Get the Title fragment (i.e.\ the bit after the #) in text form
         *
@@ -1837,7 +1799,7 @@ class Title {
        /**
         * Is $wgUser watching this page?
         *
-        * @deprecated in 1.20; use User::isWatched() instead.
+        * @deprecated since 1.20; use User::isWatched() instead.
         * @return Bool
         */
        public function userIsWatching() {
@@ -1856,7 +1818,7 @@ class Title {
        /**
         * Can $wgUser read this page?
         *
-        * @deprecated in 1.19; use userCan(), quickUserCan() or getUserPermissionsErrors() instead
+        * @deprecated since 1.19; use userCan(), quickUserCan() or getUserPermissionsErrors() instead
         * @return Bool
         */
        public function userCanRead() {
@@ -2521,7 +2483,7 @@ class Title {
        /**
         * Update the title protection status
         *
-        * @deprecated in 1.19; use WikiPage::doUpdateRestrictions() instead.
+        * @deprecated since 1.19; use WikiPage::doUpdateRestrictions() instead.
         * @param $create_perm String Permission required for creation
         * @param string $reason Reason for protection
         * @param string $expiry Expiry timestamp
@@ -4341,9 +4303,10 @@ class Title {
         *
         * @param int|Revision $old Old revision or rev ID (first before range)
         * @param int|Revision $new New revision or rev ID (first after range)
+        * @param int|null $max Limit of Revisions to count, will be incremented to detect truncations
         * @return Int Number of revisions between these revisions.
         */
-       public function countRevisionsBetween( $old, $new ) {
+       public function countRevisionsBetween( $old, $new, $max = null ) {
                if ( !( $old instanceof Revision ) ) {
                        $old = Revision::newFromTitle( $this, (int)$old );
                }
@@ -4354,14 +4317,21 @@ class Title {
                        return 0; // nothing to compare
                }
                $dbr = wfGetDB( DB_SLAVE );
-               return (int)$dbr->selectField( 'revision', 'count(*)',
-                       array(
-                               'rev_page' => $this->getArticleID(),
-                               'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $old->getTimestamp() ) ),
-                               'rev_timestamp < ' . $dbr->addQuotes( $dbr->timestamp( $new->getTimestamp() ) )
-                       ),
-                       __METHOD__
+               $conds = array(
+                       'rev_page' => $this->getArticleID(),
+                       'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $old->getTimestamp() ) ),
+                       'rev_timestamp < ' . $dbr->addQuotes( $dbr->timestamp( $new->getTimestamp() ) )
                );
+               if ( $max !== null ) {
+                       $res = $dbr->select( 'revision', '1',
+                               $conds,
+                               __METHOD__,
+                               array( 'LIMIT' => $max + 1 ) // extra to detect truncation
+                       );
+                       return $res->numRows();
+               } else {
+                       return (int)$dbr->selectField( 'revision', 'count(*)', $conds, __METHOD__ );
+               }
        }
 
        /**
@@ -4916,7 +4886,7 @@ class Title {
         * they will already be wrapped in paragraphs.
         *
         * @since 1.21
-        * @param int oldid Revision ID that's being edited
+        * @param int $oldid Revision ID that's being edited
         * @return Array
         */
        public function getEditNotices( $oldid = 0 ) {