Rethink the WP-CLI approach

Aperta
#153 0 commenti 3 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
php, wordpress
Ambito
cli

Direzione di ricerca

Inizia esaminando l'integrazione attuale di WP-CLI e il modo in cui object-cache.php viene utilizzato come hook. Confronta questo approccio con il pacchetto WP-CLI separato proposto, il comando condizionale del plugin e i controlli della versione. Il lavoro sarà considerato completato quando sarà disponibile un design condiviso per il pacchetto, il comportamento di fallback del plugin, il rilevamento degli aggiornamenti e i necessari confini del repository.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

[Type] Enhancement Needs Discussion WP-CLI
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.

  1. Create a WP-CLI package that provides a plugin check command. This package is a separate repository and can be installed via something like wp 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 using WP_CLI::add_wp_hook().
  2. From within the plugin, conditionally add a WP-CLI plugin check only if that command is not yet registered (to avoid overriding the already installed WP-CLI package). This plugin check command 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
  1. 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
Lingua principale
PHP
Stelle
365
Fork
135
Merge medio
1g 8h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di WordPress/plugin-check

Tutte le issue di WordPress/plugin-check

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.