Skip to content

Page List: Use null coalescing operator for parentPageID attribute - #80728

Merged
Soean merged 1 commit into
trunkfrom
page-list/null-coalescing
Jul 27, 2026
Merged

Page List: Use null coalescing operator for parentPageID attribute#80728
Soean merged 1 commit into
trunkfrom
page-list/null-coalescing

Conversation

@Soean

@Soean Soean commented Jul 27, 2026

Copy link
Copy Markdown
Member

What?

Simplifies reading the parentPageID attribute in the Page List block's by replacing the ternary isset() check
with the null coalescing operator (??).

Why?

The isset( $x ) ? $x : null pattern is exactly what the ?? operator was introduced for. Using it makes the intent clearer and the line shorter, without changing behavior. This is a code quality / readability improvement only.

Follow-up to #80558

@Soean Soean added [Type] Code Quality Issues or PRs that relate to code quality [Block] Page List Affects the Page List Block labels Jul 27, 2026
@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Jul 27, 2026
@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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Soean <soean@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

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

@Soean
Soean merged commit 7908c1d into trunk Jul 27, 2026
53 of 54 checks passed
@Soean
Soean deleted the page-list/null-coalescing branch July 27, 2026 09:19
@github-actions github-actions Bot added this to the Gutenberg 23.7 milestone Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Page List Affects the Page List Block [Package] Block library /packages/block-library [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants