Automattic\WooCommerce\Database\Migrations

MetaToCustomTableMigrator::processs_and_sanitize_meta_data()privateWC 1.0

Helper method to sanitize soure meta data.

Method of the class: MetaToCustomTableMigrator{}

No Hooks.

Return

null. Nothing.

Usage

// private - for code of main (parent) class only
$result = $this->processs_and_sanitize_meta_data( $sanitized_entity_data, $error_records, $meta_data ): void;
$sanitized_entity_data(array) (required)
Array containing sanitized data for insertion.
$error_records(array) (required)
Error records.
$meta_data(array) (required)
Original source data.

MetaToCustomTableMigrator::processs_and_sanitize_meta_data() code WC 7.1.1

private function processs_and_sanitize_meta_data( array &$sanitized_entity_data, array &$error_records, array $meta_data ): void {
	foreach ( $meta_data as $datum ) {
		$column_schema = $this->meta_column_mapping[ $datum->meta_key ];
		$value         = $this->validate_data( $datum->meta_value, $column_schema['type'] );
		if ( is_wp_error( $value ) ) {
			$error_records[ $datum->entity_id ][ $column_schema['destination'] ] = "{$value->get_error_code()}: {$value->get_error_message()}";
		} else {
			$sanitized_entity_data[ $datum->entity_id ][ $column_schema['destination'] ] = $value;
		}
	}
}