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
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
namespace MediaWiki\Tests\Revision;
|
|
|
|
use Wikimedia\Rdbms\IDatabase;
|
|
|
|
/**
|
|
* Trait providing methods for detecting which MCR schema migration phase the current schema
|
|
* is compatible with.
|
|
*/
|
|
trait McrSchemaDetection {
|
|
|
|
/**
|
|
* Returns true if MCR-related tables exist in the database.
|
|
* If yes, the database is compatible with with MIGRATION_NEW.
|
|
* If hasPreMcrFields() also returns true, the database supports MIGRATION_WRITE_BOTH mode.
|
|
*
|
|
* @param IDatabase $db
|
|
* @return bool
|
|
*/
|
|
protected function hasMcrTables( IDatabase $db ) {
|
|
return $db->tableExists( 'slots', __METHOD__ );
|
|
}
|
|
|
|
/**
|
|
* Returns true if pre-MCR fields still exist in the database.
|
|
* If yes, the database is compatible with with MIGRATION_OLD mode.
|
|
* If hasMcrTables() also returns true, the database supports MIGRATION_WRITE_BOTH mode.
|
|
*
|
|
* Note that if the database has been updated in MIGRATION_NEW mode,
|
|
* the rev_text_id field will be 0 for new revisions. This means that
|
|
* in MIGRATION_OLD mode, reading such revisions will fail, even though
|
|
* all the necessary fields exist.
|
|
* This is not relevant for unit tests, since unit tests reset the database content anyway.
|
|
*
|
|
* @param IDatabase $db
|
|
* @return bool
|
|
*/
|
|
protected function hasPreMcrFields( IDatabase $db ) {
|
|
return $db->fieldExists( 'revision', 'rev_content_model', __METHOD__ );
|
|
}
|
|
|
|
}
|