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

オープン 初心者向け
#737 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
cli

調査の方向性

まず CliCommand::error() と CliCommand::execute() を見つけ、コマンドの戻り値がプロセスの終了ステータスに変換される流れを追います。issue に記載された config:publish のケースを確認し、報告されたエラーと成功するコマンドを対象にしたテストを追加または実行します。error() がステータス 1 になり、正常終了がステータス 0 になり、動作の変更が changelog に記録されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
PHP
スター
44
フォーク
22
平均マージ
2時間 49分
マージ済み PR(30日)
61

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quantum-php/framework のほかの issue

quantum-php/framework の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。