For example, [[en:]] on enwiki. These links were for some reason considered
invalid. However, to support use-cases such as cross-wiki transclusion and
the importing of templates across wikis, this type of link should be
allowed.
I can't see that this would break anything. If anything, it will "un-break"
some links.
Should MediaWikiTitleCodec depend on Title::newMainPage? Almost certainly
not, but I note that splitTitleString is earmarked for demolition, so I
expect that the confusing dependency-web will be cleaned up in the future.
I also note that MediaWikiTitleCode already uses various static methods of
the Title class.
Bug: 64167
Change-Id: I27495aa62e6059c7725387135ae0358d7e6fb35b
foreach ( $this->localInterwikis as $localIW ) {
if ( 0 == strcasecmp( $parts['interwiki'], $localIW ) ) {
if ( $dbkey == '' ) {
foreach ( $this->localInterwikis as $localIW ) {
if ( 0 == strcasecmp( $parts['interwiki'], $localIW ) ) {
if ( $dbkey == '' ) {
- # Can't have an empty self-link
- throw new MalformedTitleException( 'Local interwiki with empty title: ' . $text );
+ # Empty self-links should point to the Main Page, to ensure
+ # compatibility with cross-wiki transclusions and the like.
+ $mainPage = Title::newMainPage();
+ return array(
+ 'interwiki' => $mainPage->getInterwiki(),
+ 'fragment' => $mainPage->getFragment(),
+ 'namespace' => $mainPage->getNamespace(),
+ 'dbkey' => $mainPage->getDBkey(),
+ 'user_case_dbkey' => $mainPage->getUserCaseDBKey()
+ );
}
$parts['interwiki'] = '';
}
$parts['interwiki'] = '';
str_repeat( 'x', 252 ),
// interwiki prefix
'localtestiw: #anchor',
str_repeat( 'x', 252 ),
// interwiki prefix
'localtestiw: #anchor',
'localtestiw:foo',
'localtestiw: foo # anchor',
'localtestiw: Talk: Sandbox # anchor',
'localtestiw:foo',
'localtestiw: foo # anchor',
'localtestiw: Talk: Sandbox # anchor',
'Category: ',
'Category: #bar',
// interwiki prefix
'Category: ',
'Category: #bar',
// interwiki prefix
'localtestiw: Talk: # anchor',
'localtestiw: Talk:'
) as $text ) {
'localtestiw: Talk: # anchor',
'localtestiw: Talk:'
) as $text ) {