dereuromark/cakephp-queue

Error runworker in postresql

Closed this issue · 2 comments

Hello,
I use cakephp-queue in postgesql server (branch master), i have this error :

Job Finished.
---------------------------------------------------------------
[2019-09-08 23:43:12] Looking for Job ...
Exception: SQLSTATE[42883]: Undefined function: 7 ERROR:  function unix_timestamp() does not exist
LINE 1: ...d < $3 OR (fetched) IS NULL)) AND failed < $4 AND UNIX_TIMES...
                                                         ^

The soluce :
in file QueuedJobsTable.php

change in line 475

				case static::DRIVER_POSTGRES:
				case static::DRIVER_MYSQL:
					$tmp['UNIX_TIMESTAMP() >='] = $this->rateHistory[$tmp['job_type']] + $task['rate'];
					break;

to :

				case static::DRIVER_POSTGRES:
				    $tmp["EXTRACT(EPOCH FROM NOW()) >="] = $this->rateHistory[$tmp['job_type']] + $task['rate'];
				    break;
				case static::DRIVER_MYSQL:
					$tmp['UNIX_TIMESTAMP() >='] = $this->rateHistory[$tmp['job_type']] + $task['rate'];
					break;

Regard

Can you make a PR with your suggested changes?

See PR #241