During development a lot of classes were placed in MediaWiki\Storage\. The precedent set would mean that every class relating to something stored in a database table, plus all related value classes and such, would go into that namespace. Let's put them into MediaWiki\Revision\ instead. Then future classes related to the 'page' table can go into MediaWiki\Page\, future classes related to the 'user' table can go into MediaWiki\User\, and so on. Note I didn't move DerivedPageDataUpdater, PageUpdateException, PageUpdater, or RevisionSlotsUpdate in this patch. If these are kept long-term, they probably belong in MediaWiki\Page\ or MediaWiki\Edit\ instead. Bug: T204158 Change-Id: I16bea8927566a3c73c07e4f4afb3537e05aa04a5
191 lines
3.9 KiB
PHP
191 lines
3.9 KiB
PHP
<?php
|
|
namespace MediaWiki\Tests\Revision;
|
|
|
|
use Revision;
|
|
|
|
/**
|
|
* Tests RevisionStore against the pre-MCR, pre-ContentHandler DB schema.
|
|
*
|
|
* @covers \MediaWiki\Revision\RevisionStore
|
|
*
|
|
* @group RevisionStore
|
|
* @group Storage
|
|
* @group Database
|
|
* @group medium
|
|
*/
|
|
class NoContentModelRevisionStoreDbTest extends RevisionStoreDbTestBase {
|
|
|
|
use PreMcrSchemaOverride;
|
|
|
|
protected function getContentHandlerUseDB() {
|
|
return false;
|
|
}
|
|
|
|
protected function revisionToRow( Revision $rev, $options = [ 'page', 'user', 'comment' ] ) {
|
|
$row = parent::revisionToRow( $rev, $options );
|
|
|
|
$row->rev_text_id = (string)$rev->getTextId();
|
|
|
|
return $row;
|
|
}
|
|
|
|
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',
|
|
]
|
|
),
|
|
'joins' => [],
|
|
]
|
|
];
|
|
}
|
|
|
|
public function provideGetQueryInfo() {
|
|
yield [
|
|
[],
|
|
[
|
|
'tables' => [ 'revision' ],
|
|
'fields' => array_merge(
|
|
$this->getDefaultQueryFields(),
|
|
$this->getCommentQueryFields(),
|
|
$this->getActorQueryFields()
|
|
),
|
|
'joins' => [],
|
|
]
|
|
];
|
|
yield [
|
|
[ 'page' ],
|
|
[
|
|
'tables' => [ 'revision', 'page' ],
|
|
'fields' => array_merge(
|
|
$this->getDefaultQueryFields(),
|
|
$this->getCommentQueryFields(),
|
|
$this->getActorQueryFields(),
|
|
[
|
|
'page_namespace',
|
|
'page_title',
|
|
'page_id',
|
|
'page_latest',
|
|
'page_is_redirect',
|
|
'page_len',
|
|
]
|
|
),
|
|
'joins' => [
|
|
'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
|
|
],
|
|
]
|
|
];
|
|
yield [
|
|
[ 'user' ],
|
|
[
|
|
'tables' => [ 'revision', 'user' ],
|
|
'fields' => array_merge(
|
|
$this->getDefaultQueryFields(),
|
|
$this->getCommentQueryFields(),
|
|
$this->getActorQueryFields(),
|
|
[
|
|
'user_name',
|
|
]
|
|
),
|
|
'joins' => [
|
|
'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
|
|
],
|
|
]
|
|
];
|
|
yield [
|
|
[ 'text' ],
|
|
[
|
|
'tables' => [ 'revision', 'text' ],
|
|
'fields' => array_merge(
|
|
$this->getDefaultQueryFields(),
|
|
$this->getCommentQueryFields(),
|
|
$this->getActorQueryFields(),
|
|
[
|
|
'old_text',
|
|
'old_flags',
|
|
]
|
|
),
|
|
'joins' => [
|
|
'text' => [ 'INNER JOIN', [ 'rev_text_id=old_id' ] ],
|
|
],
|
|
]
|
|
];
|
|
}
|
|
|
|
public function provideGetSlotsQueryInfo() {
|
|
$db = wfGetDB( DB_REPLICA );
|
|
|
|
yield [
|
|
[],
|
|
[
|
|
'tables' => [
|
|
'slots' => 'revision',
|
|
],
|
|
'fields' => array_merge(
|
|
[
|
|
'slot_revision_id' => 'slots.rev_id',
|
|
'slot_content_id' => 'NULL',
|
|
'slot_origin' => 'slots.rev_id',
|
|
'role_name' => $db->addQuotes( SlotRecord::MAIN ),
|
|
]
|
|
),
|
|
'joins' => [],
|
|
]
|
|
];
|
|
yield [
|
|
[ 'content' ],
|
|
[
|
|
'tables' => [
|
|
'slots' => 'revision',
|
|
],
|
|
'fields' => array_merge(
|
|
[
|
|
'slot_revision_id' => 'slots.rev_id',
|
|
'slot_content_id' => 'NULL',
|
|
'slot_origin' => 'slots.rev_id',
|
|
'role_name' => $db->addQuotes( SlotRecord::MAIN ),
|
|
'content_size' => 'slots.rev_len',
|
|
'content_sha1' => 'slots.rev_sha1',
|
|
'content_address' =>
|
|
$db->buildConcat( [ $db->addQuotes( 'tt:' ), 'slots.rev_text_id' ] ),
|
|
'model_name' => 'NULL',
|
|
]
|
|
),
|
|
'joins' => [],
|
|
]
|
|
];
|
|
}
|
|
|
|
public function provideNewMutableRevisionFromArray() {
|
|
foreach ( parent::provideNewMutableRevisionFromArray() as $case ) {
|
|
yield $case;
|
|
}
|
|
|
|
yield 'Basic array, with page & id' => [
|
|
[
|
|
'id' => 2,
|
|
'page' => 1,
|
|
'text_id' => 2,
|
|
'timestamp' => '20171017114835',
|
|
'user_text' => '111.0.1.2',
|
|
'user' => 0,
|
|
'minor_edit' => false,
|
|
'deleted' => 0,
|
|
'len' => 46,
|
|
'parent_id' => 1,
|
|
'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
|
|
'comment' => 'Goat Comment!',
|
|
]
|
|
];
|
|
}
|
|
|
|
}
|