Skip to content

Conversation

@pento
Copy link
Member

@pento pento commented Oct 4, 2017

No description provided.

@pento pento closed this Oct 4, 2017
pento pushed a commit that referenced this pull request Jun 12, 2022
…p_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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53490 602fd350-edb4-49c9-b593-d223f7449a82
azaozz pushed a commit to azaozz/wordpress-develop that referenced this pull request Feb 2, 2024
BesrourMS added a commit to BesrourMS/wordpress-develop that referenced this pull request Aug 6, 2024
This commit addresses a fatal TypeError occurring in widgets.php when merging sidebar widgets. The error was caused by null values being passed to array_merge(), which expects only arrays.
Changes made:

Replace the problematic array_merge() call with a more robust loop
Add explicit checks for array type before merging
Implement array_unique() to remove potential duplicates

This fix prevents the "Uncaught TypeError: array_merge(): Argument WordPress#5 must be of type array, null given" error, improving stability when handling widget data, especially during theme switching or widget updates.
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.

1 participant