Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the output of put-mapping errors #3464

Merged
merged 2 commits into from
May 18, 2023
Merged

Conversation

felipeelia
Copy link
Member

Description of the Change

Currently, if the put-mapping operation returns an error, the message returned says Mapping failed: Array. This PR fixes that introducing a general function that gets an Elasticsearch response and returns the error reason in it (if any.)

How to test the Change

Add the following snippet to your codebase and run wp elasticpress sync --setup, wp elasticpress put-mapping, or sync via the UI:

add_filter(
	'ep_post_mapping',
	function ( $mapping ) {
		$mapping['mappings']['properties']['post_title']['index_options'] = 'something_wrong';
		return $mapping;
	}
);

Changelog Entry

Fixed - Display the error message returned by Elasticsearch if a mapping operation fails.

Credits

Props @felipeelia

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@felipeelia felipeelia added this to the 4.6.0 milestone May 18, 2023
@felipeelia felipeelia self-assigned this May 18, 2023
Co-authored-by: Mohammed <MARQAS@users.noreply.github.com>
@felipeelia felipeelia merged commit 3f95e78 into develop May 18, 2023
@felipeelia felipeelia deleted the fix/mapping-error-output branch May 18, 2023 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants