<?php
/**
 * File Path: includes/migrations/class-mbs-migration-4-36.php
 *
 * Migration 4.36 -- Sprint RO-Display: hero term_meta cleanup.
 *
 * Deletes any mbs_term_layout term_meta rows that store the value 'hero'.
 * Hero is not a valid archive layout (excluded via MBS_Layout_Registry::
 * get_archive_layout_options() since Sprint RO-Display Group 2). Stale 'hero'
 * rows stored before the restriction was added are replaced by the global
 * default on the next archive page load; this migration removes them
 * permanently so the fallback is no longer needed.
 *
 * Idempotent no-op if no 'hero' rows are present.
 *
 * @package MyBookShowroom
 * @since   4.36.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class MBS_Migration_4_36 implements MBS_Migration { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- mbs_/MBS_ prefix is correct; scanner not configured with plugin prefix

	/**
	 * Returns the migration version string.
	 *
	 * @return string
	 */
	public function version(): string { return '4.36'; }

	/**
	 * Run the migration.
	 *
	 * @return void
	 */
	public function up(): void {
		global $wpdb;

		// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
		$wpdb->delete( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery -- DAO layer -- direct DB access is intentional per MBS architecture
			$wpdb->termmeta,
			array(
				'meta_key'   => 'mbs_term_layout', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- standard WP query pattern; VIP rule does not apply to this plugin
				'meta_value' => 'hero', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- standard WP query pattern; VIP rule does not apply to this plugin
			),
			array( '%s', '%s' )
		);
	}
}
