$nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
foreach ( $sorted as $obj ) {
$title = Title::makeTitle( $obj->rc_namespace, $obj->rc_title );
- $talkpage = $nsInfo->hasTalkNamespace( $obj->rc_namespace )
+ $talkpage = $nsInfo->hasTalkNamespace( $obj->rc_namespace ) && $title->isValid()
? $title->getTalkPage()->getFullURL()
: '';
public function getPreloadTitles() {
$title = $this->entry->getTarget();
// Preload user page for non-autoblocks
- if ( substr( $title->getText(), 0, 1 ) !== '#' ) {
+ if ( substr( $title->getText(), 0, 1 ) !== '#' && $title->isValid() ) {
return [ $title->getTalkPage() ];
}
return [];
'duration' => 'infinite',
'flags' => [ 'anononly' ],
],
+ 'preload' => [ new TitleValue( NS_USER_TALK, 'Logtestuser' ) ],
+ ],
+ ],
+
+ // With blank page title (T224811)
+ [
+ [
+ 'type' => 'block',
+ 'action' => 'block',
+ 'comment' => 'Block comment',
+ 'user' => 0,
+ 'user_text' => 'Sysop',
+ 'namespace' => NS_USER,
+ 'title' => '',
+ 'params' => [],
+ ],
+ [
+ 'text' => 'Sysop blocked (no username available) '
+ . 'with an expiration time of indefinite',
+ 'api' => [
+ 'duration' => 'infinite',
+ 'flags' => [],
+ ],
+ 'preload' => [],
],
],
<?php
+use MediaWiki\Linker\LinkTarget;
/**
* @since 1.26
self::removeApiMetaData( $formatter->formatParametersForApi() ),
'Api log params is equal to expected array'
);
+
+ if ( isset( $extra['preload'] ) ) {
+ $this->assertArrayEquals(
+ $this->getLinkTargetsAsStrings( $extra['preload'] ),
+ $this->getLinkTargetsAsStrings(
+ $formatter->getPreloadTitles()
+ )
+ );
+ }
+ }
+
+ private function getLinkTargetsAsStrings( array $linkTargets ) {
+ return array_map( function ( LinkTarget $t ) {
+ return $t->getInterwiki() . ':' . $t->getNamespace() . ':'
+ . $t->getDBkey() . '#' . $t->getFragment();
+ }, $linkTargets );
}
protected function isLegacy( $extra ) {