Closed boboldehampsink closed 2 years ago
Thanks for reporting that! Just released Craft 3.7.53.1 and 4.2.3 with a fix for that.
Seeing this error in Craft 4.5.14 Console::startProgress (u causes the Undefined constant "STDOUT" error. Only happens on our production server. The code is running inside a Queued Job. This is to output progress to the CLI, separate from the BaseJob setProgress.
The odd part is that if I run ./craft crm/registrations && ./craft queue/run it runs fine in the terminal, but if I only do ./craft crm/registrations and let the crontab for the QueueManager pick it up I see an error in Craft CP
@dgrigg Can you search for the error in storage/logs/
and post the stack trace?
It only happens if the Queue runs from the CP panel. Executing ./craft queue/run from the CLI runs fine. I ended up creating a Console Trait that wrapped the functions with this if (defined('STDOUT')
and added that to the Jobs to get around the issue. Any of the output functions in yii\helpers\Console throw the error.
Looks like it’s getting called from a module file:
#2 /var/www/thermacell/modules/crm/jobs/ProductDataJob.php(122): yii\helpers\BaseConsole::startProgress(0, 366, 'PRODUCTS: 366 ')
So you’ll need to adjust that code yourself.
Queue jobs should not assume that they will be run from a CLI request.
Yes, I fixed the code. The issue is that it's throwing that error in the first place. I guess the Queue process does not define STDOUT anywhere?
Your code is calling a method on the Console
helper, which should only ever be invoked on a CLI request. It’s expected that errors will occur if you do that from a web request. Nothing in the queue or built-in queue jobs is built to assume that it will be run from a CLI request.
Got it. Makes sense. Thanks.
What happened?
Description
Undefined constant "STDOUT"
See this Sentry log: https://sentry.io/share/issue/e795939f38dd4c4e858becf37dc14158/
Craft CMS version
Craft Pro 3.7.52
PHP version
8.1.9
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
-