# rest_get_combining_operation_error()

URL: https://chugunov.pro/api-wordpress/functions/rest_get_combining_operation_error/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 5.6.0.

## Сигнатура

```php
rest_get_combining_operation_error( array $value, string $param, array $errors ): WP_Error
```

## Описание

Возвращает ошибку операции объединения.

## Параметры

- `$value` `array` — обязательный. Значение для проверки.
- `$param` `string` — обязательный. Имя параметра, используемое в сообщениях об ошибках.
- `$errors` `array` — обязательный. Массив ошибок для поиска возможной ошибки.

## Возвращаемое значение

`WP_Error`

## Исходный код

Файл: `wp-includes/rest-api.php:1877`

```php
function rest_get_combining_operation_error( $value, $param, $errors ) {
	// If there is only one error, simply return it.
	if ( 1 === count( $errors ) ) {
		return rest_format_combining_operation_error( $param, $errors[0] );
	}

	// Filter out all errors related to type validation.
	$filtered_errors = array();
	foreach ( $errors as $error ) {
		$error_code = $error['error_object']->get_error_code();
		$error_data = $error['error_object']->get_error_data();

		if ( 'rest_invalid_type' !== $error_code || ( isset( $error_data['param'] ) && $param !== $error_data['param'] ) ) {
			$filtered_errors[] = $error;
		}
	}

	// If there is only one error left, simply return it.
	if ( 1 === count( $filtered_errors ) ) {
		return rest_format_combining_operation_error( $param, $filtered_errors[0] );
	}

	// If there are only errors related to object validation, try choosing the most appropriate one.
	if ( count( $filtered_errors ) > 1 && 'object' === $filtered_errors[0]['schema']['type'] ) {
		$result = null;
		$number = 0;

		foreach ( $filtered_errors as $error ) {
			if ( isset( $error['schema']['properties'] ) ) {
				$n = count( array_intersect_key( $error['schema']['properties'], $value ) );
				if ( $n > $number ) {
					$result = $error;
					$number = $n;
				}
			}
		}

		if ( null !== $result ) {
			return rest_format_combining_operation_error( $param, $result );
		}
	}

	// If each schema has a title, include those titles in the error message.
	$schema_titles = array();
	foreach ( $errors as $error ) {
		if ( isset( $error['schema']['title'] ) ) {
			$schema_titles[] = $error['schema']['title'];
		}
	}

	if ( count( $schema_titles ) === count( $errors ) ) {
		/* translators: 1: Parameter, 2: Schema titles. */
		return new WP_Error( 'rest_no_matching_schema', wp_sprintf( __( '%1$s is not a valid %2$l.' ), $param, $schema_titles ) );
	}

	/* translators: %s: Parameter. */
	return new WP_Error( 'rest_no_matching_schema', sprintf( __( '%s does not match any of the expected formats.' ), $param ) );
}
```

## История изменений

- 5.6.0 — Introduced.

## Связанные

Использует: [`rest_format_combining_operation_error`](https://chugunov.pro/api-wordpress/functions/rest_format_combining_operation_error/), `WP_Error`, [`wp_sprintf`](https://chugunov.pro/api-wordpress/functions/wp_sprintf/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), `WP_Error::__construct`.
Используется в: [`rest_find_any_matching_schema`](https://chugunov.pro/api-wordpress/functions/rest_find_any_matching_schema/), [`rest_find_one_matching_schema`](https://chugunov.pro/api-wordpress/functions/rest_find_one_matching_schema/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/rest_get_combining_operation_error/
