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

Fix fatal error introduced in #449 #453

Merged
merged 9 commits into from Apr 9, 2024
Merged

Fix fatal error introduced in #449 #453

merged 9 commits into from Apr 9, 2024

Conversation

swissspidy
Copy link
Member

Introduced in #449

Reported in WordPress/plugin-check-action#68

To reproduce:

wp plugin check akismet --require=./wp-content/plugins/plugin-check/cli.php

cc @ernilambar

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

Thanks @swissspidy. Overall this looks good to me, though I'm not sure I like the idea of the caller of the Plugin_Context class constructor having to take care of the normalization.

On the one hand, it makes sense from a separation of concerns perspective, because it works differently for WP core and WP-CLI. On the other hand, it would be great to implement this internally in the class.

Maybe we could go with a pragmatic approach within the Plugin_Context constructor? If wp_normalize_path() exists, use that, otherwise if we're in CLI and the WP-CLI method exists, use that, otherwise do nothing - or maybe even throw an exception cause this should never happen? WDYT?

@swissspidy
Copy link
Member Author

IDK, don't have a strong opinion. We can keep doing it in the constructor, but throwing an exception seems overkill.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

The current implementation WFM, though I do think being strict here is safer than silently letting a problematic configuration continue. Not a big deal either way, so my feedback is just nit-picks.

Note that there are some lint failures due to the CLI function.

includes/Plugin_Context.php Outdated Show resolved Hide resolved
includes/Plugin_Context.php Outdated Show resolved Hide resolved
Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

Thanks @swissspidy for the PR! Left some feedbacks.

includes/Plugin_Context.php Outdated Show resolved Hide resolved
includes/Plugin_Context.php Outdated Show resolved Hide resolved
tests/behat/features/plugin-check.feature Outdated Show resolved Hide resolved
includes/Plugin_Context.php Outdated Show resolved Hide resolved
@ernilambar
Copy link
Contributor

What if we provide polyfill function for wp_normalize_path() so that it is always available.

@swissspidy
Copy link
Member Author

I think a polyfill for an edge case that should never ever happen is overkill.

Here it‘s only not available because of the hacky object-cache.php drop-in

Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
@mukeshpanchal27 mukeshpanchal27 merged commit 6721eb4 into trunk Apr 9, 2024
24 checks passed
@mukeshpanchal27 mukeshpanchal27 deleted the fix/cli-fatal branch April 9, 2024 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature is broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants