From 6f6bbbd1a37c89eeb95c87c6a64e8dd0c2fb487d Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Thu, 8 Apr 2021 16:38:17 +0200 Subject: [PATCH] Ensure same data types for all autocompelete list items In client code we expect that botch category and product ids are strings but we send strings for lists based on posts and integers for lists based on terms. We use mostly string values so this change unifies that all ids for autocomplete lists are strings. [MAILPOET-3555] --- lib/WP/AutocompletePostListLoader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/WP/AutocompletePostListLoader.php b/lib/WP/AutocompletePostListLoader.php index d7a79d20fe..645b64cb93 100644 --- a/lib/WP/AutocompletePostListLoader.php +++ b/lib/WP/AutocompletePostListLoader.php @@ -54,7 +54,7 @@ class AutocompletePostListLoader { $result = []; foreach ($posts as $post) { $result[] = [ - 'id' => $post->ID, + 'id' => (string)$post->ID, 'name' => $post->post_title,// phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps ]; } @@ -67,7 +67,7 @@ class AutocompletePostListLoader { $result = []; foreach ($terms as $term) { $result[] = [ - 'id' => $term->term_id,// phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps + 'id' => (string)$term->term_id,// phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps 'name' => $term->name, ]; }