Skip to content

Code Modernization: Use the null coalescing operator in wp_get_chromium_major_version() tests - #13469

Open
Soean wants to merge 1 commit into
WordPress:trunkfrom
Soean:code-modernization/null-coalescing-operator
Open

Code Modernization: Use the null coalescing operator in wp_get_chromium_major_version() tests#13469
Soean wants to merge 1 commit into
WordPress:trunkfrom
Soean:code-modernization/null-coalescing-operator

Conversation

@Soean

@Soean Soean commented Sep 10, 2026

Copy link
Copy Markdown
Member

Tests_Media_wpGetChromiumMajorVersion::set_up() stores the original $_SERVER['HTTP_USER_AGENT'] value using an isset() ternary that repeats the array access. This replaces it with the null coalescing operator, which is shorter and expresses the same intent.

The null coalescing operator is available since PHP 7.0, and WordPress requires PHP 7.4 or later, so no compatibility concerns apply. It is already used widely across the codebase, so this makes the style more consistent.

Follow-up to 62428.

Trac ticket: https://core.trac.wordpress.org/ticket/65819


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

…ium_major_version()` tests.

Replaces an `isset()` ternary with the null coalescing operator when reading `$_SERVER['HTTP_USER_AGENT']`. The operator is available since PHP 7.0 and WordPress requires PHP 7.4 or later.
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props soean.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

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.

2 participants