115 lines
2.6 KiB
PHP
115 lines
2.6 KiB
PHP
|
|
<?php
|
||
|
|
namespace MediaWiki\Tests\Storage;
|
||
|
|
|
||
|
|
use MediaWiki\Storage\RevisionRecord;
|
||
|
|
use MediaWiki\Storage\SlotRecord;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Tests RevisionStore against the intermediate MCR DB schema for use during schema migration.
|
||
|
|
*
|
||
|
|
* @covers \MediaWiki\Storage\RevisionStore
|
||
|
|
*
|
||
|
|
* @group RevisionStore
|
||
|
|
* @group Storage
|
||
|
|
* @group Database
|
||
|
|
* @group medium
|
||
|
|
*/
|
||
|
|
class McrWriteBothRevisionStoreDbTest extends RevisionStoreDbTestBase {
|
||
|
|
|
||
|
|
use McrWriteBothSchemaOverride;
|
||
|
|
|
||
|
|
protected function assertRevisionExistsInDatabase( RevisionRecord $rev ) {
|
||
|
|
parent::assertRevisionExistsInDatabase( $rev );
|
||
|
|
|
||
|
|
$this->assertSelect(
|
||
|
|
'slots', [ 'count(*)' ], [ 'slot_revision_id' => $rev->getId() ], [ [ '1' ] ]
|
||
|
|
);
|
||
|
|
$this->assertSelect(
|
||
|
|
'content',
|
||
|
|
[ 'count(*)' ],
|
||
|
|
[ 'content_address' => $rev->getSlot( 'main' )->getAddress() ],
|
||
|
|
[ [ '1' ] ]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param SlotRecord $a
|
||
|
|
* @param SlotRecord $b
|
||
|
|
*/
|
||
|
|
protected function assertSameSlotContent( SlotRecord $a, SlotRecord $b ) {
|
||
|
|
parent::assertSameSlotContent( $a, $b );
|
||
|
|
|
||
|
|
// Assert that the same content ID has been used
|
||
|
|
if ( $a->hasContentId() && $b->hasContentId() ) {
|
||
|
|
$this->assertSame( $a->getContentId(), $b->getContentId() );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public function provideGetArchiveQueryInfo() {
|
||
|
|
yield [
|
||
|
|
[
|
||
|
|
'tables' => [ 'archive' ],
|
||
|
|
'fields' => array_merge(
|
||
|
|
$this->getDefaultArchiveFields(),
|
||
|
|
[
|
||
|
|
'ar_comment_text' => 'ar_comment',
|
||
|
|
'ar_comment_data' => 'NULL',
|
||
|
|
'ar_comment_cid' => 'NULL',
|
||
|
|
'ar_user_text' => 'ar_user_text',
|
||
|
|
'ar_user' => 'ar_user',
|
||
|
|
'ar_actor' => 'NULL',
|
||
|
|
'ar_content_format',
|
||
|
|
'ar_content_model',
|
||
|
|
]
|
||
|
|
),
|
||
|
|
'joins' => [],
|
||
|
|
]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function provideGetQueryInfo() {
|
||
|
|
yield [
|
||
|
|
[],
|
||
|
|
[
|
||
|
|
'tables' => [ 'revision' ],
|
||
|
|
'fields' => array_merge(
|
||
|
|
$this->getDefaultQueryFields(),
|
||
|
|
$this->getCommentQueryFields(),
|
||
|
|
$this->getActorQueryFields(),
|
||
|
|
$this->getContentHandlerQueryFields()
|
||
|
|
),
|
||
|
|
'joins' => [],
|
||
|
|
]
|
||
|
|
];
|
||
|
|
yield [
|
||
|
|
[ 'page', 'user', 'text' ],
|
||
|
|
[
|
||
|
|
'tables' => [ 'revision', 'page', 'user', 'text' ],
|
||
|
|
'fields' => array_merge(
|
||
|
|
$this->getDefaultQueryFields(),
|
||
|
|
$this->getCommentQueryFields(),
|
||
|
|
$this->getActorQueryFields(),
|
||
|
|
$this->getContentHandlerQueryFields(),
|
||
|
|
[
|
||
|
|
'page_namespace',
|
||
|
|
'page_title',
|
||
|
|
'page_id',
|
||
|
|
'page_latest',
|
||
|
|
'page_is_redirect',
|
||
|
|
'page_len',
|
||
|
|
'user_name',
|
||
|
|
'old_text',
|
||
|
|
'old_flags',
|
||
|
|
]
|
||
|
|
),
|
||
|
|
'joins' => [
|
||
|
|
'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
|
||
|
|
'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
|
||
|
|
'text' => [ 'INNER JOIN', [ 'rev_text_id=old_id' ] ],
|
||
|
|
],
|
||
|
|
]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|