[wp-trac] [WordPress Trac] #54914: Deprecation warning for PHP 8.1 setcookie
WordPress Trac
noreply at wordpress.org
Sun Jun 12 11:09:35 UTC 2022
#54914: Deprecation warning for PHP 8.1 setcookie
--------------------------------+-----------------------------
Reporter: shenyanzhi | Owner: SergeyBiryukov
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.1
Component: Options, Meta APIs | Version: 4.0
Severity: normal | Resolution: fixed
Keywords: php81 has-patch | Focuses:
--------------------------------+-----------------------------
Changes (by SergeyBiryukov):
* owner: (none) => SergeyBiryukov
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"53490" 53490]:
{{{
#!CommitTicketReference repository="" revision="53490"
Code Modernization: Pass correct default value to `setcookie()` in
`wp_user_settings()`.
The `wp_user_settings()` function calls the PHP native `setcookie()`
function, the fifth parameter of which is the ''optional'' `$domain`
parameter which expects a `string`.
A parameter being optional, however, does not automatically make it
nullable.
As of PHP 8.1, passing `null` to a non-nullable PHP native function will
generate a deprecation notice.
In this case, this function call yielded a `setcookie(): Passing null to
parameter #5 ($domain) of type string is deprecated` notice.
Changing the `null` to an empty string fixes this without a backward
compatibility break.
References:
* [https://www.php.net/manual/en/function.setcookie.php PHP Manual:
setcookie()]
* [https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg PHP RFC:
Deprecate passing null to non-nullable arguments of internal functions]
Follow-up to [29478].
Props ocean90, shenyanzhi, meysamnorouzi, jrf.
Fixes #54914.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54914#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list