Automattic\WooCommerce\Database\Migrations

MetaToCustomTableMigrator::verify_meta_columns()privateWC 1.0

Helper method to verify meta columns.

{} Это метод класса: MetaToCustomTableMigrator{}

Хуков нет.

Возвращает

Массив. Array of failed IDs if any, along with columns/meta_key names.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->verify_meta_columns( $row, $failed_ids );
$row(массив) (обязательный)
Both migrated and source data for a single row.
$failed_ids(массив) (обязательный)
Array of failed IDs.

Код MetaToCustomTableMigrator::verify_meta_columns() WC 6.7.0

private function verify_meta_columns( $row, $failed_ids ) {
	$primary_key_column = "{$this->schema_config['source']['entity']['table_name']}_{$this->schema_config['source']['entity']['primary_key']}";
	foreach ( $this->meta_column_mapping as $meta_key => $schema ) {
		$meta_alias        = "meta_source_{$schema['destination']}";
		$destination_alias = "{$this->schema_config['destination']['table_name']}_{$schema['destination']}";
		$row               = $this->pre_process_row( $row, $schema, $meta_alias, $destination_alias );
		if ( $row[ $meta_alias ] !== $row[ $destination_alias ] ) {
			if ( ! isset( $failed_ids[ $row[ $primary_key_column ] ] ) ) {
				$failed_ids[ $row[ $primary_key_column ] ] = array();
			}
			$failed_ids[ $row[ $primary_key_column ] ][] = array(
				'column'         => $meta_key,
				'original_value' => $row[ $meta_alias ],
				'new_value'      => $row[ $destination_alias ],
			);
		}
	}

	return $failed_ids;
}