laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.22k stars 10.91k forks source link

Improper option parsing for scheduled commands with options. #52685

Closed davidbankes closed 2 weeks ago

davidbankes commented 2 weeks ago

Laravel Version

11.22.0

PHP Version

8.2.22

Database Driver & Version

mysql5.5.5-10.5.26-MariaDB

Description

Scheduled commands cannot handle boolean options according to the documentation.

Steps To Reproduce

Create a command (e.g. app:do-thing with a boolean option (say --force). Schedule that command with the boolean option being called (Schedule::command('app:do-thing', ['--force' => true]) in the routes/console.php file). Run the schedule, and you'll get The "--force" option does not accept a value.

Furthermore, if you run php artisan shedule:list you'll see that the command has been improperly parsed so that the command now is app:do-thing --force='1', which is wrong and understandably causes that error.

Below are screenshots showing my command signature, my console.php file, the output of php artisan schedule:list and the flare report.

Screenshot 2024-09-06 at 11 50 03 AM

davidbankes commented 2 weeks ago

Drat. I was looking at the wrong documentation. I was looking at calling commands from other code, and that's different from registering it for the cron.

Sorry.