This commit is contained in:
Javier Casares 2026-06-08 18:01:39 +00:00
commit b6a55a7f04
27 changed files with 2221 additions and 45 deletions

View file

@ -11,6 +11,8 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use MediaRightsAudit\Core\NetworkDatabase;
/**
* Manages all custom table creation and schema migrations.
*
@ -29,6 +31,7 @@ class Database {
self::migration_101();
self::migration_110();
self::migration_120();
self::migration_130();
}
/**
@ -57,6 +60,10 @@ class Database {
if ( version_compare( $current, '1.2.0', '<' ) ) {
self::migration_120();
}
if ( version_compare( $current, '1.3.0', '<' ) ) {
self::migration_130();
}
}
/**
@ -92,6 +99,10 @@ class Database {
// phpcs:enable WordPress.DB.DirectDatabaseQuery
delete_transient( 'mra_alert_count' );
if ( is_multisite() && 'central' === get_site_option( 'robotstxt_mediaaudit_network_mode', 'per_site' ) ) {
NetworkDatabase::clear_site( get_current_blog_id() );
}
}
// -------------------------------------------------------------------------
@ -256,4 +267,23 @@ class Database {
) {$charset_collate};"
);
}
/**
* Migration 1.3.0 creates the network mirror table (Multisite central mode only).
*
* For single-site installs this is a no-op. The network table lives in the
* main site's DB and is managed by NetworkDatabase::create_network_table().
* This migration entry exists only to advance the per-site DB version constant.
*
* @return void
*/
private static function migration_130(): void {
if ( ! is_multisite() ) {
return;
}
if ( 'central' === get_site_option( 'robotstxt_mediaaudit_network_mode', 'per_site' ) ) {
NetworkDatabase::create_network_table();
}
}
}