Make WordPress Core

Changeset 62497


Ignore:
Timestamp:
06/12/2026 11:42:27 PM (7 hours ago)
Author:
SergeyBiryukov
Message:

Docs: Correct the DocBlock for build_query().

This updates the @param and @return descriptions to state that build_query() does not URL-encode, unlike PHP's native http_build_query(), and that callers are responsible for encoding the values beforehand or late-escaping the output with esc_url().

Follow-up to [8215].

Props nimeshatxecurify, johnbillion.
Fixes #65453.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r62421 r62497  
    10321032 * It sets the separator to '&' and uses the _http_build_query() function.
    10331033 *
     1034 * Unlike PHP's native http_build_query(), this function does NOT URL-encode
     1035 * the keys or values. Callers are responsible for encoding values beforehand
     1036 * with urlencode() or rawurlencode(), or late-escaping the output with
     1037 * esc_url() before use.
     1038 *
    10341039 * @since 2.3.0
    10351040 *
    1036  * @see _http_build_query() Used to build the query
     1041 * @see _http_build_query() Used to build the query.
    10371042 * @link https://www.php.net/manual/en/function.http-build-query.php for more on what
    10381043 *       http_build_query() does.
    10391044 *
    1040  * @param array $data URL-encode key/value pairs.
    1041  * @return string URL-encoded string.
     1045 * @param array $data Array of key/value pairs to build the query from.
     1046 * @return string Query string, without URL encoding applied.
    10421047 */
    10431048function build_query( $data ) {
Note: See TracChangeset for help on using the changeset viewer.