The test fills $wgUrlProtocols with 86000 entries, forging oversized
strings which ends up eventually truncated to 100 bytes. The aim is to
overflow $wgAPIMaxResultSize to trigger an apiwarn-truncatedresult
warning.
The test takes 230 ms on my machine and when generating code coverage
almost a minute.
A faster approach is just to lower the $wgAPIMaxResultSize limit to
trigger the warning.
Test plan:
$ php tests/phpunit/phpunit.php \
tests/phpunit/includes/api/ApiQuerySiteinfoTest.php \
--filter testContinuation
Bug: T234016
Change-Id: I3dc96d394d8b98dda8f151d14544b829c92f9b10
}
public function testContinuation() {
}
public function testContinuation() {
- // We make lots and lots of URL protocols that are each 100 bytes
+ // Use $wgUrlProtocols to forge the size of the API query
global $wgAPIMaxResultSize, $wgUrlProtocols;
global $wgAPIMaxResultSize, $wgUrlProtocols;
- $this->setMwGlobals( 'wgUrlProtocols', [] );
- // Just under the limit
- $chunks = $wgAPIMaxResultSize / 100 - 1;
-
- for ( $i = 0; $i < $chunks; $i++ ) {
- $wgUrlProtocols[] = substr( str_repeat( "$i ", 50 ), 0, 100 );
- }
+ $this->setMwGlobals( 'wgUrlProtocols', [ $protocol ] );
+ $this->setMwGlobals( 'wgAPIMaxResultSize', strlen( $protocol ) );
$res = $this->doApiRequest( [
'action' => 'query',
$res = $this->doApiRequest( [
'action' => 'query',