16 private const TRACKED_VERBS = [
'INSERT',
'UPDATE',
'REPLACE' ];
17 private static bool $trackingEnabled =
false;
19 private static array $tableMap = [];
25 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
26 throw new RuntimeException(
"This class is internal and should only be used in tests." );
28 if ( self::$trackingEnabled ) {
29 throw new RuntimeException(
"Tracking is already enabled" );
31 self::$trackingEnabled =
true;
41 public static function getTables(
string $domainId ): array {
42 $tableMap = self::$tableMap[$domainId] ?? [];
43 return array_keys( $tableMap );
50 if ( !self::$trackingEnabled ) {
51 throw new RuntimeException(
"Tracking is not enabled" );
54 self::$trackingEnabled =
false;
62 if ( !self::$trackingEnabled ) {
65 if ( !$query->isWriteQuery() ) {
68 $domainId = $domain->getId();
69 $queryVerb = $query->getVerb();
70 $tableName = $query->getWriteTable();
71 if ( $tableName ===
null ) {
74 if ( $queryVerb ===
'DROP' ) {
76 unset( self::$tableMap[$domainId][$tableName] );
79 if ( !in_array( $queryVerb, self::TRACKED_VERBS,
true ) ) {
83 self::$tableMap[$domainId][$tableName] =
true;
if(!defined('MW_SETUP_CALLBACK'))
Class to handle database/schema/prefix specifications for IDatabase.