From 50ab21d8c9cd97692a7cec62f230b21832b52494 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Wed, 25 Oct 2023 19:33:05 +0200 Subject: [PATCH 1/4] Remove deprecations (#389) * Remove deprecations * Remove deprecations * Remove deprecations * Remove deprecations --- README.md | 2 +- composer.json | 2 +- src/Command/InfoCommand.php | 1 + src/Command/JobCommand.php | 1 + src/Command/WorkerCommand.php | 1 + src/Controller/Admin/QueueController.php | 1 + .../Admin/QueueProcessesController.php | 1 + src/Controller/Admin/QueuedJobsController.php | 1 + tests/TestCase/Command/AddCommandTest.php | 2 +- .../Command/BakeQueueTaskCommandTest.php | 2 +- tests/TestCase/Command/InfoCommandTest.php | 2 +- tests/TestCase/Command/JobCommandTest.php | 2 +- .../Command/MigrateTasksCommandTest.php | 2 +- tests/TestCase/Command/RunCommandTest.php | 2 +- tests/TestCase/Command/WorkerCommandTest.php | 2 +- .../Controller/Admin/QueueControllerTest.php | 2 +- .../Model/Table/QueuedJobsTableTest.php | 6 ++-- .../View/Helper/QueueProgressHelperTest.php | 28 +++++++++---------- 18 files changed, 33 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index aaacf84f..5ad6b28e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![Total Downloads](https://poser.pugx.org/dereuromark/cakephp-queue/d/total)](https://packagist.org/packages/dereuromark/cakephp-queue) [![Coding Standards](https://img.shields.io/badge/cs-PSR--2--R-yellow.svg)](https://github.com/php-fig-rectified/fig-rectified-standards) -This branch is for use with **CakePHP 4.3+**. For details see [version map](https://github.com/dereuromark/cakephp-queue/wiki#cakephp-version-map). +This branch is for use with **CakePHP 4.4+**. For details see [version map](https://github.com/dereuromark/cakephp-queue/wiki#cakephp-version-map). ## Background diff --git a/composer.json b/composer.json index 3728bc6a..74327ae2 100755 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require": { "php": ">=7.4", "brick/varexporter": "^0.3.5 || ^0.4.0", - "cakephp/cakephp": "^4.3.0" + "cakephp/cakephp": "^4.4.0" }, "require-dev": { "cakedc/cakephp-phpstan": "^2.0", diff --git a/src/Command/InfoCommand.php b/src/Command/InfoCommand.php index 06eb1d5b..8a0ec8c0 100644 --- a/src/Command/InfoCommand.php +++ b/src/Command/InfoCommand.php @@ -14,6 +14,7 @@ * @property \Queue\Model\Table\QueuedJobsTable $QueuedJobs * @property \Queue\Model\Table\QueueProcessesTable $QueueProcesses */ +#[\AllowDynamicProperties] class InfoCommand extends Command { /** diff --git a/src/Command/JobCommand.php b/src/Command/JobCommand.php index e5dbbeb7..0f6f4d8b 100644 --- a/src/Command/JobCommand.php +++ b/src/Command/JobCommand.php @@ -15,6 +15,7 @@ /** * @property \Queue\Model\Table\QueuedJobsTable $QueuedJobs */ +#[\AllowDynamicProperties] class JobCommand extends Command { /** diff --git a/src/Command/WorkerCommand.php b/src/Command/WorkerCommand.php index 0245f8d3..8023ae43 100644 --- a/src/Command/WorkerCommand.php +++ b/src/Command/WorkerCommand.php @@ -13,6 +13,7 @@ /** * @property \Queue\Model\Table\QueueProcessesTable $QueueProcesses */ +#[\AllowDynamicProperties] class WorkerCommand extends Command { /** diff --git a/src/Controller/Admin/QueueController.php b/src/Controller/Admin/QueueController.php index 87e6eb46..350c9e18 100644 --- a/src/Controller/Admin/QueueController.php +++ b/src/Controller/Admin/QueueController.php @@ -13,6 +13,7 @@ * @property \Queue\Model\Table\QueuedJobsTable $QueuedJobs * @property \Queue\Model\Table\QueueProcessesTable $QueueProcesses */ +#[\AllowDynamicProperties] class QueueController extends AppController { use LoadHelperTrait; diff --git a/src/Controller/Admin/QueueProcessesController.php b/src/Controller/Admin/QueueProcessesController.php index 2ea6cf0a..10071aa7 100644 --- a/src/Controller/Admin/QueueProcessesController.php +++ b/src/Controller/Admin/QueueProcessesController.php @@ -12,6 +12,7 @@ * @method \Cake\Datasource\ResultSetInterface<\Queue\Model\Entity\QueueProcess> paginate($object = null, array $settings = []) * @property \Queue\Model\Table\QueuedJobsTable $QueuedJobs */ +#[\AllowDynamicProperties] class QueueProcessesController extends AppController { use LoadHelperTrait; diff --git a/src/Controller/Admin/QueuedJobsController.php b/src/Controller/Admin/QueuedJobsController.php index 7240bdd0..f8785250 100644 --- a/src/Controller/Admin/QueuedJobsController.php +++ b/src/Controller/Admin/QueuedJobsController.php @@ -19,6 +19,7 @@ * @method \Cake\Datasource\ResultSetInterface<\Queue\Model\Entity\QueuedJob> paginate($object = null, array $settings = []) * @property \Search\Controller\Component\SearchComponent $Search */ +#[\AllowDynamicProperties] class QueuedJobsController extends AppController { use LoadHelperTrait; diff --git a/tests/TestCase/Command/AddCommandTest.php b/tests/TestCase/Command/AddCommandTest.php index 5fb92d46..ee552a1e 100644 --- a/tests/TestCase/Command/AddCommandTest.php +++ b/tests/TestCase/Command/AddCommandTest.php @@ -3,7 +3,7 @@ namespace Queue\Test\TestCase\Command; -use Cake\TestSuite\ConsoleIntegrationTestTrait; +use Cake\Console\TestSuite\ConsoleIntegrationTestTrait; use Cake\TestSuite\TestCase; /** diff --git a/tests/TestCase/Command/BakeQueueTaskCommandTest.php b/tests/TestCase/Command/BakeQueueTaskCommandTest.php index 02d7de25..2014edc6 100644 --- a/tests/TestCase/Command/BakeQueueTaskCommandTest.php +++ b/tests/TestCase/Command/BakeQueueTaskCommandTest.php @@ -3,7 +3,7 @@ namespace Queue\Test\TestCase\Command; -use Cake\TestSuite\ConsoleIntegrationTestTrait; +use Cake\Console\TestSuite\ConsoleIntegrationTestTrait; use Cake\TestSuite\TestCase; use Shim\TestSuite\TestTrait; diff --git a/tests/TestCase/Command/InfoCommandTest.php b/tests/TestCase/Command/InfoCommandTest.php index 12ba07bd..3f25667e 100644 --- a/tests/TestCase/Command/InfoCommandTest.php +++ b/tests/TestCase/Command/InfoCommandTest.php @@ -3,7 +3,7 @@ namespace Queue\Test\TestCase\Command; -use Cake\TestSuite\ConsoleIntegrationTestTrait; +use Cake\Console\TestSuite\ConsoleIntegrationTestTrait; use Cake\TestSuite\TestCase; /** diff --git a/tests/TestCase/Command/JobCommandTest.php b/tests/TestCase/Command/JobCommandTest.php index 8ad6be57..c0fe5e04 100644 --- a/tests/TestCase/Command/JobCommandTest.php +++ b/tests/TestCase/Command/JobCommandTest.php @@ -3,9 +3,9 @@ namespace Queue\Test\TestCase\Command; +use Cake\Console\TestSuite\ConsoleIntegrationTestTrait; use Cake\Core\Configure; use Cake\I18n\FrozenTime; -use Cake\TestSuite\ConsoleIntegrationTestTrait; use Cake\TestSuite\TestCase; use Queue\Model\Entity\QueuedJob; diff --git a/tests/TestCase/Command/MigrateTasksCommandTest.php b/tests/TestCase/Command/MigrateTasksCommandTest.php index 53313508..6b730223 100644 --- a/tests/TestCase/Command/MigrateTasksCommandTest.php +++ b/tests/TestCase/Command/MigrateTasksCommandTest.php @@ -3,7 +3,7 @@ namespace Queue\Test\TestCase\Command; -use Cake\TestSuite\ConsoleIntegrationTestTrait; +use Cake\Console\TestSuite\ConsoleIntegrationTestTrait; use Cake\TestSuite\TestCase; use Queue\Command\MigrateTasksCommand; use Shim\TestSuite\TestTrait; diff --git a/tests/TestCase/Command/RunCommandTest.php b/tests/TestCase/Command/RunCommandTest.php index 3db1dc32..e58d8449 100644 --- a/tests/TestCase/Command/RunCommandTest.php +++ b/tests/TestCase/Command/RunCommandTest.php @@ -3,9 +3,9 @@ namespace Queue\Test\TestCase\Command; +use Cake\Console\TestSuite\ConsoleIntegrationTestTrait; use Cake\Core\Configure; use Cake\Datasource\ConnectionManager; -use Cake\TestSuite\ConsoleIntegrationTestTrait; use Cake\TestSuite\TestCase; /** diff --git a/tests/TestCase/Command/WorkerCommandTest.php b/tests/TestCase/Command/WorkerCommandTest.php index 70910e39..0a2ed650 100644 --- a/tests/TestCase/Command/WorkerCommandTest.php +++ b/tests/TestCase/Command/WorkerCommandTest.php @@ -3,7 +3,7 @@ namespace Queue\Test\TestCase\Command; -use Cake\TestSuite\ConsoleIntegrationTestTrait; +use Cake\Console\TestSuite\ConsoleIntegrationTestTrait; use Cake\TestSuite\TestCase; /** diff --git a/tests/TestCase/Controller/Admin/QueueControllerTest.php b/tests/TestCase/Controller/Admin/QueueControllerTest.php index 07739cc4..71724f94 100644 --- a/tests/TestCase/Controller/Admin/QueueControllerTest.php +++ b/tests/TestCase/Controller/Admin/QueueControllerTest.php @@ -242,7 +242,7 @@ public function testFlush() { $job = $jobsTable->newEntity([ 'job_task' => 'foo', 'failed' => 1, - 'fetched' => (new FrozenTime())->subHour(), + 'fetched' => (new FrozenTime())->subHours(1), ]); $jobsTable->saveOrFail($job); diff --git a/tests/TestCase/Model/Table/QueuedJobsTableTest.php b/tests/TestCase/Model/Table/QueuedJobsTableTest.php index a12ecb5c..ea961381 100644 --- a/tests/TestCase/Model/Table/QueuedJobsTableTest.php +++ b/tests/TestCase/Model/Table/QueuedJobsTableTest.php @@ -689,9 +689,9 @@ public function testIsQueued() { public function testGetStats() { $queuedJob = $this->QueuedJobs->newEntity([ 'job_task' => 'Foo', - 'completed' => (new FrozenTime())->subHour(2), - 'fetched' => (new FrozenTime())->subHour(3), - 'created' => (new FrozenTime())->subHour(5), + 'completed' => (new FrozenTime())->subHours(2), + 'fetched' => (new FrozenTime())->subHours(3), + 'created' => (new FrozenTime())->subHours(5), ]); $this->QueuedJobs->saveOrFail($queuedJob); diff --git a/tests/TestCase/View/Helper/QueueProgressHelperTest.php b/tests/TestCase/View/Helper/QueueProgressHelperTest.php index 3582ca40..5d636aeb 100644 --- a/tests/TestCase/View/Helper/QueueProgressHelperTest.php +++ b/tests/TestCase/View/Helper/QueueProgressHelperTest.php @@ -86,7 +86,7 @@ public function testProgress() { public function testProgressCalculatedEmpty() { $queuedJob = new QueuedJob([ 'job_task' => 'Queue.Example', - 'fetched' => (new FrozenTime())->subMinute(), + 'fetched' => (new FrozenTime())->subMinutes(1), ]); $result = $this->QueueProgressHelper->progress($queuedJob); $this->assertNull($result); @@ -99,14 +99,14 @@ public function testProgressCalculated() { $queuedJob = new QueuedJob([ 'job_task' => 'Queue.Example', 'created' => (new FrozenTime())->subMinutes(2), - 'fetched' => (new FrozenTime())->subMinute(), + 'fetched' => (new FrozenTime())->subMinutes(1), 'completed' => (new FrozenTime())->subSeconds(2), ]); $this->getTableLocator()->get('Queue.QueuedJobs')->saveOrFail($queuedJob); $queuedJob = new QueuedJob([ 'job_task' => 'Queue.Example', - 'fetched' => (new FrozenTime())->subMinute(), + 'fetched' => (new FrozenTime())->subMinutes(1), ]); $result = $this->QueueProgressHelper->progress($queuedJob); @@ -160,14 +160,14 @@ public function testProgressBarByStatistics() { /** @var \Queue\Model\Entity\QueuedJob $queuedJob */ $queuedJob = $this->getTableLocator()->get('Queue.QueuedJobs')->newEntity([ 'job_task' => 'Foo', - 'created' => (new FrozenTime())->subHour(), - 'fetched' => (new FrozenTime())->subHour(), - 'completed' => (new FrozenTime())->subHour()->addMinutes(10), + 'created' => (new FrozenTime())->subHours(1), + 'fetched' => (new FrozenTime())->subHours(1), + 'completed' => (new FrozenTime())->subHours(1)->addMinutes(10), ]); $this->getTableLocator()->get('Queue.QueuedJobs')->saveOrFail($queuedJob); $queuedJob->completed = null; - $queuedJob->fetched = (new FrozenTime())->subMinute(); + $queuedJob->fetched = (new FrozenTime())->subMinutes(1); $result = $this->QueueProgressHelper->progressBar($queuedJob, 5); $this->assertTextContains('', $result); @@ -178,8 +178,8 @@ public function testProgressBarByStatistics() { */ public function testTimeoutProgressBar() { $queuedJob = new QueuedJob([ - 'created' => (new FrozenTime())->subHour(), - 'notbefore' => (new FrozenTime())->addHour(), + 'created' => (new FrozenTime())->subHours(1), + 'notbefore' => (new FrozenTime())->addHours(1), ]); $result = $this->QueueProgressHelper->timeoutProgressBar($queuedJob, 5); @@ -191,8 +191,8 @@ public function testTimeoutProgressBar() { */ public function testHtmlTimeoutProgressBar() { $queuedJob = new QueuedJob([ - 'created' => (new FrozenTime())->subMinute(), - 'notbefore' => (new FrozenTime())->addMinute(), + 'created' => (new FrozenTime())->subMinutes(1), + 'notbefore' => (new FrozenTime())->addMinutes(1), ]); $result = $this->QueueProgressHelper->htmlTimeoutProgressBar($queuedJob); $expected = ''; @@ -200,7 +200,7 @@ public function testHtmlTimeoutProgressBar() { $queuedJob = new QueuedJob([ 'created' => (new FrozenTime()), - 'notbefore' => (new FrozenTime())->addHour(), + 'notbefore' => (new FrozenTime())->addHours(1), ]); // For IE9 and below $fallback = $this->QueueProgressHelper->timeoutProgressBar($queuedJob, 10); @@ -209,8 +209,8 @@ public function testHtmlTimeoutProgressBar() { $this->assertSame($expected, $result); $queuedJob = new QueuedJob([ - 'created' => (new FrozenTime())->subMinute(), - 'notbefore' => (new FrozenTime())->subSecond(), + 'created' => (new FrozenTime())->subMinutes(1), + 'notbefore' => (new FrozenTime())->subSeconds(1), ]); // For IE9 and below $fallback = $this->QueueProgressHelper->timeoutProgressBar($queuedJob, 10); From ddac3dfc9a8b408847dae87e216d69e07b6f1ce9 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 26 Oct 2023 13:22:29 +0200 Subject: [PATCH 2/4] Gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b5ad65e1..fcb72d6a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ composer.lock schema-dump-default.lock composer.phar /.phpunit.result.cache +/.phpunit.cache/ From 01a7583710795b40d27e1df989f7c65af24ee922 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 8 Nov 2023 05:04:17 +0100 Subject: [PATCH 3/4] Fix up CI badge --- .github/workflows/ci.yml | 2 -- README.md | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa23e605..5fbf4feb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,8 +2,6 @@ name: CI on: push: - branches: - - master pull_request: workflow_dispatch: diff --git a/README.md b/README.md index 5ad6b28e..55212778 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # CakePHP Queue Plugin -[![CI](https://github.com/dereuromark/cakephp-queue/workflows/CI/badge.svg?branch=master)](https://github.com/dereuromark/cakephp-queue/actions?query=workflow%3ACI+branch%3Amaster) +[![CI](https://github.com/dereuromark/cakephp-queue/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/dereuromark/cakephp-queue/actions?query=workflow%3ACI+branch%3Amaster) [![Coverage Status](https://img.shields.io/codecov/c/github/dereuromark/cakephp-queue/master.svg)](https://codecov.io/github/dereuromark/cakephp-queue/branch/master) [![Latest Stable Version](https://poser.pugx.org/dereuromark/cakephp-queue/v/stable.svg)](https://packagist.org/packages/dereuromark/cakephp-queue) [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.4-8892BF.svg)](https://php.net/) From fc54fa50586b410014356d730807455bcb359ca3 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 28 Nov 2023 08:01:52 +0100 Subject: [PATCH 4/4] add index to queued_jobs table --- .../202311128071500_MigrationAddIndex.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 config/Migrations/202311128071500_MigrationAddIndex.php diff --git a/config/Migrations/202311128071500_MigrationAddIndex.php b/config/Migrations/202311128071500_MigrationAddIndex.php new file mode 100644 index 00000000..7b55147c --- /dev/null +++ b/config/Migrations/202311128071500_MigrationAddIndex.php @@ -0,0 +1,15 @@ +table('queued_jobs'); + $table + ->addIndex('completed') + ->addIndex('job_task') + ->update(); + } + +}