Skip to content

Commit cce051d

Browse files
committed
Fix cleanup timeout disable.
1 parent bdceb43 commit cce051d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

docs/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ You may create a file called `app_queue.php` inside your `config` folder (NOT th
6464
$config['Queue']['exitwhennothingtodo'] = false;
6565
```
6666

67-
- Minimum number of seconds before a cleanup run will remove a completed task; defaults to 0 for the Queue worker, or 2592000 for the Cron worker:
67+
- Minimum number of seconds before a cleanup run will remove a completed task (set to 0 to disable):
6868

6969
```php
7070
$config['Queue']['cleanuptimeout'] = 2592000; // 30 days
7171
```
72-
72+
7373
- Use a different connection:
7474

7575
```php

src/Model/Table/QueuedJobsTable.php

+4
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@ public function getPendingStats() {
412412
* @return void
413413
*/
414414
public function cleanOldJobs() {
415+
if (!Configure::read('Queue.cleanuptimeout')) {
416+
return;
417+
}
418+
415419
$this->deleteAll([
416420
'completed <' => time() - Configure::read('Queue.cleanuptimeout'),
417421
]);

src/Shell/QueueShell.php

+4
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ protected function _logError($message) {
229229
* @return void
230230
*/
231231
public function clean() {
232+
if (!Configure::read('Queue.cleanuptimeout')) {
233+
$this->abort('You disabled cleanuptimout in config. Aborting.');
234+
}
235+
232236
$this->out('Deleting old jobs, that have finished before ' . date('Y-m-d H:i:s', time() - Configure::read('Queue.cleanuptimeout')));
233237
$this->QueuedJobs->cleanOldJobs();
234238
$this->QueueProcesses->cleanKilledProcesses();

0 commit comments

Comments
 (0)