Merge "Move around "ا" to after "آ" and not before"
[lhc/web/wiklou.git] / includes / parser / Parser.php
index 3f0e38f..988e248 100644 (file)
@@ -2296,11 +2296,8 @@ class Parser {
                                                $this->mOutput->addLanguageLink( $nt->getFullText() );
                                        }
 
-                                       /**
-                                        * Strip the whitespace interwiki links produce, see T10897
-                                        */
                                        $s = rtrim( $s . $prefix );
-                                       $s .= rtrim( $trail, "\n" );
+                                       $s .= trim( $trail, "\n" ) == '' ? '' : $prefix . $trail;
                                        continue;
                                }
 
@@ -2325,11 +2322,7 @@ class Parser {
                                                continue;
                                        }
                                } elseif ( $ns == NS_CATEGORY ) {
-                                       /**
-                                        * Strip the whitespace Category links produce, see T2087
-                                        */
-                                       $s = rtrim( $s . $prefix ); # T2087, T87753
-                                       $s .= rtrim( $trail, "\n" );
+                                       $s = rtrim( $s . "\n" ); # T2087
 
                                        if ( $wasblank ) {
                                                $sortkey = $this->getDefaultSort();
@@ -2341,6 +2334,11 @@ class Parser {
                                        $sortkey = $this->getConverterLanguage()->convertCategoryKey( $sortkey );
                                        $this->mOutput->addCategory( $nt->getDBkey(), $sortkey );
 
+                                       /**
+                                        * Strip the whitespace Category links produce, see T2087
+                                        */
+                                       $s .= trim( $prefix . $trail, "\n" ) == '' ? '' : $prefix . $trail;
+
                                        continue;
                                }
                        }
@@ -2586,7 +2584,7 @@ class Parser {
                                ) ) );
                                break;
                        case 'talkpagename':
-                               if ( $this->mTitle->canTalk() ) {
+                               if ( $this->mTitle->canHaveTalkPage() ) {
                                        $talkPage = $this->mTitle->getTalkPage();
                                        $value = wfEscapeWikiText( $talkPage->getPrefixedText() );
                                } else {
@@ -2594,7 +2592,7 @@ class Parser {
                                }
                                break;
                        case 'talkpagenamee':
-                               if ( $this->mTitle->canTalk() ) {
+                               if ( $this->mTitle->canHaveTalkPage() ) {
                                        $talkPage = $this->mTitle->getTalkPage();
                                        $value = wfEscapeWikiText( $talkPage->getPrefixedURL() );
                                } else {
@@ -2694,12 +2692,12 @@ class Parser {
                                $value = $this->mTitle->getNamespace();
                                break;
                        case 'talkspace':
-                               $value = $this->mTitle->canTalk()
+                               $value = $this->mTitle->canHaveTalkPage()
                                        ? str_replace( '_', ' ', $this->mTitle->getTalkNsText() )
                                        : '';
                                break;
                        case 'talkspacee':
-                               $value = $this->mTitle->canTalk() ? wfUrlencode( $this->mTitle->getTalkNsText() ) : '';
+                               $value = $this->mTitle->canHaveTalkPage() ? wfUrlencode( $this->mTitle->getTalkNsText() ) : '';
                                break;
                        case 'subjectspace':
                                $value = str_replace( '_', ' ', $this->mTitle->getSubjectNsText() );