Merge "When title contains only slashes, Title::getRootText() shouldn't return false"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 14 Jul 2019 12:40:30 +0000 (12:40 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 14 Jul 2019 12:40:30 +0000 (12:40 +0000)
includes/Title.php
tests/phpunit/includes/TitleTest.php

index 28bec0b..95ccd9a 100644 (file)
@@ -1770,6 +1770,7 @@ class Title implements LinkTarget, IDBAccessObject {
                if (
                        !MediaWikiServices::getInstance()->getNamespaceInfo()->
                                hasSubpages( $this->mNamespace )
+                       || strtok( $this->getText(), '/' ) === false
                ) {
                        return $this->getText();
                }
index d0a95c2..913f56d 100644 (file)
@@ -554,6 +554,10 @@ class TitleTest extends MediaWikiTestCase {
                        # Title, expected base, optional message
                        [ 'User:John_Doe/subOne/subTwo', 'John Doe' ],
                        [ 'User:Foo / Bar / Baz', 'Foo ' ],
+                       [ 'Talk:////', '////' ],
+                       [ 'Template:////', '////' ],
+                       [ 'Template:Foo////', 'Foo' ],
+                       [ 'Template:Foo////Bar', 'Foo' ],
                ];
        }