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

未關閉 適合新手
#737 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
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 分鐘
30 天內合併 PR
61

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

quantum-php/framework 的其他 Issue

查看 quantum-php/framework 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。