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

Single file plugin text domain check yields mixed and incorrect expected strings #745

Open
ironprogrammer opened this issue Oct 24, 2024 · 4 comments · May be fixed by #747
Open

Single file plugin text domain check yields mixed and incorrect expected strings #745

ironprogrammer opened this issue Oct 24, 2024 · 4 comments · May be fixed by #747
Labels
[Type] Bug An existing feature is broken

Comments

@ironprogrammer
Copy link

For a single file plugin with a text domain set, the WordPress.WP.I18n.TextDomainMismatch check relies on a plugin directory slug (non-existent in this context) and shows different results between the UI and CLI. It has been suggested that this check be bypassed for single-file plugins (hat tip @ernilambar).

To test this, I added the hello-dolly text domain to the hello.php plugin that ships with WP core (required to avoid an error with the WordPress.WP.I18n.MissingArgDomain check):

__( 'Quote from Hello Dolly song, by Jerry Herman:', 'hello-dolly' ),

Running PCP, the admin shows
Mismatched text domain. Expected 'plugins' but got 'hello-dolly'.
whereas the CLI returns
Mismatched text domain. Expected 'hello.php' but got 'hello-dolly'.

Originally reported at #713 (comment).

@ernilambar
Copy link
Member

May be if we bail the runner in Abstract_PHP_CodeSniffer_Check if $this->get_args( $result ) is empty array. This way we can pass args based on single file plugin or multiple file plugin.

CC @swissspidy

@ernilambar ernilambar added the [Type] Bug An existing feature is broken label Oct 25, 2024
@swissspidy
Copy link
Member

Sorry, why is that array empty for single-file plugins?

We do have special handling for single-file plugins in many places, I suppose this is just one more place we‘d need to fix.

@ernilambar
Copy link
Member

For check extended from Abstract_PHP_CodeSniffer_Check, only get_args() method is exposed. I could not find place to add is_single_file_plugin() conditional for such check like I18n_Usage_Check.

@swissspidy
Copy link
Member

Trying to solve this in I18n_Usage_Check is the wrong place. The big issue is that admin & CLI expect a different plugin slug. And both of them are incorrect.

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 a pull request may close this issue.

3 participants