wa0x6e / Cake-Resque

Resque plugin for CakePHP : for creating background jobs that can be processed offline later
MIT License
159 stars 56 forks source link

Monolog: timezone setting missing #32

Closed johannesnagl closed 10 years ago

johannesnagl commented 10 years ago

Hi,

since there's no possibility to open an issue directly at the monolog-repo, I'd like to open up the issue here, because i do receive the error when firing up a resque worker.

by calling

Console/cake CakeResque.CakeResque start

I receive a "fail" and the worker can not be started. having a look in the resque-worker-error.log I found the following error:

PHP Fatal error:  Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead' in …/htdocs/app/Plugin/CakeResque/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php:42
Stack trace:
#0 …/htdocs/app/Plugin/CakeResque/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(42): DateTime->__construct('tomorrow')
#1 [internal function]: Monolog\Handler\RotatingFileHandler->__construct('/Users/...')
#2 …/htdocs/app/Plugin/CakeResque/vendor/kamisama/monolog-init/src/MonologInit/MonologInit.php(98): ReflectionClass->newInstanceArgs(Array)
#3 [int in …/htdocs/app/Plugin/CakeResque/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php on line 42

Of course, I sat the date_default_timezone_set directly within Cake's core.php file, but this is apparently not reflected by monolog.

by adding the "date_default_timezone_set('Europe/Vienna');" directly to the mentioned file above, everything works as expected. but I think, this is only a quick & dirty hack - not a proper solution to the underlying problem. what do you think?

wa0x6e commented 10 years ago

Set it in your php.ini

johannesnagl commented 10 years ago

don't you see an advantage for this directly within the code? i don't always have the possibility to change this in the php.ini due to access limitations.

wa0x6e commented 10 years ago

Putting it in the php.ini is the "right way" to solve that warning.

You can also set php.ini values in .htaccess if your server is running under Apache, and if it allows it.

Setting the timezone directly in a file is a bit hacky, since everyone has a different timezone, and you can't hardcode that.

wa0x6e commented 10 years ago

If it's really not possible, you can maybe try setting your timezone in Lib/CakeResqueBootstrap.php

wa0x6e commented 10 years ago

Any update ?

johannesnagl commented 10 years ago

Sorry, this does not help. I tested it within the Lib/CakeResque.php as well as in my custom Config/boostrap.php

Both ways do not work as expected - i'm receiving the same error as mentioned previously.

wa0x6e commented 10 years ago

Can you update the composer dependencies, and try again with Lib/CakeResqueBootstrap.php ?

New php-resque-ex version should be 1.2.7

johannesnagl commented 10 years ago

Looks like it's now working out of the box - without a need to write something in Lib/CakeResqueBootstrap.php.

Thx mate!

wa0x6e commented 10 years ago

Good !