new MWException( "Text already stored in external store (id someid), " .
"can't serialize content object" )
];
- yield 'unknown user id and no user name' => [
- [
- 'content' => new JavaScriptContent( 'hello world.' ),
- 'user' => 9989,
- ],
- new MWException( 'user_text not given, and unknown user ID 9989' )
- ];
yield 'with bad content object (class)' => [
[ 'content' => new stdClass() ],
new MWException( 'content field must contain a Content object.' )
$lb,
$this->getBlobStore(),
$cache,
- MediaWikiServices::getInstance()->getCommentStore()
+ MediaWikiServices::getInstance()->getCommentStore(),
+ MediaWikiServices::getInstance()->getActorMigration()
);
return $blobStore;
}
*/
public function testLoadFromTitle() {
$this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD );
+ $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_OLD );
$this->overrideMwServices();
$title = $this->getMockTitle();
*/
public function testUserJoinCond() {
$this->hideDeprecated( 'Revision::userJoinCond' );
+ $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_OLD );
+ $this->overrideMwServices();
$this->assertEquals(
[ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
Revision::userJoinCond()
);
}
- private function overrideCommentStore() {
+ private function overrideCommentStoreAndActorMigration() {
$mockStore = $this->getMockBuilder( CommentStore::class )
->disableOriginalConstructor()
->getMock();
'fields' => [ 'commentstore' => 'field' ],
'joins' => [ 'commentstore' => 'join' ],
] );
-
$this->setService( 'CommentStore', $mockStore );
+
+ $mockStore = $this->getMockBuilder( ActorMigration::class )
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mockStore->expects( $this->any() )
+ ->method( 'getJoin' )
+ ->willReturnCallback( function ( $key ) {
+ $p = strtok( $key, '_' );
+ return [
+ 'tables' => [ 'actormigration' => 'table' ],
+ 'fields' => [
+ $p . '_user' => 'actormigration_user',
+ $p . '_user_text' => 'actormigration_user_text',
+ $p . '_actor' => 'actormigration_actor',
+ ],
+ 'joins' => [ 'actormigration' => 'join' ],
+ ];
+ } );
+ $this->setService( 'ActorMigration', $mockStore );
}
public function provideSelectFields() {
'rev_timestamp',
'rev_user_text',
'rev_user',
+ 'rev_actor' => 'NULL',
'rev_minor_edit',
'rev_deleted',
'rev_len',
'rev_timestamp',
'rev_user_text',
'rev_user',
+ 'rev_actor' => 'NULL',
'rev_minor_edit',
'rev_deleted',
'rev_len',
public function testSelectFields( $contentHandlerUseDB, $expected ) {
$this->hideDeprecated( 'Revision::selectFields' );
$this->setMwGlobals( 'wgContentHandlerUseDB', $contentHandlerUseDB );
- $this->overrideCommentStore();
+ $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_OLD );
+ $this->overrideCommentStoreAndActorMigration();
$this->assertEquals( $expected, Revision::selectFields() );
}
'ar_id',
'ar_page_id',
'ar_rev_id',
- 'ar_text',
'ar_text_id',
'ar_timestamp',
'ar_user_text',
'ar_user',
+ 'ar_actor' => 'NULL',
'ar_minor_edit',
'ar_deleted',
'ar_len',
'ar_id',
'ar_page_id',
'ar_rev_id',
- 'ar_text',
'ar_text_id',
'ar_timestamp',
'ar_user_text',
'ar_user',
+ 'ar_actor' => 'NULL',
'ar_minor_edit',
'ar_deleted',
'ar_len',
public function testSelectArchiveFields( $contentHandlerUseDB, $expected ) {
$this->hideDeprecated( 'Revision::selectArchiveFields' );
$this->setMwGlobals( 'wgContentHandlerUseDB', $contentHandlerUseDB );
- $this->overrideCommentStore();
+ $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_OLD );
+ $this->overrideCommentStoreAndActorMigration();
$this->assertEquals( $expected, Revision::selectArchiveFields() );
}
'tables' => [
'archive',
'commentstore' => 'table',
+ 'actormigration' => 'table',
],
'fields' => [
'ar_id',
'ar_namespace',
'ar_title',
'ar_rev_id',
- 'ar_text',
'ar_text_id',
'ar_timestamp',
- 'ar_user_text',
- 'ar_user',
'ar_minor_edit',
'ar_deleted',
'ar_len',
'ar_parent_id',
'ar_sha1',
- 'commentstore' => 'field'
+ 'commentstore' => 'field',
+ 'ar_user' => 'actormigration_user',
+ 'ar_user_text' => 'actormigration_user_text',
+ 'ar_actor' => 'actormigration_actor',
],
- 'joins' => [ 'commentstore' => 'join' ],
+ 'joins' => [ 'commentstore' => 'join', 'actormigration' => 'join' ],
]
];
yield 'wgContentHandlerUseDB true' => [
'tables' => [
'archive',
'commentstore' => 'table',
+ 'actormigration' => 'table',
],
'fields' => [
'ar_id',
'ar_namespace',
'ar_title',
'ar_rev_id',
- 'ar_text',
'ar_text_id',
'ar_timestamp',
- 'ar_user_text',
- 'ar_user',
'ar_minor_edit',
'ar_deleted',
'ar_len',
'ar_parent_id',
'ar_sha1',
'commentstore' => 'field',
+ 'ar_user' => 'actormigration_user',
+ 'ar_user_text' => 'actormigration_user_text',
+ 'ar_actor' => 'actormigration_actor',
'ar_content_format',
'ar_content_model',
],
- 'joins' => [ 'commentstore' => 'join' ],
+ 'joins' => [ 'commentstore' => 'join', 'actormigration' => 'join' ],
]
];
}
*/
public function testGetArchiveQueryInfo( $globals, $expected ) {
$this->setMwGlobals( $globals );
- $this->overrideCommentStore();
+ $this->overrideCommentStoreAndActorMigration();
$revisionStore = $this->getRevisionStore();
$revisionStore->setContentHandlerUseDB( $globals['wgContentHandlerUseDB'] );
],
[],
[
- 'tables' => [ 'revision', 'commentstore' => 'table' ],
+ 'tables' => [ 'revision', 'commentstore' => 'table', 'actormigration' => 'table' ],
'fields' => [
'rev_id',
'rev_page',
'rev_text_id',
'rev_timestamp',
- 'rev_user_text',
- 'rev_user',
'rev_minor_edit',
'rev_deleted',
'rev_len',
'rev_parent_id',
'rev_sha1',
'commentstore' => 'field',
+ 'rev_user' => 'actormigration_user',
+ 'rev_user_text' => 'actormigration_user_text',
+ 'rev_actor' => 'actormigration_actor',
],
- 'joins' => [ 'commentstore' => 'join' ],
+ 'joins' => [ 'commentstore' => 'join', 'actormigration' => 'join' ],
],
];
yield 'wgContentHandlerUseDB false, opts page' => [
],
[ 'page' ],
[
- 'tables' => [ 'revision', 'commentstore' => 'table', 'page' ],
+ 'tables' => [ 'revision', 'commentstore' => 'table', 'actormigration' => 'table', 'page' ],
'fields' => [
'rev_id',
'rev_page',
'rev_text_id',
'rev_timestamp',
- 'rev_user_text',
- 'rev_user',
'rev_minor_edit',
'rev_deleted',
'rev_len',
'rev_parent_id',
'rev_sha1',
'commentstore' => 'field',
+ 'rev_user' => 'actormigration_user',
+ 'rev_user_text' => 'actormigration_user_text',
+ 'rev_actor' => 'actormigration_actor',
'page_namespace',
'page_title',
'page_id',
[ 'page_id = rev_page' ],
],
'commentstore' => 'join',
+ 'actormigration' => 'join',
],
],
];
],
[ 'user' ],
[
- 'tables' => [ 'revision', 'commentstore' => 'table', 'user' ],
+ 'tables' => [ 'revision', 'commentstore' => 'table', 'actormigration' => 'table', 'user' ],
'fields' => [
'rev_id',
'rev_page',
'rev_text_id',
'rev_timestamp',
- 'rev_user_text',
- 'rev_user',
'rev_minor_edit',
'rev_deleted',
'rev_len',
'rev_parent_id',
'rev_sha1',
'commentstore' => 'field',
+ 'rev_user' => 'actormigration_user',
+ 'rev_user_text' => 'actormigration_user_text',
+ 'rev_actor' => 'actormigration_actor',
'user_name',
],
'joins' => [
'user' => [
'LEFT JOIN',
[
- 'rev_user != 0',
- 'user_id = rev_user',
+ 'actormigration_user != 0',
+ 'user_id = actormigration_user',
],
],
'commentstore' => 'join',
+ 'actormigration' => 'join',
],
],
];
],
[ 'text' ],
[
- 'tables' => [ 'revision', 'commentstore' => 'table', 'text' ],
+ 'tables' => [ 'revision', 'commentstore' => 'table', 'actormigration' => 'table', 'text' ],
'fields' => [
'rev_id',
'rev_page',
'rev_text_id',
'rev_timestamp',
- 'rev_user_text',
- 'rev_user',
'rev_minor_edit',
'rev_deleted',
'rev_len',
'rev_parent_id',
'rev_sha1',
'commentstore' => 'field',
+ 'rev_user' => 'actormigration_user',
+ 'rev_user_text' => 'actormigration_user_text',
+ 'rev_actor' => 'actormigration_actor',
'old_text',
'old_flags',
],
[ 'rev_text_id=old_id' ],
],
'commentstore' => 'join',
+ 'actormigration' => 'join',
],
],
];
],
[ 'text', 'page', 'user' ],
[
- 'tables' => [ 'revision', 'commentstore' => 'table', 'page', 'user', 'text' ],
+ 'tables' => [
+ 'revision', 'commentstore' => 'table', 'actormigration' => 'table', 'page', 'user', 'text'
+ ],
'fields' => [
'rev_id',
'rev_page',
'rev_text_id',
'rev_timestamp',
- 'rev_user_text',
- 'rev_user',
'rev_minor_edit',
'rev_deleted',
'rev_len',
'rev_parent_id',
'rev_sha1',
'commentstore' => 'field',
+ 'rev_user' => 'actormigration_user',
+ 'rev_user_text' => 'actormigration_user_text',
+ 'rev_actor' => 'actormigration_actor',
'page_namespace',
'page_title',
'page_id',
'user' => [
'LEFT JOIN',
[
- 'rev_user != 0',
- 'user_id = rev_user',
+ 'actormigration_user != 0',
+ 'user_id = actormigration_user',
],
],
'text' => [
[ 'rev_text_id=old_id' ],
],
'commentstore' => 'join',
+ 'actormigration' => 'join',
],
],
];
],
[],
[
- 'tables' => [ 'revision', 'commentstore' => 'table' ],
+ 'tables' => [ 'revision', 'commentstore' => 'table', 'actormigration' => 'table' ],
'fields' => [
'rev_id',
'rev_page',
'rev_text_id',
'rev_timestamp',
- 'rev_user_text',
- 'rev_user',
'rev_minor_edit',
'rev_deleted',
'rev_len',
'rev_parent_id',
'rev_sha1',
'commentstore' => 'field',
+ 'rev_user' => 'actormigration_user',
+ 'rev_user_text' => 'actormigration_user_text',
+ 'rev_actor' => 'actormigration_actor',
'rev_content_format',
'rev_content_model',
],
- 'joins' => [ 'commentstore' => 'join' ],
+ 'joins' => [ 'commentstore' => 'join', 'actormigration' => 'join' ],
],
];
}
*/
public function testGetQueryInfo( $globals, $options, $expected ) {
$this->setMwGlobals( $globals );
- $this->overrideCommentStore();
+ $this->overrideCommentStoreAndActorMigration();
$revisionStore = $this->getRevisionStore();
$revisionStore->setContentHandlerUseDB( $globals['wgContentHandlerUseDB'] );