Skip to content

Cache redundant function call for is_user_logged_in() function #70999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

dhananjaykuber
Copy link
Contributor

Closes #70998

What?

Optimizes Form Input and LoginOut blocks by caching is_user_logged_in() function.

Why?

Currently, both blocks make repeated function calls that don't change during a single request:

How?

Saved result of is_user_logged_in() in variable

Copy link

github-actions bot commented Jul 31, 2025

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: dhananjaykuber <[email protected]>
Co-authored-by: Mamaduka <[email protected]>

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

@Mamaduka Mamaduka added [Type] Code Quality Issues or PRs that relate to code quality [Block] Login/out Affects the Login/out Block labels Aug 1, 2025
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @dhananjaykuber!

A nice code quality improvement, though it's hard to check a performance impact for similar changes.

@Mamaduka Mamaduka added the props-bot Adding this label triggers the Props Bot workflow for a PR. label Aug 1, 2025
@github-actions github-actions bot removed the props-bot Adding this label triggers the Props Bot workflow for a PR. label Aug 1, 2025
@Mamaduka Mamaduka merged commit 7023c51 into WordPress:trunk Aug 1, 2025
69 of 71 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.4 milestone Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Login/out Affects the Login/out Block [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache function calls in Form Input and LoginOut blocks
2 participants