Skip to content
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

Script Modules: Fix private method reflection access #62154

Merged
merged 2 commits into from
May 30, 2024

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented May 30, 2024

What?

Set private methods accessed through reflection to accessible before invoking.

Why?

This cases an error in some PHP versions: https://github.com/WordPress/gutenberg/pull/61658/files#r1621194664

PHP Fatal error: Uncaught ReflectionException: Trying to invoke private method WP_Script_Modules::get_marked_for_enqueue() from scope ReflectionMethod in /wordpress/wp-content/plugins/gutenberg/lib/experimental/script-modules.php:218

How?

Setting the methods to accessible fixes the issue.

Testing Instructions

Go to the playground:

https://playground.wordpress.net/gutenberg.html

Put this PR number in the form: 62154

Change the playground PHP version to 7.2.
Try using the Interactivity API on the playground site. You can check the error logs on the site to ensure there are no errors related to private method access.

Copy link

github-actions bot commented May 30, 2024

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: sirreal <jonsurrell@git.wordpress.org>
Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org>

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

Copy link

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/experimental/script-modules.php
@sirreal sirreal added the [Type] Bug An existing feature does not function as intended label May 30, 2024
Copy link
Contributor

@cbravobernal cbravobernal left a comment

Choose a reason for hiding this comment

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

LGTM

@cbravobernal cbravobernal enabled auto-merge (squash) May 30, 2024 19:30
@cbravobernal cbravobernal merged commit 5132888 into trunk May 30, 2024
68 of 70 checks passed
@cbravobernal cbravobernal deleted the fix/script-modules-data-php72-reflection-access branch May 30, 2024 19:33
@github-actions github-actions bot added this to the Gutenberg 18.5 milestone May 30, 2024
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Jun 4, 2024
* Set private reflection methods to accessible

* Set private reflection methods to accessible
patil-vipul pushed a commit to patil-vipul/gutenberg that referenced this pull request Jun 17, 2024
* Set private reflection methods to accessible

* Set private reflection methods to accessible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
2 participants