*/ private static function steps(): array { return array( '1.0.3' => array( self::class, 'to_1_0_3' ), ); } /** * 1.0.3: remove prices of vehicles that no longer exist (deleted outside wp-admin), so a new vehicle that * gets the same post ID never inherits them. * * @return void */ public static function to_1_0_3(): void { global $wpdb; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time data clean-up. $wpdb->query( $wpdb->prepare( 'DELETE r FROM %i r LEFT JOIN %i p ON p.ID = r.vehicle_id WHERE p.ID IS NULL', Schema::table( 'rates' ), $wpdb->posts ) ); Repository::bump_data_version(); } /** * Run every step newer than $from. * * @param string $from Installed schema version ('' on a fresh install). * @return void */ public static function run( string $from ): void { if ( '' === $from ) { return; } foreach ( self::steps() as $version => $callback ) { if ( version_compare( $from, $version, '<' ) ) { call_user_func( $callback ); } } } }