Rethink the WP-CLI approach
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
Piste de recherche
Commencez par examiner l’intégration actuelle de WP-CLI et la manière dont object-cache.php est utilisé comme hook. Comparez cette approche avec le package WP-CLI séparé proposé, la commande conditionnelle du plugin et les vérifications de version. La tâche sera considérée comme terminée lorsqu’un design approuvé existera pour le package, le comportement de fallback du plugin, la détection des mises à jour et les limites nécessaires du repository.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Is your enhancement related to a problem? Please describe.
Hi performance team!
@spacedmonkey pinged me to see if I have any input on improving the WP-CLI integration.
The current approach to integrating with WP-CLI is both cumbersome and can lead to side effects due to the use of object-cache.php as a "hook".
I would suggest a different approach that is safer to use and will ultimately provide a better user experience.
- Create a WP-CLI package that provides a
plugin checkcommand. This package is a separate repository and can be installed via something likewp package install 10up/plugin-check-cli. As a WP-CLI package, it is already loaded and active before WordPress is loaded, so there is no need for any special handling to get in early. The command can check for the existence of the plugin and make use of its files as required, or come with its own code where it makes sense. This allows for different handling in CLI than for the regular plugin, but also allows for code reuse where applicable (just ensure you can rely on a fixed set of interfaces!). It also gives full control over the WordPress environment and you can already hook into the WordPress lifecycle usingWP_CLI::add_wp_hook(). - From within the plugin, conditionally add a WP-CLI
plugin checkonly if that command is not yet registered (to avoid overriding the already installed WP-CLI package). Thisplugin checkcommand does not actually run any checks, though, it only produces a helpful message about the missing WP-CLI package and how the user can install it. It will show something like this:
$ wp plugin check akismet
Error: The necessary WP-CLI package for running performance checks has not yet been installed.
Please install it using the following command and then run your request again:
wp package install 10up/plugin-check-cli
- Add version numbers and update checks into both the WP-CLI package and the plugin to ensure that you can detect unmet requirements and prompt users to run updates when required.
The above should be a safer way to achieve a WP-CLI integration with a plugin that goes beyond the boundaries of what a plugin is supposed to do.
That being said, I'd like to note, that I'd generally not recommend have this type of checkers in a plugin, but would rather recommend building it CLI-first and then maybe wrap a plugin UI around it, not the other way around as it is happening here.
Designs
No response
Describe alternatives you've considered
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
- Langage dominant
- PHP
- Étoiles
- 365
- Forks
- 135
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 20
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de WordPress/plugin-check
-
False positive trademarked_term warning for "wc" inside the word "Flowchart"Peut-être pris @anandrajaram21 l’a pris il y a 3 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
WordPress/plugin-check#1556 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Add opt-in .distignore exclusions for local and CI scansPeut-être pris @jakaria-istauk l’a pris il y a 1 jour. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 42/100
WordPress/plugin-check#1559 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 58/100
WordPress/plugin-check#1557 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
WordPress/plugin-check#1555 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
PHPErrorReportingSniff flags debug constants used as values in const declarationsPeut-être pris @elphizu l’a pris il y a 7 jours. Ouverte
Difficulté 3/5 Une demi-journée Accessibilité débutants 35/100
WordPress/plugin-check#1553 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de WordPress/plugin-check
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
ExpressionEngine/ExpressionEngine#5493 ·
Les mainteneurs répondent en général sous 5 jours
-
"Attempt to read property 'username' on null" error after a user is deletedPeut-être pris @dicksonlaw583 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
omeka/plugin-SimplePages#49 ·
-
Bug Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
quantum-php/project#222 ·
-
support
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour