Automattic\WooCommerce\Database\Migrations
MetaToMetaTableMigrator::get_already_migrated_records()
Helper method to get already migrated records. Will be used to find prevent migration of already migrated records.
Метод класса: MetaToMetaTableMigrator{}
Хуков нет.
Возвращает
Массив
. Already migrated records.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_already_migrated_records( $entity_ids ): array;
- $entity_ids(массив) (обязательный)
- List of entity ids to check for.
Код MetaToMetaTableMigrator::get_already_migrated_records() MetaToMetaTableMigrator::get already migrated records WC 9.2.3
private function get_already_migrated_records( array $entity_ids ): array { global $wpdb; $destination_table_name = $this->schema_config['destination']['meta']['table_name']; $destination_id_column = $this->schema_config['destination']['meta']['meta_id_column']; $destination_entity_id_column = $this->schema_config['destination']['meta']['entity_id_column']; $destination_meta_key_column = $this->schema_config['destination']['meta']['meta_key_column']; $destination_meta_value_column = $this->schema_config['destination']['meta']['meta_value_column']; $entity_id_type_placeholder = MigrationHelper::get_wpdb_placeholder_for_type( $this->schema_config['destination']['meta']['entity_id_type'] ); $entity_ids_placeholder = implode( ',', array_fill( 0, count( $entity_ids ), $entity_id_type_placeholder ) ); // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare $data_already_migrated = $this->db_get_results( $wpdb->prepare( " SELECT $destination_id_column meta_id, $destination_entity_id_column entity_id, $destination_meta_key_column meta_key, $destination_meta_value_column meta_value FROM $destination_table_name destination WHERE destination.$destination_entity_id_column in ( $entity_ids_placeholder ) ORDER BY destination.$destination_entity_id_column ", $entity_ids ) ); // phpcs:enable $already_migrated = array(); foreach ( $data_already_migrated as $migrate_row ) { if ( ! isset( $already_migrated[ $migrate_row->entity_id ] ) ) { $already_migrated[ $migrate_row->entity_id ] = array(); } // phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_key, WordPress.DB.SlowDBQuery.slow_db_query_meta_value if ( ! isset( $already_migrated[ $migrate_row->entity_id ][ $migrate_row->meta_key ] ) ) { $already_migrated[ $migrate_row->entity_id ][ $migrate_row->meta_key ] = array(); } $already_migrated[ $migrate_row->entity_id ][ $migrate_row->meta_key ][] = array( 'id' => $migrate_row->meta_id, 'meta_value' => $migrate_row->meta_value, ); // phpcs:enable } return $already_migrated; }