This commit is contained in:
Javier Casares 2026-06-03 06:25:27 +00:00
commit 650e69349f
21 changed files with 2919 additions and 268 deletions

View file

@ -172,4 +172,21 @@ class AttachmentIndexer {
Scheduler::schedule_single( self::AS_HOOK );
}
}
/**
* Deletes all rows from mra_media_index and mra_media_usage, forcing a full re-index on the next run.
*
* @return int Number of index rows removed.
*/
public static function reset_all(): int {
global $wpdb;
// phpcs:disable WordPress.DB.DirectDatabaseQuery
$count = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}mra_media_index" );
$wpdb->query( "DELETE FROM {$wpdb->prefix}mra_media_usage" );
$wpdb->query( "DELETE FROM {$wpdb->prefix}mra_media_index" );
// phpcs:enable WordPress.DB.DirectDatabaseQuery
return $count;
}
}