-
Notifications
You must be signed in to change notification settings - Fork 57
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 slug for single-file plugins in both admin and CLI #747
Open
swissspidy
wants to merge
9
commits into
trunk
Choose a base branch
from
fix/745-slug-domain
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4
−8
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e3480c6
Do not try to guess slug in `Abstract_Check_Runner`
swissspidy 48a3ed9
Use correct slug for single-file plugins
swissspidy 7b5bde6
Don't use `plugin_dir_path`
swissspidy 31a86e2
Merge branch 'trunk' into fix/745-slug-domain
swissspidy a184b20
No `trailingslashit`
swissspidy ce049d5
Remove errant space
swissspidy 89ba796
Merge branch 'trunk' into fix/745-slug-domain
swissspidy 16f8e09
Don't use in constructor
swissspidy f430cc2
Merge branch 'trunk' into fix/745-slug-domain
davidperezgar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should happen within
Plugin_Context
(whichCheck_Context
extends).That's where there's already logic to determine the slug by default, if none was specified. It doesn't make sense to me to have that duplicated in this class, neither here nor in the
set_slug()
method where it was so far.I think it makes most sense to have
get_slug()
pass through the empty string thatget_slug_param()
may return (for AJAX always, for CLI only if no slug was explicitly specified). And then because that string is empty,Plugin_Context
would define the default slug as the source of truth.Alternatively, if there's value to have the logic here in
Abstract_Check_Runner
, we should remove the logic fromPlugin_Context
and make the constructor$slug
parameter required (and throw an exception if it's empty). It just doesn't make sense to have the logic split/duplicated between two places.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just moved this there in 16f8e09 because otherwise it didn't work when using WP-CLI "shortinit" with
--require
. We don't pass enough information toCheck_Context
/Plugin_Context
on its own to determine whether it's a single-file plugin or not.Feel free to make edits to the PR with what you have in mind.
Aside: whenever we have to add workarounds like this I'm wondering whether we actually really want to support single-file plugins or not. They aren't allowed in the repo anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does WP-CLI "shortinit" work? Not familiar with it... How does it prevent that logic in the constructor from working correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the
--require
hack we use with the object-cache drop-in. Then a lot of the WP constants and functions won't be available that early. See https://github.com/WordPress/plugin-check/actions/runs/11660800826/job/32463868033?pr=747 for example.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying. I can have a look later this week to see if I can come up with a solution for that.