Merge "(bug 41292) Fix "containing..." search option"
[lhc/web/wiklou.git] / includes / Skin.php
index 364d8c5..24d48bc 100644 (file)
@@ -290,8 +290,8 @@ abstract class Skin extends ContextSource {
                        return $this->mRelevantUser;
                }
                $title = $this->getRelevantTitle();
-               if( $title->getNamespace() == NS_USER || $title->getNamespace() == NS_USER_TALK ) {
-                       $rootUser = strtok( $title->getText(), '/' );
+               if( $title->hasSubjectNamespace( NS_USER ) ) {
+                       $rootUser = $title->getRootText();
                        if ( User::isIP( $rootUser ) ) {
                                $this->mRelevantUser = User::newFromName( $rootUser, false );
                        } else {
@@ -1063,7 +1063,7 @@ abstract class Skin extends ContextSource {
         * @return String URL
         */
        static function makeInternalOrExternalUrl( $name ) {
-               if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
+               if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $name ) ) {
                        return $name;
                } else {
                        return self::makeUrl( $name );
@@ -1227,7 +1227,7 @@ abstract class Skin extends ContextSource {
                                                $text = $line[1];
                                        }
 
-                                       if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
+                                       if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $link ) ) {
                                                $href = $link;
 
                                                // Parser::getExternalLinkAttribs won't work here because of the Namespace things
@@ -1288,18 +1288,19 @@ abstract class Skin extends ContextSource {
                $ntl = '';
 
                if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
-                       $userTalkTitle = $this->getUser()->getTalkPage();
+                       $uTalkTitle = $this->getUser()->getTalkPage();
 
-                       if ( !$userTalkTitle->equals( $out->getTitle() ) ) {
+                       if ( !$uTalkTitle->equals( $out->getTitle() ) ) {
                                $lastSeenRev = isset( $newtalks[0]['rev'] ) ? $newtalks[0]['rev'] : null;
                                $nofAuthors = 0;
                                if ( $lastSeenRev !== null ) {
                                        $plural = true; // Default if we have a last seen revision: if unknown, use plural
-                                       $latestRev = Revision::newFromTitle ($userTalkTitle);
+                                       $latestRev = Revision::newFromTitle( $uTalkTitle, false, Revision::READ_NORMAL );
                                        if ( $latestRev !== null ) {
                                                // Singular if only 1 unseen revision, plural if several unseen revisions.
                                                $plural = $latestRev->getParentId() !== $lastSeenRev->getId();
-                                               $nofAuthors = $userTalkTitle->countAuthorsBetween( $lastSeenRev, $latestRev, 10, 'include_new' );
+                                               $nofAuthors = $uTalkTitle->countAuthorsBetween(
+                                                       $lastSeenRev, $latestRev, 10, 'include_new' );
                                        }
                                } else {
                                        // Singular if no revision -> diff link will show latest change only in any case
@@ -1310,14 +1311,14 @@ abstract class Skin extends ContextSource {
                                // the number of revisions or authors is not necessarily the same as the number of
                                // "messages".
                                $newMessagesLink = Linker::linkKnown(
-                                       $userTalkTitle,
+                                       $uTalkTitle,
                                        $this->msg( 'newmessageslinkplural' )->params( $plural )->escaped(),
                                        array(),
                                        array( 'redirect' => 'no' )
                                );
 
                                $newMessagesDiffLink = Linker::linkKnown(
-                                       $userTalkTitle,
+                                       $uTalkTitle,
                                        $this->msg( 'newmessagesdifflinkplural' )->params( $plural )->escaped(),
                                        array(),
                                        $lastSeenRev !== null
@@ -1535,6 +1536,7 @@ abstract class Skin extends ContextSource {
         *
         * @param $fname String Name of called method
         * @param $args Array Arguments to the method
+        * @throws MWException
         * @return mixed
         */
        function __call( $fname, $args ) {