12 'By default nothing is merged' => [
17 'A simple merge policy adds the redirect data in' => [
18 function ( $current, $new ) {
19 if ( !isset( $current[
'index'] ) || $new[
'index'] < $current[
'index'] ) {
20 $current[
'index'] = $new[
'index'];
34 $pageSet->setRedirectMergePolicy( $mergePolicy );
36 $target->getArticleID() => []
38 $pageSet->populateGeneratorData( $result );
39 $this->assertEquals( $expect, $result[$target->getArticleID()] );
47 $pageSet->setRedirectMergePolicy( $mergePolicy );
49 $result->addValue(
null,
'pages', [
50 $target->getArticleID() => []
52 $pageSet->populateGeneratorData( $result, [
'pages' ] );
55 $result->getResultData( [
'pages', $target->getArticleID() ] )
60 $target = Title::makeTitle(
NS_MAIN,
'UTRedirectTarget' );
61 $sourceA = Title::makeTitle(
NS_MAIN,
'UTRedirectSourceA' );
62 $sourceB = Title::makeTitle(
NS_MAIN,
'UTRedirectSourceB' );
64 self::editPage(
'UTRedirectSourceA',
'#REDIRECT [[UTRedirectTarget]]' );
65 self::editPage(
'UTRedirectSourceB',
'#REDIRECT [[UTRedirectTarget]]' );
73 $pageSet->setGeneratorData( $sourceA, [
'index' => 1 ] );
74 $pageSet->setGeneratorData( $sourceB, [
'index' => 3 ] );
75 $pageSet->populateFromTitles( [ $sourceA, $sourceB ] );
77 return [ $target, $pageSet ];
88 [ 0 => [
'A' => -1,
'B' => -2,
'Å' => -3 ] ],
89 $pageSet->getAllTitlesByNamespace()
93 [
'fromencoded' =>
true,
'from' =>
'a%CC%8A',
'to' =>
'å' ],
94 [
'fromencoded' =>
false,
'from' =>
'a',
'to' =>
'A' ],
95 [
'fromencoded' =>
false,
'from' =>
'å',
'to' =>
'Å' ],
97 $pageSet->getNormalizedTitlesAsResult()
102 $id1 =
self::editPage(
'UTApiPageSet',
'UTApiPageSet in the default language' )
103 ->value[
'revision']->getTitle()->getArticleID();
104 $id2 =
self::editPage(
'UTApiPageSet/de',
'UTApiPageSet in German' )
105 ->value[
'revision']->getTitle()->getArticleID();
108 $userName = $user->getName();
109 $userDbkey = str_replace(
' ',
'_', $userName );
111 'titles' => implode(
'|', [
112 'Special:MyContributions',
114 'Special:MyTalk/subpage',
115 'Special:MyLanguage/UTApiPageSet',
126 $this->assertEquals( [
127 ], $pageSet->getRedirectTitlesAsResult() );
128 $this->assertEquals( [
129 [
'ns' => -1,
'title' =>
'Special:MyContributions',
'special' =>
true ],
130 [
'ns' => -1,
'title' =>
'Special:MyPage',
'special' =>
true ],
131 [
'ns' => -1,
'title' =>
'Special:MyTalk/subpage',
'special' =>
true ],
132 [
'ns' => -1,
'title' =>
'Special:MyLanguage/UTApiPageSet',
'special' =>
true ],
133 ], $pageSet->getInvalidTitlesAndRevisions() );
134 $this->assertEquals( [
135 ], $pageSet->getAllTitlesByNamespace() );
142 $this->assertEquals( [
143 [
'from' =>
'Special:MyPage',
'to' =>
"User:$userName" ],
144 [
'from' =>
'Special:MyTalk/subpage',
'to' =>
"User talk:$userName/subpage" ],
145 [
'from' =>
'Special:MyLanguage/UTApiPageSet',
'to' =>
'UTApiPageSet' ],
146 ], $pageSet->getRedirectTitlesAsResult() );
147 $this->assertEquals( [
148 [
'ns' => -1,
'title' =>
'Special:MyContributions',
'special' =>
true ],
149 [
'ns' => 2,
'title' =>
"User:$userName",
'missing' =>
true ],
150 [
'ns' => 3,
'title' =>
"User talk:$userName/subpage",
'missing' =>
true ],
151 ], $pageSet->getInvalidTitlesAndRevisions() );
152 $this->assertEquals( [
153 0 => [
'UTApiPageSet' => $id1 ],
154 2 => [ $userDbkey => -2 ],
155 3 => [
"$userDbkey/subpage" => -3 ],
156 ], $pageSet->getAllTitlesByNamespace() );
163 $this->assertEquals( [
164 [
'from' =>
'Special:MyPage',
'to' =>
"User:$userName" ],
165 [
'from' =>
'Special:MyTalk/subpage',
'to' =>
"User talk:$userName/subpage" ],
166 [
'from' =>
'Special:MyLanguage/UTApiPageSet',
'to' =>
'UTApiPageSet/de' ],
167 ], $pageSet->getRedirectTitlesAsResult() );
168 $this->assertEquals( [
169 [
'ns' => -1,
'title' =>
'Special:MyContributions',
'special' =>
true ],
170 [
'ns' => 2,
'title' =>
"User:$userName",
'missing' =>
true ],
171 [
'ns' => 3,
'title' =>
"User talk:$userName/subpage",
'missing' =>
true ],
172 ], $pageSet->getInvalidTitlesAndRevisions() );
173 $this->assertEquals( [
174 0 => [
'UTApiPageSet/de' => $id2 ],
175 2 => [ $userDbkey => -2 ],
176 3 => [
"$userDbkey/subpage" => -3 ],
177 ], $pageSet->getAllTitlesByNamespace() );
This is the main API class, used for both external and internal processing.
API medium Database ApiPageSet.
static provideRedirectMergePolicy()
testHandleNormalization()
testRedirectMergePolicyWithApiResult( $mergePolicy, $expect)
provideRedirectMergePolicy
createPageSetWithRedirect()
testRedirectMergePolicyWithArrayResult( $mergePolicy, $expect)
provideRedirectMergePolicy
This class contains a list of pages that the client has requested.
This class represents the result of the API operations.
WebRequest clone which takes values from a provided array.
Group all the pieces relevant to the context of a request into one instance.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context