REST API: Allow for string ids in the search controller.
Previously, the search controller infrastructure required that the id property was an integer. This prevents data models that use a string id from utilizing the search infrastructure. This commit lifts the restraint that search handlers return integer ids. This will allow for the Post Formats search handler coming in 5.6 to use slugs instead of creating fake ids. Props stoyangeorgiev. Fixes #51131. git-svn-id: https://develop.svn.wordpress.org/trunk@49088 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
540b331096
commit
a3eb0d803e
@ -140,7 +140,7 @@ class WP_REST_Search_Controller extends WP_REST_Controller {
|
||||
);
|
||||
}
|
||||
|
||||
$ids = array_map( 'absint', $result[ WP_REST_Search_Handler::RESULT_IDS ] );
|
||||
$ids = $result[ WP_REST_Search_Handler::RESULT_IDS ];
|
||||
|
||||
$results = array();
|
||||
|
||||
@ -186,7 +186,7 @@ class WP_REST_Search_Controller extends WP_REST_Controller {
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param int $id ID of the item to prepare.
|
||||
* @param int|string $id ID of the item to prepare.
|
||||
* @param WP_REST_Request $request Request object.
|
||||
* @return WP_REST_Response Response object.
|
||||
*/
|
||||
@ -245,7 +245,7 @@ class WP_REST_Search_Controller extends WP_REST_Controller {
|
||||
'properties' => array(
|
||||
self::PROP_ID => array(
|
||||
'description' => __( 'Unique identifier for the object.' ),
|
||||
'type' => 'integer',
|
||||
'type' => array( 'integer', 'string' ),
|
||||
'context' => array( 'view', 'embed' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
|
@ -79,7 +79,7 @@ abstract class WP_REST_Search_Handler {
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param int $id Item ID.
|
||||
* @param int|string $id Item ID.
|
||||
* @param array $fields Fields to include for the item.
|
||||
* @return array Associative array containing all fields for the item.
|
||||
*/
|
||||
@ -90,7 +90,7 @@ abstract class WP_REST_Search_Handler {
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param int $id Item ID.
|
||||
* @param int|string $id Item ID.
|
||||
* @return array Links for the given item.
|
||||
*/
|
||||
abstract public function prepare_item_links( $id );
|
||||
|
Loading…
Reference in New Issue
Block a user