Repository navigation
Code Modernization: Use the null coalescing assignment operator in wp-includes/update.php - #16051
noruzzamans wants to merge 1 commit into
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the version-normalization cleanup in plugin and theme update checks.
No open issues 🎉
What changed in this PR
Modernizes version normalization in WordPress’s plugin and theme update checks as part of Trac #65823, without changing behavior.
Changes:
- Replaces two
! isset()assignment guards with??=inwp_update_plugins()andwp_update_themes(). - Preserves the fallback from
versionwhennew_versionis unset or null.
| File | Description |
|---|---|
src/wp-includes/update.php |
Simplifies default version assignments in both update functions. |
Review effort: Balanced
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Part of Core Trac Ticket #65823.
Replaces verbose
! isset()guard blocks that assign default values with the null coalescing assignment operator (??=) insrc/wp-includes/update.php.Scope
This covers
wp_update_plugins()andwp_update_themes()completely insrc/wp-includes/update.php:wp_update_plugins(): Sets default$update->new_versionfrom$update->version.wp_update_themes(): Sets default$update->new_versionfrom$update->version.Both update functions normalize version information using the same idiom, so the two functions read consistently. 2 guard blocks replaced (-6 lines, +2 lines).
Why this is safe
??=requires PHP 7.4, which is already the minimum supported version for WordPress.??=and! isset()evaluate the exact same condition, applying the default only when the property is not already set.Follow-up to [r65529], [r65530], and [r65535].
Trac ticket: https://core.trac.wordpress.org/ticket/65823