2012-05-10 20:56:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
2022-02-14 04:28:20 +00:00
|
|
|
use MediaWiki\Deferred\LinksUpdate\LinksTable;
|
|
|
|
|
use MediaWiki\Deferred\LinksUpdate\LinksTableGroup;
|
2021-12-10 02:36:13 +00:00
|
|
|
use MediaWiki\Deferred\LinksUpdate\LinksUpdate;
|
2022-07-20 12:42:41 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
2022-09-06 09:27:52 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2021-12-09 23:03:19 +00:00
|
|
|
use MediaWiki\Page\PageIdentityValue;
|
2023-03-01 20:33:26 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2020-04-09 12:06:22 +00:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
|
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
|
|
2012-05-10 20:56:34 +00:00
|
|
|
/**
|
2023-05-27 09:43:12 +00:00
|
|
|
* @covers MediaWiki\Deferred\LinksUpdate\LinksUpdate
|
2021-12-07 05:37:26 +00:00
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\CategoryLinksTable
|
|
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\ExternalLinksTable
|
|
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable
|
|
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\ImageLinksTable
|
|
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable
|
|
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\LangLinksTable
|
|
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\LinksTable
|
|
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\LinksTableGroup
|
|
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\PageLinksTable
|
|
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\PagePropsTable
|
|
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\TemplateLinksTable
|
|
|
|
|
* @covers \MediaWiki\Deferred\LinksUpdate\TitleLinksTable
|
2021-12-07 04:17:56 +00:00
|
|
|
*
|
2015-11-15 02:29:37 +00:00
|
|
|
* @group LinksUpdate
|
2012-05-10 20:56:34 +00:00
|
|
|
* @group Database
|
|
|
|
|
* ^--- make sure temporary tables are used.
|
|
|
|
|
*/
|
2015-12-07 16:26:16 +00:00
|
|
|
class LinksUpdateTest extends MediaWikiLangTestCase {
|
2016-03-07 17:26:25 +00:00
|
|
|
protected static $testingPageId;
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2021-07-22 03:11:47 +00:00
|
|
|
protected function setUp(): void {
|
2021-03-08 03:23:08 +00:00
|
|
|
parent::setUp();
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2012-10-02 08:39:30 +00:00
|
|
|
$this->tablesUsed = array_merge( $this->tablesUsed,
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2012-10-02 08:39:30 +00:00
|
|
|
'interwiki',
|
|
|
|
|
'page_props',
|
|
|
|
|
'pagelinks',
|
|
|
|
|
'categorylinks',
|
2022-01-15 12:31:58 +00:00
|
|
|
'category',
|
2012-10-02 08:39:30 +00:00
|
|
|
'langlinks',
|
|
|
|
|
'externallinks',
|
|
|
|
|
'imagelinks',
|
|
|
|
|
'templatelinks',
|
2015-08-24 17:40:06 +00:00
|
|
|
'iwlinks',
|
|
|
|
|
'recentchanges',
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2012-10-02 08:39:30 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2021-04-29 02:37:11 +00:00
|
|
|
$dbw = wfGetDB( DB_PRIMARY );
|
2012-10-02 08:39:30 +00:00
|
|
|
$dbw->replace(
|
|
|
|
|
'interwiki',
|
2021-12-07 04:17:56 +00:00
|
|
|
'iw_prefix',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2012-10-02 08:39:30 +00:00
|
|
|
'iw_prefix' => 'linksupdatetest',
|
|
|
|
|
'iw_url' => 'http://testing.com/wiki/$1',
|
|
|
|
|
'iw_api' => 'http://testing.com/w/api.php',
|
|
|
|
|
'iw_local' => 0,
|
|
|
|
|
'iw_trans' => 0,
|
|
|
|
|
'iw_wikiid' => 'linksupdatetest',
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2012-10-02 08:39:30 +00:00
|
|
|
);
|
2022-07-20 12:42:41 +00:00
|
|
|
$this->overrideConfigValue( MainConfigNames::RCWatchCategoryMembership, true );
|
2015-08-24 17:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-07 17:26:25 +00:00
|
|
|
public function addDBDataOnce() {
|
2015-12-11 13:17:51 +00:00
|
|
|
$res = $this->insertPage( 'Testing' );
|
2016-03-07 17:26:25 +00:00
|
|
|
self::$testingPageId = $res['id'];
|
2015-08-24 17:40:06 +00:00
|
|
|
$this->insertPage( 'Some_other_page' );
|
|
|
|
|
$this->insertPage( 'Template:TestingTemplate' );
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function makeTitleAndParserOutput( $name, $id ) {
|
2020-04-09 12:06:22 +00:00
|
|
|
// Force the value returned by getArticleID, even is
|
|
|
|
|
// READ_LATEST is passed.
|
|
|
|
|
|
|
|
|
|
/** @var Title|MockObject $t */
|
|
|
|
|
$t = $this->getMockBuilder( Title::class )
|
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->onlyMethods( [ 'getArticleID' ] )
|
|
|
|
|
->getMock();
|
|
|
|
|
$t->method( 'getArticleID' )->willReturn( $id );
|
|
|
|
|
|
|
|
|
|
$tAccess = TestingAccessWrapper::newFromObject( $t );
|
|
|
|
|
$tAccess->secureAndSplit( $name );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$po = new ParserOutput();
|
2020-04-09 12:06:22 +00:00
|
|
|
$po->setTitleText( $name );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return [ $t, $po ];
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addLink
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_pagelinks() {
|
2015-12-11 13:17:51 +00:00
|
|
|
/** @var Title $t */
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$po->addLink( Title::newFromText( "Foo" ) );
|
2021-12-07 04:17:56 +00:00
|
|
|
$po->addLink( Title::newFromText( "Bar" ) );
|
2012-05-10 20:56:34 +00:00
|
|
|
$po->addLink( Title::newFromText( "Special:Foo" ) ); // special namespace should be ignored
|
|
|
|
|
$po->addLink( Title::newFromText( "linksupdatetest:Foo" ) ); // interwiki link should be ignored
|
|
|
|
|
$po->addLink( Title::newFromText( "#Foo" ) ); // hash link should be ignored
|
|
|
|
|
|
2014-04-24 10:05:52 +00:00
|
|
|
$update = $this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'pagelinks',
|
2021-12-09 23:03:19 +00:00
|
|
|
[ 'pl_namespace', 'pl_title' ],
|
2016-03-07 17:26:25 +00:00
|
|
|
'pl_from = ' . self::$testingPageId,
|
2021-12-07 04:17:56 +00:00
|
|
|
[
|
|
|
|
|
[ NS_MAIN, 'Bar' ],
|
|
|
|
|
[ NS_MAIN, 'Foo' ],
|
|
|
|
|
]
|
2014-04-24 10:05:52 +00:00
|
|
|
);
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertArrayEquals( [
|
2013-10-09 18:48:37 +00:00
|
|
|
Title::makeTitle( NS_MAIN, 'Foo' ), // newFromText doesn't yield the same internal state....
|
2021-12-07 04:17:56 +00:00
|
|
|
Title::makeTitle( NS_MAIN, 'Bar' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
], $update->getAddedLinks() );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$po = new ParserOutput();
|
|
|
|
|
$po->setTitleText( $t->getPrefixedText() );
|
|
|
|
|
|
|
|
|
|
$po->addLink( Title::newFromText( "Bar" ) );
|
2021-12-07 04:17:56 +00:00
|
|
|
$po->addLink( Title::newFromText( "Baz" ) );
|
|
|
|
|
$po->addLink( Title::newFromText( "Talk:Baz" ) );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2014-04-24 10:05:52 +00:00
|
|
|
$update = $this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'pagelinks',
|
2021-12-09 23:03:19 +00:00
|
|
|
[ 'pl_namespace', 'pl_title' ],
|
2016-03-07 17:26:25 +00:00
|
|
|
'pl_from = ' . self::$testingPageId,
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[ NS_MAIN, 'Bar' ],
|
2021-12-07 04:17:56 +00:00
|
|
|
[ NS_MAIN, 'Baz' ],
|
|
|
|
|
[ NS_TALK, 'Baz' ],
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2014-04-24 10:05:52 +00:00
|
|
|
);
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertArrayEquals( [
|
2021-12-07 04:17:56 +00:00
|
|
|
Title::makeTitle( NS_MAIN, 'Baz' ),
|
|
|
|
|
Title::makeTitle( NS_TALK, 'Baz' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
], $update->getAddedLinks() );
|
|
|
|
|
$this->assertArrayEquals( [
|
2013-10-09 18:48:37 +00:00
|
|
|
Title::makeTitle( NS_MAIN, 'Foo' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
], $update->getRemovedLinks() );
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-09 23:03:19 +00:00
|
|
|
public function testUpdate_pagelinks_move() {
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2021-12-09 23:03:19 +00:00
|
|
|
|
|
|
|
|
$po->addLink( Title::newFromText( "Foo" ) );
|
|
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'pagelinks',
|
|
|
|
|
[ 'pl_namespace', 'pl_title', 'pl_from_namespace' ],
|
|
|
|
|
'pl_from = ' . self::$testingPageId,
|
|
|
|
|
[
|
|
|
|
|
[ NS_MAIN, 'Foo', NS_MAIN ],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "User:Testing", self::$testingPageId );
|
2021-12-09 23:03:19 +00:00
|
|
|
$po->addLink( Title::newFromText( "Foo" ) );
|
|
|
|
|
$this->assertMoveLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
new PageIdentityValue( 2, 0, "Foo", false ),
|
|
|
|
|
$po,
|
|
|
|
|
'pagelinks',
|
|
|
|
|
[ 'pl_namespace', 'pl_title', 'pl_from_namespace' ],
|
|
|
|
|
'pl_from = ' . self::$testingPageId,
|
|
|
|
|
[
|
|
|
|
|
[ NS_MAIN, 'Foo', NS_USER ],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addExternalLink
|
2023-05-27 09:43:12 +00:00
|
|
|
* @covers MediaWiki\Deferred\LinksUpdate\LinksUpdate::getAddedExternalLinks
|
|
|
|
|
* @covers MediaWiki\Deferred\LinksUpdate\LinksUpdate::getRemovedExternalLinks
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_externallinks() {
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$po->addExternalLink( "http://testing.com/wiki/Foo" );
|
2021-12-07 04:17:56 +00:00
|
|
|
$po->addExternalLink( "http://testing.com/wiki/Bar" );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2019-02-07 16:10:09 +00:00
|
|
|
$update = $this->assertLinksUpdate(
|
2015-12-11 13:17:51 +00:00
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'externallinks',
|
2021-12-09 23:03:19 +00:00
|
|
|
[ 'el_to', 'el_index' ],
|
2016-03-07 17:26:25 +00:00
|
|
|
'el_from = ' . self::$testingPageId,
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2021-12-07 04:17:56 +00:00
|
|
|
[ 'http://testing.com/wiki/Bar', 'http://com.testing./wiki/Bar' ],
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'http://testing.com/wiki/Foo', 'http://com.testing./wiki/Foo' ],
|
|
|
|
|
]
|
2015-12-11 13:17:51 +00:00
|
|
|
);
|
2019-02-07 16:10:09 +00:00
|
|
|
|
|
|
|
|
$this->assertArrayEquals( [
|
2021-12-07 04:17:56 +00:00
|
|
|
"http://testing.com/wiki/Bar",
|
2019-02-07 16:10:09 +00:00
|
|
|
"http://testing.com/wiki/Foo"
|
|
|
|
|
], $update->getAddedExternalLinks() );
|
|
|
|
|
|
|
|
|
|
$po = new ParserOutput();
|
|
|
|
|
$po->setTitleText( $t->getPrefixedText() );
|
|
|
|
|
$po->addExternalLink( 'http://testing.com/wiki/Bar' );
|
2021-12-07 04:17:56 +00:00
|
|
|
$po->addExternalLink( 'http://testing.com/wiki/Baz' );
|
2019-02-07 16:10:09 +00:00
|
|
|
$update = $this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'externallinks',
|
2021-12-09 23:03:19 +00:00
|
|
|
[ 'el_to', 'el_index' ],
|
2019-02-07 16:10:09 +00:00
|
|
|
'el_from = ' . self::$testingPageId,
|
|
|
|
|
[
|
|
|
|
|
[ 'http://testing.com/wiki/Bar', 'http://com.testing./wiki/Bar' ],
|
2021-12-07 04:17:56 +00:00
|
|
|
[ 'http://testing.com/wiki/Baz', 'http://com.testing./wiki/Baz' ],
|
2019-02-07 16:10:09 +00:00
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertArrayEquals( [
|
2021-12-07 04:17:56 +00:00
|
|
|
"http://testing.com/wiki/Baz"
|
2019-02-07 16:10:09 +00:00
|
|
|
], $update->getAddedExternalLinks() );
|
|
|
|
|
$this->assertArrayEquals( [
|
|
|
|
|
"http://testing.com/wiki/Foo"
|
|
|
|
|
], $update->getRemovedExternalLinks() );
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addCategory
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_categorylinks() {
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2022-07-20 12:42:41 +00:00
|
|
|
$this->overrideConfigValue( MainConfigNames::CategoryCollation, 'uppercase' );
|
2013-03-01 20:02:42 +00:00
|
|
|
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$po->addCategory( "Foo", "FOO" );
|
2021-12-07 04:17:56 +00:00
|
|
|
$po->addCategory( "Bar", "BAR" );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2015-12-11 13:17:51 +00:00
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'categorylinks',
|
2021-12-09 23:03:19 +00:00
|
|
|
[ 'cl_to', 'cl_sortkey' ],
|
2016-03-07 17:26:25 +00:00
|
|
|
'cl_from = ' . self::$testingPageId,
|
2021-12-07 04:17:56 +00:00
|
|
|
[
|
|
|
|
|
[ 'Bar', "BAR\nTESTING" ],
|
|
|
|
|
[ 'Foo', "FOO\nTESTING" ]
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Check category count
|
|
|
|
|
$this->assertSelect(
|
|
|
|
|
'category',
|
|
|
|
|
[ 'cat_title', 'cat_pages' ],
|
|
|
|
|
[ 'cat_title' => [ 'Foo', 'Bar', 'Baz' ] ],
|
|
|
|
|
[
|
|
|
|
|
[ 'Bar', 1 ],
|
|
|
|
|
[ 'Foo', 1 ]
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2021-12-07 04:17:56 +00:00
|
|
|
$po->addCategory( "Bar", "Bar" );
|
|
|
|
|
$po->addCategory( "Baz", "Baz" );
|
|
|
|
|
|
|
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'categorylinks',
|
2021-12-09 23:03:19 +00:00
|
|
|
[ 'cl_to', 'cl_sortkey' ],
|
2021-12-07 04:17:56 +00:00
|
|
|
'cl_from = ' . self::$testingPageId,
|
|
|
|
|
[
|
|
|
|
|
[ 'Bar', "BAR\nTESTING" ],
|
|
|
|
|
[ 'Baz', "BAZ\nTESTING" ]
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Check category count decrement
|
|
|
|
|
$this->assertSelect(
|
|
|
|
|
'category',
|
|
|
|
|
[ 'cat_title', 'cat_pages' ],
|
|
|
|
|
[ 'cat_title' => [ 'Foo', 'Bar', 'Baz' ] ],
|
|
|
|
|
[
|
|
|
|
|
[ 'Bar', 1 ],
|
|
|
|
|
[ 'Baz', 1 ],
|
|
|
|
|
]
|
2015-12-11 13:17:51 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-24 17:40:06 +00:00
|
|
|
public function testOnAddingAndRemovingCategory_recentChangesRowIsAdded() {
|
2022-07-20 12:42:41 +00:00
|
|
|
$this->overrideConfigValue( MainConfigNames::CategoryCollation, 'uppercase' );
|
2015-08-24 17:40:06 +00:00
|
|
|
|
|
|
|
|
$title = Title::newFromText( 'Testing' );
|
2022-06-26 21:21:02 +00:00
|
|
|
$wikiPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
|
2021-06-24 08:42:19 +00:00
|
|
|
$wikiPage->doUserEditContent(
|
|
|
|
|
new WikitextContent( '[[Category:Foo]]' ),
|
|
|
|
|
$this->getTestSysop()->getUser(),
|
|
|
|
|
'added category'
|
|
|
|
|
);
|
2015-11-15 02:29:37 +00:00
|
|
|
$this->runAllRelatedJobs();
|
2015-08-24 17:40:06 +00:00
|
|
|
|
|
|
|
|
$this->assertRecentChangeByCategorization(
|
|
|
|
|
$title,
|
2022-06-16 13:22:24 +00:00
|
|
|
$wikiPage->getParserOutput( ParserOptions::newFromAnon() ),
|
2015-08-24 17:40:06 +00:00
|
|
|
Title::newFromText( 'Category:Foo' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'Foo', '[[:Testing]] added to category' ] ]
|
2015-08-24 17:40:06 +00:00
|
|
|
);
|
|
|
|
|
|
2021-06-24 08:42:19 +00:00
|
|
|
$wikiPage->doUserEditContent(
|
|
|
|
|
new WikitextContent( '[[Category:Bar]]' ),
|
|
|
|
|
$this->getTestSysop()->getUser(),
|
|
|
|
|
'replaced category'
|
|
|
|
|
);
|
2015-11-15 02:29:37 +00:00
|
|
|
$this->runAllRelatedJobs();
|
|
|
|
|
|
2015-08-24 17:40:06 +00:00
|
|
|
$this->assertRecentChangeByCategorization(
|
|
|
|
|
$title,
|
2022-06-16 13:22:24 +00:00
|
|
|
$wikiPage->getParserOutput( ParserOptions::newFromAnon() ),
|
2015-08-24 17:40:06 +00:00
|
|
|
Title::newFromText( 'Category:Foo' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[ 'Foo', '[[:Testing]] added to category' ],
|
|
|
|
|
[ 'Foo', '[[:Testing]] removed from category' ],
|
|
|
|
|
]
|
2015-08-24 17:40:06 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertRecentChangeByCategorization(
|
|
|
|
|
$title,
|
2022-06-16 13:22:24 +00:00
|
|
|
$wikiPage->getParserOutput( ParserOptions::newFromAnon() ),
|
2015-08-24 17:40:06 +00:00
|
|
|
Title::newFromText( 'Category:Bar' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[ 'Bar', '[[:Testing]] added to category' ],
|
|
|
|
|
]
|
2015-08-24 17:40:06 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testOnAddingAndRemovingCategoryToTemplates_embeddingPagesAreIgnored() {
|
2022-07-20 12:42:41 +00:00
|
|
|
$this->overrideConfigValue( MainConfigNames::CategoryCollation, 'uppercase' );
|
2015-08-24 17:40:06 +00:00
|
|
|
|
|
|
|
|
$templateTitle = Title::newFromText( 'Template:TestingTemplate' );
|
2022-06-26 21:21:02 +00:00
|
|
|
$templatePage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $templateTitle );
|
2015-08-24 17:40:06 +00:00
|
|
|
|
2022-06-26 21:21:02 +00:00
|
|
|
$wikiPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( Title::newFromText( 'Testing' ) );
|
2021-06-24 08:42:19 +00:00
|
|
|
$wikiPage->doUserEditContent(
|
|
|
|
|
new WikitextContent( '{{TestingTemplate}}' ),
|
|
|
|
|
$this->getTestSysop()->getUser(),
|
|
|
|
|
'added template'
|
|
|
|
|
);
|
2015-11-15 02:29:37 +00:00
|
|
|
$this->runAllRelatedJobs();
|
|
|
|
|
|
2022-06-26 21:21:02 +00:00
|
|
|
$otherWikiPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( Title::newFromText( 'Some_other_page' ) );
|
2021-06-24 08:42:19 +00:00
|
|
|
$otherWikiPage->doUserEditContent(
|
|
|
|
|
new WikitextContent( '{{TestingTemplate}}' ),
|
|
|
|
|
$this->getTestSysop()->getUser(),
|
|
|
|
|
'added template'
|
|
|
|
|
);
|
2015-11-15 02:29:37 +00:00
|
|
|
$this->runAllRelatedJobs();
|
|
|
|
|
|
|
|
|
|
$this->assertRecentChangeByCategorization(
|
|
|
|
|
$templateTitle,
|
2022-06-16 13:22:24 +00:00
|
|
|
$templatePage->getParserOutput( ParserOptions::newFromAnon() ),
|
2015-11-15 02:29:37 +00:00
|
|
|
Title::newFromText( 'Baz' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[]
|
2015-11-15 02:29:37 +00:00
|
|
|
);
|
|
|
|
|
|
2021-06-24 08:42:19 +00:00
|
|
|
$templatePage->doUserEditContent(
|
|
|
|
|
new WikitextContent( '[[Category:Baz]]' ),
|
|
|
|
|
$this->getTestSysop()->getUser(),
|
|
|
|
|
'added category'
|
|
|
|
|
);
|
2015-11-15 02:29:37 +00:00
|
|
|
$this->runAllRelatedJobs();
|
2015-08-24 17:40:06 +00:00
|
|
|
|
|
|
|
|
$this->assertRecentChangeByCategorization(
|
|
|
|
|
$templateTitle,
|
2022-06-16 13:22:24 +00:00
|
|
|
$templatePage->getParserOutput( ParserOptions::newFromAnon() ),
|
2015-11-15 02:29:37 +00:00
|
|
|
Title::newFromText( 'Baz' ),
|
2016-02-26 10:28:16 +00:00
|
|
|
[ [
|
|
|
|
|
'Baz',
|
2016-04-02 16:06:40 +00:00
|
|
|
'[[:Template:TestingTemplate]] added to category, ' .
|
|
|
|
|
'[[Special:WhatLinksHere/Template:TestingTemplate|this page is included within other pages]]'
|
2016-02-26 10:28:16 +00:00
|
|
|
] ]
|
2015-08-24 17:40:06 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-09 23:03:19 +00:00
|
|
|
public function testUpdate_categorylinks_move() {
|
2022-07-20 12:42:41 +00:00
|
|
|
$this->overrideConfigValue( MainConfigNames::CategoryCollation, 'uppercase' );
|
2021-12-09 23:03:19 +00:00
|
|
|
|
|
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Old", self::$testingPageId );
|
2021-12-09 23:03:19 +00:00
|
|
|
|
2022-01-15 12:31:58 +00:00
|
|
|
$po->addCategory( "Bar", "BAR" );
|
2021-12-09 23:03:19 +00:00
|
|
|
$po->addCategory( "Foo", "FOO" );
|
|
|
|
|
|
|
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'categorylinks',
|
|
|
|
|
[ 'cl_to', 'cl_sortkey' ],
|
|
|
|
|
'cl_from = ' . self::$testingPageId,
|
|
|
|
|
[
|
2022-01-15 12:31:58 +00:00
|
|
|
[ 'Bar', "BAR\nOLD" ],
|
|
|
|
|
[ 'Foo', "FOO\nOLD" ],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Check category count
|
|
|
|
|
$this->assertSelect(
|
|
|
|
|
[ 'category' ],
|
|
|
|
|
[ 'cat_title', 'cat_pages' ],
|
|
|
|
|
[ 'cat_title' => [ 'Foo', 'Bar', 'Baz' ] ],
|
|
|
|
|
[
|
|
|
|
|
[ 'Bar', '1' ],
|
|
|
|
|
[ 'Foo', '1' ],
|
2021-12-09 23:03:19 +00:00
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "New", self::$testingPageId );
|
2021-12-09 23:03:19 +00:00
|
|
|
|
2022-01-15 12:31:58 +00:00
|
|
|
$po->addCategory( "Bar", "BAR" );
|
2021-12-09 23:03:19 +00:00
|
|
|
$po->addCategory( "Foo", "FOO" );
|
|
|
|
|
|
|
|
|
|
// An update to cl_sortkey is not expected if there was no move
|
|
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'categorylinks',
|
|
|
|
|
[ 'cl_to', 'cl_sortkey' ],
|
|
|
|
|
'cl_from = ' . self::$testingPageId,
|
|
|
|
|
[
|
2022-01-15 12:31:58 +00:00
|
|
|
[ 'Bar', "BAR\nOLD" ],
|
|
|
|
|
[ 'Foo', "FOO\nOLD" ],
|
2021-12-09 23:03:19 +00:00
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
2022-01-15 12:31:58 +00:00
|
|
|
// Check category count
|
|
|
|
|
$this->assertSelect(
|
|
|
|
|
[ 'category' ],
|
|
|
|
|
[ 'cat_title', 'cat_pages' ],
|
|
|
|
|
[ 'cat_title' => [ 'Foo', 'Bar', 'Baz' ] ],
|
|
|
|
|
[
|
|
|
|
|
[ 'Bar', '1' ],
|
|
|
|
|
[ 'Foo', '1' ],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// A category changed on move
|
|
|
|
|
$po->setCategories( [
|
|
|
|
|
"Baz" => "BAZ",
|
|
|
|
|
"Foo" => "FOO",
|
|
|
|
|
] );
|
|
|
|
|
|
2021-12-09 23:03:19 +00:00
|
|
|
// With move notification, update to cl_sortkey is expected
|
|
|
|
|
$this->assertMoveLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
new PageIdentityValue( 2, 0, "new", false ),
|
|
|
|
|
$po,
|
|
|
|
|
'categorylinks',
|
|
|
|
|
[ 'cl_to', 'cl_sortkey' ],
|
|
|
|
|
'cl_from = ' . self::$testingPageId,
|
|
|
|
|
[
|
2022-01-15 12:31:58 +00:00
|
|
|
[ 'Baz', "BAZ\nNEW" ],
|
|
|
|
|
[ 'Foo', "FOO\nNEW" ],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Check category count
|
|
|
|
|
$this->assertSelect(
|
|
|
|
|
[ 'category' ],
|
|
|
|
|
[ 'cat_title', 'cat_pages' ],
|
|
|
|
|
[ 'cat_title' => [ 'Foo', 'Bar', 'Baz' ] ],
|
|
|
|
|
[
|
|
|
|
|
[ 'Baz', '1' ],
|
|
|
|
|
[ 'Foo', '1' ],
|
2021-12-09 23:03:19 +00:00
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addInterwikiLink
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_iwlinks() {
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2021-12-07 04:17:56 +00:00
|
|
|
$target1 = Title::makeTitleSafe( NS_MAIN, "T1", '', 'linksupdatetest' );
|
|
|
|
|
$target2 = Title::makeTitleSafe( NS_MAIN, "T2", '', 'linksupdatetest' );
|
|
|
|
|
$target3 = Title::makeTitleSafe( NS_MAIN, "T3", '', 'linksupdatetest' );
|
|
|
|
|
$po->addInterwikiLink( $target1 );
|
|
|
|
|
$po->addInterwikiLink( $target2 );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2015-12-11 13:17:51 +00:00
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'iwlinks',
|
2021-12-09 23:03:19 +00:00
|
|
|
[ 'iwl_prefix', 'iwl_title' ],
|
2016-03-07 17:26:25 +00:00
|
|
|
'iwl_from = ' . self::$testingPageId,
|
2021-12-07 04:17:56 +00:00
|
|
|
[
|
|
|
|
|
[ 'linksupdatetest', 'T1' ],
|
|
|
|
|
[ 'linksupdatetest', 'T2' ],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2021-12-07 04:17:56 +00:00
|
|
|
|
|
|
|
|
$po->addInterwikiLink( $target2 );
|
|
|
|
|
$po->addInterwikiLink( $target3 );
|
|
|
|
|
|
|
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'iwlinks',
|
2021-12-09 23:03:19 +00:00
|
|
|
[ 'iwl_prefix', 'iwl_title' ],
|
2021-12-07 04:17:56 +00:00
|
|
|
'iwl_from = ' . self::$testingPageId,
|
|
|
|
|
[
|
|
|
|
|
[ 'linksupdatetest', 'T2' ],
|
|
|
|
|
[ 'linksupdatetest', 'T3' ]
|
|
|
|
|
]
|
2015-12-11 13:17:51 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addTemplate
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_templatelinks() {
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2022-09-06 09:27:52 +00:00
|
|
|
$linkTargetLookup = MediaWikiServices::getInstance()->getLinkTargetLookup();
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2021-12-07 04:17:56 +00:00
|
|
|
$target1 = Title::newFromText( "Template:T1" );
|
|
|
|
|
$target2 = Title::newFromText( "Template:T2" );
|
|
|
|
|
$target3 = Title::newFromText( "Template:T3" );
|
|
|
|
|
|
|
|
|
|
$po->addTemplate( $target1, 23, 42 );
|
|
|
|
|
$po->addTemplate( $target2, 23, 42 );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2014-04-24 10:05:52 +00:00
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'templatelinks',
|
2022-09-06 09:27:52 +00:00
|
|
|
[ 'tl_target_id' ],
|
2016-03-07 17:26:25 +00:00
|
|
|
'tl_from = ' . self::$testingPageId,
|
2021-12-07 04:17:56 +00:00
|
|
|
[
|
2022-09-06 09:27:52 +00:00
|
|
|
[ $linkTargetLookup->acquireLinkTargetId( $target1, $this->db ) ],
|
|
|
|
|
[ $linkTargetLookup->acquireLinkTargetId( $target2, $this->db ) ],
|
2021-12-07 04:17:56 +00:00
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2021-12-07 04:17:56 +00:00
|
|
|
|
|
|
|
|
$po->addTemplate( $target2, 23, 42 );
|
|
|
|
|
$po->addTemplate( $target3, 23, 42 );
|
|
|
|
|
|
|
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'templatelinks',
|
2022-09-06 09:27:52 +00:00
|
|
|
[ 'tl_target_id' ],
|
2021-12-07 04:17:56 +00:00
|
|
|
'tl_from = ' . self::$testingPageId,
|
|
|
|
|
[
|
2022-09-06 09:27:52 +00:00
|
|
|
[ $linkTargetLookup->acquireLinkTargetId( $target2, $this->db ) ],
|
|
|
|
|
[ $linkTargetLookup->acquireLinkTargetId( $target3, $this->db ) ],
|
2021-12-07 04:17:56 +00:00
|
|
|
]
|
2014-04-24 10:05:52 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addImage
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_imagelinks() {
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2021-12-07 04:17:56 +00:00
|
|
|
$po->addImage( "1.png" );
|
|
|
|
|
$po->addImage( "2.png" );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2015-12-11 13:17:51 +00:00
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'imagelinks',
|
|
|
|
|
'il_to',
|
2016-03-07 17:26:25 +00:00
|
|
|
'il_from = ' . self::$testingPageId,
|
2021-12-07 04:17:56 +00:00
|
|
|
[ [ '1.png' ], [ '2.png' ] ]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2021-12-07 04:17:56 +00:00
|
|
|
|
|
|
|
|
$po->addImage( "2.png" );
|
|
|
|
|
$po->addImage( "3.png" );
|
|
|
|
|
|
|
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'imagelinks',
|
|
|
|
|
'il_to',
|
|
|
|
|
'il_from = ' . self::$testingPageId,
|
|
|
|
|
[ [ '2.png' ], [ '3.png' ] ]
|
2015-12-11 13:17:51 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2022-01-15 12:27:24 +00:00
|
|
|
public function testUpdate_imagelinks_move() {
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2022-01-15 12:27:24 +00:00
|
|
|
|
|
|
|
|
$po->addImage( "1.png" );
|
|
|
|
|
$po->addImage( "2.png" );
|
|
|
|
|
|
|
|
|
|
$fromNamespace = $t->getNamespace();
|
|
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'imagelinks',
|
|
|
|
|
[ 'il_to', 'il_from_namespace' ],
|
|
|
|
|
[ 'il_from' => self::$testingPageId ],
|
|
|
|
|
[ [ '1.png', $fromNamespace ], [ '2.png', $fromNamespace ] ]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$oldT = $t;
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "User:Testing", self::$testingPageId );
|
2022-01-15 12:27:24 +00:00
|
|
|
$po->addImage( "1.png" );
|
|
|
|
|
$po->addImage( "2.png" );
|
|
|
|
|
|
|
|
|
|
$fromNamespace = $t->getNamespace();
|
|
|
|
|
$this->assertMoveLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$oldT->toPageIdentity(),
|
|
|
|
|
$po,
|
|
|
|
|
'imagelinks',
|
|
|
|
|
[ 'il_to', 'il_from_namespace' ],
|
|
|
|
|
[ 'il_from' => self::$testingPageId ],
|
|
|
|
|
[ [ '1.png', $fromNamespace ], [ '2.png', $fromNamespace ] ]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addLanguageLink
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_langlinks() {
|
2022-07-20 12:42:41 +00:00
|
|
|
$this->overrideConfigValue( MainConfigNames::CapitalLinks, true );
|
2014-07-07 23:21:09 +00:00
|
|
|
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2021-12-07 04:17:56 +00:00
|
|
|
$po->addLanguageLink( 'De:1' );
|
|
|
|
|
$po->addLanguageLink( 'En:1' );
|
|
|
|
|
$po->addLanguageLink( 'Fr:1' );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2015-12-11 13:17:51 +00:00
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'langlinks',
|
2021-12-09 23:03:19 +00:00
|
|
|
[ 'll_lang', 'll_title' ],
|
2016-03-07 17:26:25 +00:00
|
|
|
'll_from = ' . self::$testingPageId,
|
2021-12-07 04:17:56 +00:00
|
|
|
[
|
|
|
|
|
[ 'De', '1' ],
|
|
|
|
|
[ 'En', '1' ],
|
|
|
|
|
[ 'Fr', '1' ]
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2021-12-07 04:17:56 +00:00
|
|
|
$po->addLanguageLink( 'En:2' );
|
|
|
|
|
$po->addLanguageLink( 'Fr:1' );
|
|
|
|
|
|
|
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'langlinks',
|
2021-12-09 23:03:19 +00:00
|
|
|
[ 'll_lang', 'll_title' ],
|
2021-12-07 04:17:56 +00:00
|
|
|
'll_from = ' . self::$testingPageId,
|
|
|
|
|
[
|
|
|
|
|
[ 'En', '2' ],
|
|
|
|
|
[ 'Fr', '1' ]
|
|
|
|
|
]
|
2015-12-11 13:17:51 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2021-10-07 16:13:46 +00:00
|
|
|
* @covers ParserOutput::setPageProperty
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_page_props() {
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2021-02-05 14:15:30 +00:00
|
|
|
$fields = [ 'pp_propname', 'pp_value', 'pp_sortkey' ];
|
2021-12-07 04:17:56 +00:00
|
|
|
$cond = 'pp_page = ' . self::$testingPageId;
|
|
|
|
|
|
|
|
|
|
$po->setPageProperty( 'deleted', 1 );
|
|
|
|
|
$po->setPageProperty( 'changed', 1 );
|
|
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t, $po, 'page_props', $fields, $cond,
|
|
|
|
|
[
|
|
|
|
|
[ 'changed', '1', 1 ],
|
|
|
|
|
[ 'deleted', '1', 1 ]
|
|
|
|
|
]
|
|
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2021-12-07 04:17:56 +00:00
|
|
|
|
|
|
|
|
$expected = [];
|
2021-10-07 16:13:46 +00:00
|
|
|
$po->setPageProperty( "bool", true );
|
2016-02-17 09:09:32 +00:00
|
|
|
$expected[] = [ "bool", true ];
|
2014-03-31 11:00:28 +00:00
|
|
|
|
2021-12-07 04:17:56 +00:00
|
|
|
$po->setPageProperty( 'changed', 2 );
|
|
|
|
|
$expected[] = [ 'changed', 2 ];
|
|
|
|
|
|
2021-10-07 16:13:46 +00:00
|
|
|
$po->setPageProperty( "float", 4.0 + 1.0 / 4.0 );
|
2016-02-17 09:09:32 +00:00
|
|
|
$expected[] = [ "float", 4.0 + 1.0 / 4.0 ];
|
2014-03-31 11:00:28 +00:00
|
|
|
|
2021-10-07 16:13:46 +00:00
|
|
|
$po->setPageProperty( "int", -7 );
|
2016-02-17 09:09:32 +00:00
|
|
|
$expected[] = [ "int", -7 ];
|
2014-03-31 11:00:28 +00:00
|
|
|
|
2021-10-07 16:13:46 +00:00
|
|
|
$po->setPageProperty( "string", "33 bar" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$expected[] = [ "string", "33 bar" ];
|
2014-03-31 11:00:28 +00:00
|
|
|
|
|
|
|
|
// compute expected sortkey values
|
2021-02-05 14:15:30 +00:00
|
|
|
foreach ( $expected as &$row ) {
|
|
|
|
|
$value = $row[1];
|
2014-03-31 11:00:28 +00:00
|
|
|
|
2021-02-05 14:15:30 +00:00
|
|
|
if ( is_int( $value ) || is_float( $value ) || is_bool( $value ) ) {
|
|
|
|
|
$row[] = floatval( $value );
|
|
|
|
|
} else {
|
|
|
|
|
$row[] = null;
|
2014-03-31 11:00:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 04:17:56 +00:00
|
|
|
$update = $this->assertLinksUpdate(
|
2016-03-07 17:26:25 +00:00
|
|
|
$t, $po, 'page_props', $fields, 'pp_page = ' . self::$testingPageId, $expected );
|
2021-12-07 04:17:56 +00:00
|
|
|
|
|
|
|
|
$expectedAssoc = [];
|
2022-10-21 04:32:38 +00:00
|
|
|
foreach ( $expected as [ $name, $value ] ) {
|
2021-12-07 04:17:56 +00:00
|
|
|
$expectedAssoc[$name] = $value;
|
|
|
|
|
}
|
|
|
|
|
$this->assertArrayEquals( $expectedAssoc, $update->getAddedProperties() );
|
|
|
|
|
$this->assertArrayEquals(
|
|
|
|
|
[
|
|
|
|
|
'changed' => '1',
|
|
|
|
|
'deleted' => '1'
|
|
|
|
|
],
|
|
|
|
|
$update->getRemovedProperties()
|
|
|
|
|
);
|
2014-03-31 11:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-15 01:12:35 +00:00
|
|
|
// @todo test recursive, too!
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2014-04-24 10:05:52 +00:00
|
|
|
protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput,
|
|
|
|
|
$table, $fields, $condition, array $expectedRows
|
2021-12-09 23:03:19 +00:00
|
|
|
) {
|
|
|
|
|
return $this->assertMoveLinksUpdate( $title, null, $parserOutput,
|
|
|
|
|
$table, $fields, $condition, $expectedRows );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function assertMoveLinksUpdate(
|
|
|
|
|
Title $title, ?PageIdentityValue $oldTitle, ParserOutput $parserOutput,
|
|
|
|
|
$table, $fields, $condition, array $expectedRows
|
2014-04-24 10:05:52 +00:00
|
|
|
) {
|
2012-05-10 20:56:34 +00:00
|
|
|
$update = new LinksUpdate( $title, $parserOutput );
|
2021-12-07 04:17:56 +00:00
|
|
|
$update->setStrictTestMode();
|
2021-12-09 23:03:19 +00:00
|
|
|
if ( $oldTitle ) {
|
|
|
|
|
$update->setMoveDetails( $oldTitle );
|
|
|
|
|
}
|
rdbms: Consolidate logger channels into one
Notable changes:
* In SqlBagOStuff::getConnectionFromServerInfo, only two loggers were
injected. The rest implicitly got a NullLogger due to being absent.
These are now effectively unsilenced.
* Database::__construct() required almost all parameters, even the
loggers. I've wanted to move some of DatabaseFactory into the ctor
here for a while. In order to make this change not a breaking
change, the new 'logger' parameter is optional with NullLogger as
default. This allowed some of the test cases, which were simply
passing NullLogger, to be fixed by passing nothing instead of
passing the new option name.
The Database class is behind a dozen layers of indirection for
real use, so this will still be injected just fine (DBF, LB, LBF,
MWLBF, etc.).
* In LegacyLogger, the handling for $wgDBerrorLog was previously
limited to DBConnection and DBQuery. This now includes errors
from other (generally, newer) parts of Rdbms as well, which were
previously missing.
This only affects sites (typically CI and dev setup) where
$wgDBerrorLog is used, as opposed to the more common
$wgDebugLogGroups by-channel configuration.
* TransactionProfiler gets its logger injected in a rather odd way,
via entrypoints (MediaWiki.php, ApiMain.php, and MaintenanceRunner)
as opposed to service wiring. This is kept as-is for now.
* In LBFactoryTest, in particular testInvalidSelectDBIndependent2,
there are cases that intentionally produce failures of which
the result is then observed. In CI we assert that dberror.log is
empty so instead of adding the missing logger fields to that
LBFactory instance, the only one set (replLogger) is removed.
The alternative is to set 'logger' now, which would naturally
cause CI failures due to unexpected entries coming through to
non-mocked error log.
Bug: T320873
Change-Id: I7ca996618e41b93f488cb5c4de82000bb36e0dd3
2022-10-15 20:16:07 +00:00
|
|
|
$this->setTransactionTicket( $update );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$update->doUpdate();
|
|
|
|
|
|
|
|
|
|
$this->assertSelect( $table, $fields, $condition, $expectedRows );
|
2013-10-09 18:48:37 +00:00
|
|
|
return $update;
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
2015-08-24 17:40:06 +00:00
|
|
|
|
|
|
|
|
protected function assertRecentChangeByCategorization(
|
|
|
|
|
Title $pageTitle, ParserOutput $parserOutput, Title $categoryTitle, $expectedRows
|
|
|
|
|
) {
|
2019-01-04 18:55:11 +00:00
|
|
|
$this->assertSelect(
|
|
|
|
|
[ 'recentchanges', 'comment' ],
|
2021-12-09 23:03:19 +00:00
|
|
|
[ 'rc_title', 'comment_text' ],
|
2019-01-04 18:55:11 +00:00
|
|
|
[
|
|
|
|
|
'rc_type' => RC_CATEGORIZE,
|
|
|
|
|
'rc_namespace' => NS_CATEGORY,
|
|
|
|
|
'rc_title' => $categoryTitle->getDBkey(),
|
|
|
|
|
'comment_id = rc_comment_id',
|
|
|
|
|
],
|
|
|
|
|
$expectedRows
|
|
|
|
|
);
|
2015-08-24 17:40:06 +00:00
|
|
|
}
|
2015-11-15 02:29:37 +00:00
|
|
|
|
|
|
|
|
private function runAllRelatedJobs() {
|
2022-01-27 20:19:18 +00:00
|
|
|
$queueGroup = $this->getServiceContainer()->getJobQueueGroup();
|
2015-11-15 02:29:37 +00:00
|
|
|
while ( $job = $queueGroup->pop( 'refreshLinksPrioritized' ) ) {
|
|
|
|
|
$job->run();
|
|
|
|
|
$queueGroup->ack( $job );
|
|
|
|
|
}
|
|
|
|
|
while ( $job = $queueGroup->pop( 'categoryMembershipChange' ) ) {
|
|
|
|
|
$job->run();
|
|
|
|
|
$queueGroup->ack( $job );
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-11 14:48:02 +00:00
|
|
|
|
|
|
|
|
public function testIsRecursive() {
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $title, $po ] = $this->makeTitleAndParserOutput( 'Test', 1 );
|
2019-09-11 14:48:02 +00:00
|
|
|
$linksUpdate = new LinksUpdate( $title, $po );
|
|
|
|
|
$this->assertTrue( $linksUpdate->isRecursive(), 'LinksUpdate is recursive by default' );
|
|
|
|
|
|
|
|
|
|
$linksUpdate = new LinksUpdate( $title, $po, true );
|
|
|
|
|
$this->assertTrue( $linksUpdate->isRecursive(),
|
|
|
|
|
'LinksUpdate is recursive when asked to be recursive' );
|
|
|
|
|
|
|
|
|
|
$linksUpdate = new LinksUpdate( $title, $po, false );
|
|
|
|
|
$this->assertFalse( $linksUpdate->isRecursive(),
|
|
|
|
|
'LinksUpdate is not recursive when asked to be not recursive' );
|
|
|
|
|
}
|
2022-01-28 04:00:19 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Confirm that repeatedly saving the same ParserOutput does not lead to
|
|
|
|
|
* DELETE/INSERT queries (T299662)
|
|
|
|
|
*/
|
|
|
|
|
public function testNullEdit() {
|
|
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2022-01-28 04:00:19 +00:00
|
|
|
$po->addCategory( 'Test', 'Test' );
|
|
|
|
|
$po->addExternalLink( 'http://www.example.com/' );
|
|
|
|
|
$po->addImage( 'Test' );
|
|
|
|
|
$po->addInterwikiLink( new TitleValue( 0, 'test', '', 'test' ) );
|
|
|
|
|
$po->addLanguageLink( 'en:Test' );
|
|
|
|
|
$po->addLink( new TitleValue( 0, 'Test' ) );
|
|
|
|
|
$po->setPageProperty( 'string', 'x' );
|
|
|
|
|
$po->setPageProperty( 'numeric-string', '1' );
|
|
|
|
|
$po->setPageProperty( 'int', 10 );
|
|
|
|
|
$po->setPageProperty( 'float', 2 / 3 );
|
|
|
|
|
$po->setPageProperty( 'true', true );
|
|
|
|
|
$po->setPageProperty( 'false', false );
|
|
|
|
|
$po->setPageProperty( 'null', null );
|
|
|
|
|
|
|
|
|
|
$update = new LinksUpdate( $t, $po );
|
|
|
|
|
$update->setStrictTestMode();
|
rdbms: Consolidate logger channels into one
Notable changes:
* In SqlBagOStuff::getConnectionFromServerInfo, only two loggers were
injected. The rest implicitly got a NullLogger due to being absent.
These are now effectively unsilenced.
* Database::__construct() required almost all parameters, even the
loggers. I've wanted to move some of DatabaseFactory into the ctor
here for a while. In order to make this change not a breaking
change, the new 'logger' parameter is optional with NullLogger as
default. This allowed some of the test cases, which were simply
passing NullLogger, to be fixed by passing nothing instead of
passing the new option name.
The Database class is behind a dozen layers of indirection for
real use, so this will still be injected just fine (DBF, LB, LBF,
MWLBF, etc.).
* In LegacyLogger, the handling for $wgDBerrorLog was previously
limited to DBConnection and DBQuery. This now includes errors
from other (generally, newer) parts of Rdbms as well, which were
previously missing.
This only affects sites (typically CI and dev setup) where
$wgDBerrorLog is used, as opposed to the more common
$wgDebugLogGroups by-channel configuration.
* TransactionProfiler gets its logger injected in a rather odd way,
via entrypoints (MediaWiki.php, ApiMain.php, and MaintenanceRunner)
as opposed to service wiring. This is kept as-is for now.
* In LBFactoryTest, in particular testInvalidSelectDBIndependent2,
there are cases that intentionally produce failures of which
the result is then observed. In CI we assert that dberror.log is
empty so instead of adding the missing logger fields to that
LBFactory instance, the only one set (replLogger) is removed.
The alternative is to set 'logger' now, which would naturally
cause CI failures due to unexpected entries coming through to
non-mocked error log.
Bug: T320873
Change-Id: I7ca996618e41b93f488cb5c4de82000bb36e0dd3
2022-10-15 20:16:07 +00:00
|
|
|
$this->setTransactionTicket( $update );
|
2022-01-28 04:00:19 +00:00
|
|
|
$update->doUpdate();
|
|
|
|
|
|
|
|
|
|
$dbw = wfGetDB( DB_PRIMARY );
|
|
|
|
|
$time1 = $dbw->lastDoneWrites();
|
|
|
|
|
$this->assertGreaterThan( 0, $time1 );
|
|
|
|
|
|
|
|
|
|
$update = new class( $t, $po ) extends LinksUpdate {
|
|
|
|
|
protected function updateLinksTimestamp() {
|
|
|
|
|
// Updating the timestamp is allowed, ignore
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
$update->setStrictTestMode();
|
|
|
|
|
$update->doUpdate();
|
|
|
|
|
$time2 = wfGetDB( DB_PRIMARY )->lastDoneWrites();
|
|
|
|
|
$this->assertSame( $time1, $time2 );
|
|
|
|
|
}
|
2022-02-14 04:28:20 +00:00
|
|
|
|
|
|
|
|
public static function provideNumericKeys() {
|
|
|
|
|
$tables = TestingAccessWrapper::constant( LinksTableGroup::class, 'CORE_LIST' );
|
|
|
|
|
foreach ( $tables as $tableName => $spec ) {
|
|
|
|
|
yield [ $tableName ];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unit test for numeric strings in ParserOutput array keys (T301433)
|
|
|
|
|
*
|
|
|
|
|
* @dataProvider provideNumericKeys
|
|
|
|
|
*/
|
|
|
|
|
public function testNumericKeys( $tableName ) {
|
|
|
|
|
$s = '123';
|
|
|
|
|
$i = 123;
|
|
|
|
|
|
|
|
|
|
/** @var ParserOutput $po */
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2022-02-14 04:28:20 +00:00
|
|
|
$po->addCategory( $s, $s );
|
|
|
|
|
$po->addExternalLink( $s );
|
|
|
|
|
$po->addImage( $s );
|
|
|
|
|
$po->addInterwikiLink( new TitleValue( 0, $s, '', $s ) );
|
|
|
|
|
$po->addLanguageLink( "$s:$s" );
|
|
|
|
|
$po->addLink( new TitleValue( 0, $s ) );
|
|
|
|
|
$po->setPageProperty( $s, $s );
|
|
|
|
|
$po->addTemplate( new TitleValue( 0, $s ), 1, 1 );
|
|
|
|
|
|
|
|
|
|
$update = new LinksUpdate( $t, $po );
|
|
|
|
|
/** @var LinksTableGroup $tg */
|
|
|
|
|
$tg = TestingAccessWrapper::newFromObject( $update )->tableFactory;
|
|
|
|
|
$table = $tg->get( $tableName );
|
|
|
|
|
/** @var LinksTable $tt */
|
|
|
|
|
$tt = TestingAccessWrapper::newFromObject( $table );
|
|
|
|
|
$tableName = $tt->getTableName();
|
|
|
|
|
foreach ( $tt->getNewLinkIDs() as $linkID ) {
|
|
|
|
|
foreach ( (array)$linkID as $component ) {
|
|
|
|
|
$this->assertNotSame( $i, $component,
|
|
|
|
|
"Link ID of table $tableName should not be an integer " );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Integration test for numeric category names (T301433)
|
|
|
|
|
*/
|
|
|
|
|
public function testNumericCategory() {
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Test 1", self::$testingPageId + 1 );
|
2022-02-14 04:28:20 +00:00
|
|
|
$po->addCategory( '123a', '123a' );
|
|
|
|
|
$update = new LinksUpdate( $t, $po );
|
rdbms: Consolidate logger channels into one
Notable changes:
* In SqlBagOStuff::getConnectionFromServerInfo, only two loggers were
injected. The rest implicitly got a NullLogger due to being absent.
These are now effectively unsilenced.
* Database::__construct() required almost all parameters, even the
loggers. I've wanted to move some of DatabaseFactory into the ctor
here for a while. In order to make this change not a breaking
change, the new 'logger' parameter is optional with NullLogger as
default. This allowed some of the test cases, which were simply
passing NullLogger, to be fixed by passing nothing instead of
passing the new option name.
The Database class is behind a dozen layers of indirection for
real use, so this will still be injected just fine (DBF, LB, LBF,
MWLBF, etc.).
* In LegacyLogger, the handling for $wgDBerrorLog was previously
limited to DBConnection and DBQuery. This now includes errors
from other (generally, newer) parts of Rdbms as well, which were
previously missing.
This only affects sites (typically CI and dev setup) where
$wgDBerrorLog is used, as opposed to the more common
$wgDebugLogGroups by-channel configuration.
* TransactionProfiler gets its logger injected in a rather odd way,
via entrypoints (MediaWiki.php, ApiMain.php, and MaintenanceRunner)
as opposed to service wiring. This is kept as-is for now.
* In LBFactoryTest, in particular testInvalidSelectDBIndependent2,
there are cases that intentionally produce failures of which
the result is then observed. In CI we assert that dberror.log is
empty so instead of adding the missing logger fields to that
LBFactory instance, the only one set (replLogger) is removed.
The alternative is to set 'logger' now, which would naturally
cause CI failures due to unexpected entries coming through to
non-mocked error log.
Bug: T320873
Change-Id: I7ca996618e41b93f488cb5c4de82000bb36e0dd3
2022-10-15 20:16:07 +00:00
|
|
|
$this->setTransactionTicket( $update );
|
2022-02-14 04:28:20 +00:00
|
|
|
$update->setStrictTestMode();
|
|
|
|
|
$update->doUpdate();
|
|
|
|
|
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $t, $po ] = $this->makeTitleAndParserOutput( "Test 2", self::$testingPageId + 2 );
|
2022-02-14 04:28:20 +00:00
|
|
|
$po->addCategory( '123', '123' );
|
|
|
|
|
$update = new LinksUpdate( $t, $po );
|
rdbms: Consolidate logger channels into one
Notable changes:
* In SqlBagOStuff::getConnectionFromServerInfo, only two loggers were
injected. The rest implicitly got a NullLogger due to being absent.
These are now effectively unsilenced.
* Database::__construct() required almost all parameters, even the
loggers. I've wanted to move some of DatabaseFactory into the ctor
here for a while. In order to make this change not a breaking
change, the new 'logger' parameter is optional with NullLogger as
default. This allowed some of the test cases, which were simply
passing NullLogger, to be fixed by passing nothing instead of
passing the new option name.
The Database class is behind a dozen layers of indirection for
real use, so this will still be injected just fine (DBF, LB, LBF,
MWLBF, etc.).
* In LegacyLogger, the handling for $wgDBerrorLog was previously
limited to DBConnection and DBQuery. This now includes errors
from other (generally, newer) parts of Rdbms as well, which were
previously missing.
This only affects sites (typically CI and dev setup) where
$wgDBerrorLog is used, as opposed to the more common
$wgDebugLogGroups by-channel configuration.
* TransactionProfiler gets its logger injected in a rather odd way,
via entrypoints (MediaWiki.php, ApiMain.php, and MaintenanceRunner)
as opposed to service wiring. This is kept as-is for now.
* In LBFactoryTest, in particular testInvalidSelectDBIndependent2,
there are cases that intentionally produce failures of which
the result is then observed. In CI we assert that dberror.log is
empty so instead of adding the missing logger fields to that
LBFactory instance, the only one set (replLogger) is removed.
The alternative is to set 'logger' now, which would naturally
cause CI failures due to unexpected entries coming through to
non-mocked error log.
Bug: T320873
Change-Id: I7ca996618e41b93f488cb5c4de82000bb36e0dd3
2022-10-15 20:16:07 +00:00
|
|
|
$this->setTransactionTicket( $update );
|
2022-02-14 04:28:20 +00:00
|
|
|
$update->setStrictTestMode();
|
|
|
|
|
$update->doUpdate();
|
|
|
|
|
|
|
|
|
|
$this->assertSelect(
|
|
|
|
|
'category',
|
|
|
|
|
'cat_pages',
|
|
|
|
|
[ 'cat_title' => '123a' ],
|
|
|
|
|
[ [ '1' ] ]
|
|
|
|
|
);
|
|
|
|
|
}
|
rdbms: Consolidate logger channels into one
Notable changes:
* In SqlBagOStuff::getConnectionFromServerInfo, only two loggers were
injected. The rest implicitly got a NullLogger due to being absent.
These are now effectively unsilenced.
* Database::__construct() required almost all parameters, even the
loggers. I've wanted to move some of DatabaseFactory into the ctor
here for a while. In order to make this change not a breaking
change, the new 'logger' parameter is optional with NullLogger as
default. This allowed some of the test cases, which were simply
passing NullLogger, to be fixed by passing nothing instead of
passing the new option name.
The Database class is behind a dozen layers of indirection for
real use, so this will still be injected just fine (DBF, LB, LBF,
MWLBF, etc.).
* In LegacyLogger, the handling for $wgDBerrorLog was previously
limited to DBConnection and DBQuery. This now includes errors
from other (generally, newer) parts of Rdbms as well, which were
previously missing.
This only affects sites (typically CI and dev setup) where
$wgDBerrorLog is used, as opposed to the more common
$wgDebugLogGroups by-channel configuration.
* TransactionProfiler gets its logger injected in a rather odd way,
via entrypoints (MediaWiki.php, ApiMain.php, and MaintenanceRunner)
as opposed to service wiring. This is kept as-is for now.
* In LBFactoryTest, in particular testInvalidSelectDBIndependent2,
there are cases that intentionally produce failures of which
the result is then observed. In CI we assert that dberror.log is
empty so instead of adding the missing logger fields to that
LBFactory instance, the only one set (replLogger) is removed.
The alternative is to set 'logger' now, which would naturally
cause CI failures due to unexpected entries coming through to
non-mocked error log.
Bug: T320873
Change-Id: I7ca996618e41b93f488cb5c4de82000bb36e0dd3
2022-10-15 20:16:07 +00:00
|
|
|
|
|
|
|
|
private function setTransactionTicket( LinksUpdate $update ) {
|
|
|
|
|
$update->setTransactionTicket(
|
|
|
|
|
$this->getServiceContainer()->getDBLoadBalancerFactory()->getEmptyTransactionTicket( __METHOD__ )
|
|
|
|
|
);
|
|
|
|
|
}
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|