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

info() function misbehaves when multiple plugins use ExamplePluginUpdater #4

Open
bonny opened this issue Sep 15, 2023 · 3 comments
Open

Comments

@bonny
Copy link

bonny commented Sep 15, 2023

I think there is a bug in the the class ExamplePluginUpdater and usage of the plugins_api filter.

The info() function
https://github.com/Make-Lemonade/lemonsqueezy-wp-updater-example/blob/main/includes/class-plugin-updater.php#L125-L146
returns false if the $action is of the wrong type, or if the plugin slug is not the wanted one, or if the remote request fails. I believe it should return the passed $result instead, because the plugins_api filter can be used multiple times, for example using the ExamplePluginUpdater multiple times for multiple plugins (that was my case).

Example: I have two plugins using the ExamplePluginUpdater class: "Plugin A" and "Plugin B".
In the WP plugin list page I click "View version 1.2.3 details" for Plugin A to view details about that plugin. Then the filter in ExamplePluginUpdater fetches info for that plugin and correctly returns an object (non-false value). However since the filter is also used for Plugin B it's called again and since it's not the correct plugin slug this time, it returns false and the result from Plugin A is discarded and the result for the user is "Plugin not found.".

I solved this by using return $result; instead of return false; in the info function and it works for me after that change.

@bdkoder
Copy link

bdkoder commented Jan 31, 2024

Hi @bonny,
Please use namespace to solve the problem.
Thanks

@Brugman
Copy link

Brugman commented Feb 11, 2024

If you renamed ExamplePluginUpdater to be PluginAUpdater in Plugin A and PluginBUpdater in Plugin B, would this bug be avoided? (without namespaces)

Because that's what I think the name ExamplePluginUpdater is hinting at we should do.

@bonny
Copy link
Author

bonny commented Feb 11, 2024

@bdkoder @Brugman thanks for your feedback. I don't believe namespaces or different function names solves this. It's all about the return value.

It's the same kind of issue that for example was reported to this other plugin:
rudrastyh/misha-update-checker#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants