Improve return types in class MagicWordArray
[lhc/web/wiklou.git] / tests / phpunit / includes / Revision / McrSchemaDetection.php
1 <?php
2 namespace MediaWiki\Tests\Revision;
3
4 use Wikimedia\Rdbms\IDatabase;
5
6 /**
7 * Trait providing methods for detecting which MCR schema migration phase the current schema
8 * is compatible with.
9 */
10 trait McrSchemaDetection {
11
12 /**
13 * Returns true if MCR-related tables exist in the database.
14 * If yes, the database is compatible with with MIGRATION_NEW.
15 * If hasPreMcrFields() also returns true, the database supports MIGRATION_WRITE_BOTH mode.
16 *
17 * @param IDatabase $db
18 * @return bool
19 */
20 protected function hasMcrTables( IDatabase $db ) {
21 return $db->tableExists( 'slots', __METHOD__ );
22 }
23
24 /**
25 * Returns true if pre-MCR fields still exist in the database.
26 * If yes, the database is compatible with with MIGRATION_OLD mode.
27 * If hasMcrTables() also returns true, the database supports MIGRATION_WRITE_BOTH mode.
28 *
29 * Note that if the database has been updated in MIGRATION_NEW mode,
30 * the rev_text_id field will be 0 for new revisions. This means that
31 * in MIGRATION_OLD mode, reading such revisions will fail, even though
32 * all the necessary fields exist.
33 * This is not relevant for unit tests, since unit tests reset the database content anyway.
34 *
35 * @param IDatabase $db
36 * @return bool
37 */
38 protected function hasPreMcrFields( IDatabase $db ) {
39 return $db->fieldExists( 'revision', 'rev_content_model', __METHOD__ );
40 }
41
42 }