Code that needs to store an actor ID in the database to represent a UserIdentity, or needs to construct a UserIdentity based on an actor ID loaded from the database, should use the ActorNormalization service. Note: The getActorId() method is removed from the UserIdentity interface, but all concrete classes continue to support it for now. UsererIdentityValue::getActorId() is hard deprecated and should be removed in 1.37. It always returns 0. User::getActorId() is not deprecated at this point. Bug: T274179 Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237 Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1
67 lines
2 KiB
PHP
67 lines
2 KiB
PHP
<?php
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
use MediaWiki\Permissions\UltimateAuthority;
|
|
use MediaWiki\User\UserIdentityValue;
|
|
|
|
/**
|
|
* Test that runs against all registered special pages to make sure that regular
|
|
* execution of the special page does not cause a fatal error.
|
|
*
|
|
* UTSysop is used to run as much of the special page code as possible without
|
|
* actually knowing the details of the special page.
|
|
*
|
|
* @since 1.32
|
|
* @author Addshore
|
|
*/
|
|
class SpecialPageFatalTest extends MediaWikiIntegrationTestCase {
|
|
|
|
protected function setUp() : void {
|
|
parent::setUp();
|
|
// FIXME: Acknowledge known non-fatal query (T248191)
|
|
$this->setMwGlobals( 'wgDBerrorLog', false );
|
|
// Deprecations don't matter for what this test cares about. This made browser tests fail
|
|
// on many occasions already. (T236809)
|
|
$this->filterDeprecated( '//' );
|
|
}
|
|
|
|
public function provideSpecialPages() {
|
|
$spf = MediaWikiServices::getInstance()->getSpecialPageFactory();
|
|
foreach ( $spf->getNames() as $name ) {
|
|
yield $name => [ $name ];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideSpecialPages
|
|
*/
|
|
public function testSpecialPageDoesNotFatal( $name ) {
|
|
$spf = MediaWikiServices::getInstance()->getSpecialPageFactory();
|
|
$page = $spf->getPage( $name );
|
|
if ( !$page ) {
|
|
$this->markTestSkipped( "Could not create special page $name" );
|
|
}
|
|
|
|
$executor = new SpecialPageExecutor();
|
|
$authority = new UltimateAuthority( new UserIdentityValue( 0, 'UTSysop' ) );
|
|
|
|
try {
|
|
$executor->executeSpecialPage( $page, '', null, 'qqx', $authority );
|
|
} catch ( \PHPUnit\Framework\Error\Deprecated $deprecated ) {
|
|
// Allow deprecation,
|
|
// this test want to check fatals or other things breaking the extension
|
|
} catch ( \PHPUnit\Framework\Error\Error $error ) {
|
|
// Let phpunit settings working:
|
|
// - convertErrorsToExceptions="true"
|
|
// - convertNoticesToExceptions="true"
|
|
// - convertWarningsToExceptions="true"
|
|
throw $error;
|
|
} catch ( Exception $e ) {
|
|
// Other exceptions are allowed
|
|
}
|
|
|
|
// If the page fataled phpunit will have already died
|
|
$this->addToAssertionCount( 1 );
|
|
}
|
|
|
|
}
|