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

Refine logic in perflab_install_activate_plugin_callback() to rely only on validated slug #1170

Merged
merged 5 commits into from
Apr 24, 2024

Conversation

westonruter
Copy link
Member

This first came up in #1168 (comment).

I felt it was strange that perflab_install_activate_plugin_callback() was relying on both a slug and a file query var to be passed, with when the latter is absent then the plugin is installed. It assumes that if file is absent, then the plugin is not installed. But it could be that someone installed the plugin in another session while that screen is open, meaning that the file query var check would result in a plugin attempting to be installed when it is actually already installed.

So this PR gets rid of the file query var in favor of exclusively sending the slug query var. Then in the perflab_install_activate_plugin_callback() function it takes the plugin slug and checks among all the installed plugins whether one of them (via the plugin file) to see if it is installed. If not, then it goes ahead and installs it.

This also improves the variable terminology to use $plugin_file rather than $plugin_basename which seems misleading as it could refer to just the file in the plugin's directory, when in fact it should be something like $slug/load.php.

Lastly, the submitted slug is better validated by checking if it is among any of the actual PL plugin slugs.

@westonruter westonruter added [Type] Enhancement A suggestion for improvement of an existing feature [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only labels Apr 23, 2024
@westonruter westonruter added this to the performance-lab 3.1.0 milestone Apr 23, 2024
Copy link

github-actions bot commented Apr 23, 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: westonruter <westonruter@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>

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

@westonruter westonruter mentioned this pull request Apr 23, 2024
@mukeshpanchal27 mukeshpanchal27 merged commit a4843b7 into trunk Apr 24, 2024
15 checks passed
@mukeshpanchal27 mukeshpanchal27 deleted the update/plugin-install-activate-callback branch April 24, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants