$dbw->startAtomic( __METHOD__ );
if ( !$oldLatest || $oldLatest == $this->lockAndGetLatest() ) {
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+ $truncatedFragment = $contLang->truncateForDatabase( $rt->getFragment(), 255 );
$dbw->upsert(
'redirect',
[
'rd_from' => $this->getId(),
'rd_namespace' => $rt->getNamespace(),
'rd_title' => $rt->getDBkey(),
- 'rd_fragment' => $rt->getFragment(),
+ 'rd_fragment' => $truncatedFragment,
'rd_interwiki' => $rt->getInterwiki(),
],
[ 'rd_from' ],
[
'rd_namespace' => $rt->getNamespace(),
'rd_title' => $rt->getDBkey(),
- 'rd_fragment' => $rt->getFragment(),
+ 'rd_fragment' => $truncatedFragment,
'rd_interwiki' => $rt->getInterwiki(),
],
__METHOD__
"#REDIRECT [[Media:hello_world]]",
"File:Hello world"
],
+ // Test fragments longer than 255 bytes (T207876)
+ [
+ 'WikiPageTest_testGetRedirectTarget_4',
+ CONTENT_MODEL_WIKITEXT,
+ // phpcs:ignore Generic.Files.LineLength
+ '#REDIRECT [[Foobar#🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴]]',
+ // phpcs:ignore Generic.Files.LineLength
+ 'Foobar#🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴🏴...'
+ ]
];
}
# now, test the actual redirect
$t = $page->getRedirectTarget();
- $this->assertEquals( $target, is_null( $t ) ? null : $t->getPrefixedText() );
+ $this->assertEquals( $target, is_null( $t ) ? null : $t->getFullText() );
}
/**