php qt commands exit with status 0 when they report an error

Offen Anfängerfreundlich
#737 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
78/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
php
Bereich
cli

Rechercherichtung

Beginne damit, CliCommand::error() und CliCommand::execute() zu finden, und verfolge dann, wie Rückgabewerte von Befehlen zu Prozess-Exit-Status werden. Prüfe die im Issue aufgeführten Fälle von config:publish und füge gezielte Tests für gemeldete Fehler und erfolgreiche Befehle hinzu oder führe sie aus. Das Ziel ist erreicht, wenn error() zu Status 1 führt, ein normaler Abschluss zu Status 0 führt und die Verhaltensänderung im Changelog festgehalten ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Summary

A php qt command that stops on an error prints the message with CliCommand::error() and returns, but the process still exits with status 0. CliCommand::execute() calls exec() and always returns Command::SUCCESS. Scripts, deploy steps and CI jobs cannot tell such a failure from a success.

Where it happens

Eight core commands report errors this way: config:publish, cron:run, debugbar, core:env, module:generate, openapi, cache:clear and route:list. Application commands that extend CliCommand behave the same. A command that throws an exception already exits with a non-zero status; only errors reported through error() are affected.

For example, php qt config:publish Cache exits with 0 when shared/config/cache.php already exists and -y is not given, although nothing was published.

Scope

  1. CliCommand::error() marks the command as failed.
  2. CliCommand::execute() returns Command::FAILURE when the command was marked as failed, and Command::SUCCESS otherwise.
  3. exec() keeps its signature, so existing commands, core and application, need no change.

Acceptance criteria

  • a command that calls error() exits with status 1
  • a command that finishes without error() exits with status 0
  • config:publish exits with 1 for an existing file without -y, an unknown package or module, and a failed copy
  • the change is listed in the changelog as a behavior change, since scripts that ignored the status may now see failures
Vorherrschende Sprache
PHP
Sterne
44
Forks
22
Ø Merge
2 Std. 49 Min.
Gemergte PRs (30 T.)
61

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus quantum-php/framework

Alle Issues in quantum-php/framework

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.