mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-24 06:03:49 +00:00
Merge "Avoid using WikiPage::factory()"
This commit is contained in:
commit
b22c67ea53
|
@ -448,8 +448,9 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
|
|||
* @return string The status of the operation, as returned by the API.
|
||||
*/
|
||||
private function stashEdit( $title, $text, $summary ) {
|
||||
return $this->getServiceContainer()->getPageEditStash()->parseAndCache(
|
||||
WikiPage::factory( $title ),
|
||||
$services = $this->getServiceContainer();
|
||||
return $services->getPageEditStash()->parseAndCache(
|
||||
$services->getWikiPageFactory()->newFromTitle( $title ),
|
||||
new WikitextContent( $text ),
|
||||
$this->user,
|
||||
$summary
|
||||
|
@ -466,7 +467,8 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
|
|||
* @return Status
|
||||
*/
|
||||
private function doEdit( Title $title, $oldText, $newText, $summary, $fromStash = null ) {
|
||||
$page = WikiPage::factory( $title );
|
||||
$services = $this->getServiceContainer();
|
||||
$page = $services->getWikiPageFactory()->newFromTitle( $title );
|
||||
if ( !$page->exists() ) {
|
||||
$status = $this->editPage(
|
||||
$page,
|
||||
|
@ -501,7 +503,7 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
|
|||
$context->setWikiPage( $page );
|
||||
|
||||
$hooksHandler = new FilteredActionsHandler(
|
||||
MediaWikiServices::getInstance()->getStatsdDataFactory(),
|
||||
$services->getStatsdDataFactory(),
|
||||
AbuseFilterServices::getFilterRunnerFactory(),
|
||||
AbuseFilterServices::getVariableGeneratorFactory(),
|
||||
AbuseFilterServices::getEditRevUpdater()
|
||||
|
@ -608,7 +610,9 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
private function getActionTags( $actionParams ) {
|
||||
if ( $actionParams['action'] === 'edit' || $actionParams['action'] === 'stashedit' ) {
|
||||
$page = WikiPage::factory( Title::newFromText( $actionParams['target'] ) );
|
||||
$page = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle(
|
||||
Title::newFromText( $actionParams['target'] )
|
||||
);
|
||||
return ChangeTags::getTags( $this->db, null, $page->getLatest() );
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class LazyVariableComputerDBTest extends MediaWikiIntegrationTestCase {
|
|||
public function testEditRelatedVars( $oldText, $newText, $summary, array $expected ) {
|
||||
$pageName = __METHOD__;
|
||||
$title = Title::makeTitle( 0, $pageName );
|
||||
$page = WikiPage::factory( $title );
|
||||
$page = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
|
||||
|
||||
$this->editPage( $pageName, $oldText, 'Creating the test page' );
|
||||
$this->editPage( $pageName, $newText, $summary );
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
use MediaWiki\Extension\AbuseFilter\Parser\AFPData;
|
||||
use MediaWiki\Extension\AbuseFilter\Variables\LazyLoadedVariable;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* @group Test
|
||||
|
@ -50,7 +49,9 @@ class RCVariableGeneratorTest extends MediaWikiIntegrationTestCase {
|
|||
MWTimestamp::setFakeTime( $timestamp );
|
||||
$user = $this->getMutableTestUser()->getUser();
|
||||
$title = Title::newFromText( 'AbuseFilter testing page' );
|
||||
$page = $type === 'create' ? WikiPage::factory( $title ) : $this->getExistingTestPage( $title );
|
||||
$services = $this->getServiceContainer();
|
||||
$wikiPageFactory = $services->getWikiPageFactory();
|
||||
$page = $type === 'create' ? $wikiPageFactory->newFromTitle( $title ) : $this->getExistingTestPage( $title );
|
||||
$page->clear();
|
||||
|
||||
$summary = 'Abuse Filter summary for RC tests';
|
||||
|
@ -77,10 +78,10 @@ class RCVariableGeneratorTest extends MediaWikiIntegrationTestCase {
|
|||
break;
|
||||
case 'move':
|
||||
$newTitle = Title::newFromText( 'Another AbuseFilter testing page' );
|
||||
$mpf = MediaWikiServices::getInstance()->getMovePageFactory();
|
||||
$mpf = $services->getMovePageFactory();
|
||||
$mp = $mpf->newMovePage( $title, $newTitle );
|
||||
$mp->move( $user, $summary, false );
|
||||
$newID = WikiPage::factory( $newTitle )->getId();
|
||||
$newID = $wikiPageFactory->newFromTitle( $newTitle )->getId();
|
||||
|
||||
$expectedValues += [
|
||||
'moved_from_id' => $page->getId(),
|
||||
|
@ -116,14 +117,14 @@ class RCVariableGeneratorTest extends MediaWikiIntegrationTestCase {
|
|||
case 'upload':
|
||||
$fileName = 'My File.svg';
|
||||
$destTitle = Title::makeTitle( NS_FILE, $fileName );
|
||||
$page = WikiPage::factory( $destTitle );
|
||||
$page = $wikiPageFactory->newFromTitle( $destTitle );
|
||||
[ $status, $this->clearPath ] = $this->doUpload( $user, $fileName, 'Some text', $summary );
|
||||
if ( !$status->isGood() ) {
|
||||
throw new LogicException( "Cannot upload file:\n$status" );
|
||||
}
|
||||
|
||||
// Since the SVG is randomly generated, we need to read some properties live
|
||||
$file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()->newFile( $destTitle );
|
||||
$file = $services->getRepoGroup()->getLocalRepo()->newFile( $destTitle );
|
||||
$expectedValues += [
|
||||
'page_id' => $page->getId(),
|
||||
'page_namespace' => $destTitle->getNamespace(),
|
||||
|
|
Loading…
Reference in a new issue