Skip to content

Commit d123eb8

Browse files
committed
Merge branch '2.x' into 2.next
# Conflicts: # composer.json # tests/TestCase/Command/WorkerCommandTest.php # tests/TestCase/Consumption/LimitAttemptsExtensionTest.php # tests/TestCase/Consumption/RemoveUniqueJobIdFromCacheExtensionTest.php # tests/TestCase/Queue/ProcessorTest.php
2 parents 09b79ec + 0589469 commit d123eb8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+474
-333
lines changed

.github/workflows/deploy_docs_1x.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Cloning repo
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v6
1616
with:
1717
fetch-depth: 0
1818

.github/workflows/deploy_docs_2x.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Cloning repo
15-
uses: actions/checkout@v3
15+
uses: actions/checkout@v6
1616
with:
1717
fetch-depth: 0
1818

.phive/phars.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="phpstan" version="2.1.17" installed="2.1.17" location="./tools/phpstan" copy="false"/>
3+
<phar name="phpstan" version="2.1.31" installed="2.1.31" location="./tools/phpstan" copy="false"/>
44
</phive>

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Queue plugin for CakePHP
22

3-
![Build Status](https://github.com/cakephp/queue/actions/workflows/ci.yml/badge.svg?branch=master)
3+
[![CI](https://github.com/cakephp/queue/actions/workflows/ci.yml/badge.svg)](https://github.com/cakephp/queue/actions/workflows/ci.yml)
44
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt)
55
[![Coverage Status](https://img.shields.io/codecov/c/github/cakephp/queue/master.svg?style=flat-square)](https://codecov.io/github/cakephp/queue?branch=master)
6+
[![PHPStan Level 8](https://img.shields.io/badge/PHPStan-level%208-brightgreen)](https://github.com/cakephp/queue)
67
[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/queue.svg?style=flat-square)](https://packagist.org/packages/cakephp/queue)
78

89
This is a Queue system for CakePHP.

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
},
2323
"require": {
2424
"php": ">=8.1",
25-
"cakephp/cakephp": "dev-5.next as 5.1.0",
25+
"cakephp/cakephp": "^5.1.0",
2626
"enqueue/simple-client": "^0.10",
2727
"psr/log": "^3.0"
2828
},
2929
"require-dev": {
30-
"cakephp/bake": "dev-3.next",
30+
"cakephp/bake": "^3.5.1",
3131
"cakephp/cakephp-codesniffer": "^5.0",
3232
"enqueue/fs": "^0.10",
33-
"phpunit/phpunit": "^10.5.5 || ^11.1.3"
33+
"phpunit/phpunit": "^10.5.32 || ^11.3.3 || ^12.0.9"
3434
},
3535
"suggest": {
3636
"cakephp/bake": "Required if you want to generate jobs.",
@@ -66,6 +66,9 @@
6666
"phpstan": "tools/phpstan analyse",
6767
"stan-baseline": "tools/phpstan --generate-baseline",
6868
"stan-setup": "phive install",
69+
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"^2.2\" && mv composer.backup composer.json",
70+
"rector-check": "vendor/bin/rector process --dry-run",
71+
"rector-fix": "vendor/bin/rector process",
6972
"test": "phpunit",
7073
"test-coverage": "phpunit --coverage-clover=clover.xml"
7174
}

config/Migrations/20221007202459_CreateFailedJobs.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22
declare(strict_types=1);
33

4-
use Migrations\AbstractMigration;
4+
use Migrations\BaseMigration;
55

6-
class CreateFailedJobs extends AbstractMigration
6+
class CreateFailedJobs extends BaseMigration
77
{
88
/**
99
* Change Method.
1010
*
1111
* More information on this method is available here:
12-
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
12+
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
1313
* @return void
1414
*/
1515
public function change()

phpcs.xml.dist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?xml version="1.0"?>
22
<ruleset name="CakePHP Queue">
3-
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer" />
43
<rule ref="CakePHP" />
54

5+
<file>src/</file>
6+
<file>tests/</file>
7+
68
<exclude-pattern>tests/comparisons/*</exclude-pattern>
79
</ruleset>

rector.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
5+
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector;
8+
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
9+
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
10+
use Rector\TypeDeclarationDocblocks\Rector\ClassMethod\DocblockReturnArrayFromDirectArrayInstanceRector;
11+
use Rector\ValueObject\PhpVersion;
12+
13+
return RectorConfig::configure()
14+
->withPhpVersion(PhpVersion::PHP_82)
15+
->withPaths([
16+
__DIR__ . '/src',
17+
__DIR__ . '/tests',
18+
])
19+
->withSkip([
20+
DisallowedEmptyRuleFixerRector::class,
21+
SimplifyIfElseToTernaryRector::class,
22+
MakeInheritedMethodVisibilitySameAsParentRector::class,
23+
RemoveNullTagValueNodeRector::class,
24+
RemoveUselessReturnTagRector::class,
25+
DocblockReturnArrayFromDirectArrayInstanceRector::class => [
26+
__DIR__ . '/src/Mailer/Transport/QueueTransport.php',
27+
],
28+
])
29+
->withParallel()
30+
->withPreparedSets(
31+
deadCode: true,
32+
codeQuality: true,
33+
codingStyle: true,
34+
typeDeclarationDocblocks: true,
35+
);

src/Command/PurgeFailedCommand.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public function getOptionParser(): ConsoleOptionParser
7272
/**
7373
* @param \Cake\Console\Arguments $args Arguments
7474
* @param \Cake\Console\ConsoleIo $io ConsoleIo
75-
* @return void
75+
* @return int
7676
*/
77-
public function execute(Arguments $args, ConsoleIo $io): void
77+
public function execute(Arguments $args, ConsoleIo $io): int
7878
{
7979
/** @var \Cake\Queue\Model\Table\FailedJobsTable $failedJobsTable */
8080
$failedJobsTable = $this->getTableLocator()->get('Cake/Queue.FailedJobs');
@@ -108,21 +108,23 @@ public function execute(Arguments $args, ConsoleIo $io): void
108108
if (!$deletingCount) {
109109
$io->out('0 jobs found.');
110110

111-
return;
111+
return self::CODE_SUCCESS;
112112
}
113113

114114
if (!$args->getOption('force')) {
115-
$confirmed = $io->askChoice("Delete {$deletingCount} jobs?", ['y', 'n'], 'n');
115+
$confirmed = $io->askChoice(sprintf('Delete %s jobs?', $deletingCount), ['y', 'n'], 'n');
116116

117117
if ($confirmed !== 'y') {
118-
return;
118+
return self::CODE_SUCCESS;
119119
}
120120
}
121121

122-
$io->out("Deleting {$deletingCount} jobs.");
122+
$io->out(sprintf('Deleting %s jobs.', $deletingCount));
123123

124124
$failedJobsTable->deleteManyOrFail($jobsToDelete);
125125

126-
$io->success("{$deletingCount} jobs deleted.");
126+
$io->success($deletingCount . ' jobs deleted.');
127+
128+
return self::CODE_SUCCESS;
127129
}
128130
}

src/Command/RequeueCommand.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public function getOptionParser(): ConsoleOptionParser
7474
/**
7575
* @param \Cake\Console\Arguments $args Arguments
7676
* @param \Cake\Console\ConsoleIo $io ConsoleIo
77-
* @return void
77+
* @return int
7878
*/
79-
public function execute(Arguments $args, ConsoleIo $io): void
79+
public function execute(Arguments $args, ConsoleIo $io): int
8080
{
8181
/** @var \Cake\Queue\Model\Table\FailedJobsTable $failedJobsTable */
8282
$failedJobsTable = $this->getTableLocator()->get('Cake/Queue.FailedJobs');
@@ -110,26 +110,26 @@ public function execute(Arguments $args, ConsoleIo $io): void
110110
if (!$requeueingCount) {
111111
$io->out('0 jobs found.');
112112

113-
return;
113+
return self::CODE_SUCCESS;
114114
}
115115

116116
if (!$args->getOption('force')) {
117-
$confirmed = $io->askChoice("Requeue {$requeueingCount} jobs?", ['y', 'n'], 'n');
117+
$confirmed = $io->askChoice(sprintf('Requeue %s jobs?', $requeueingCount), ['y', 'n'], 'n');
118118

119119
if ($confirmed !== 'y') {
120-
return;
120+
return self::CODE_SUCCESS;
121121
}
122122
}
123123

124-
$io->out("Requeueing {$requeueingCount} jobs.");
124+
$io->out(sprintf('Requeueing %s jobs.', $requeueingCount));
125125

126126
$succeededCount = 0;
127127
$failedCount = 0;
128128

129129
/** @var array<\Cake\Queue\Model\Entity\FailedJob> $jobsToRequeue */
130130
$jobsToRequeue = $jobsToRequeueQuery->all();
131131
foreach ($jobsToRequeue as $failedJob) {
132-
$io->verbose("Requeueing FailedJob with ID {$failedJob->id}.");
132+
$io->verbose(sprintf('Requeueing FailedJob with ID %d.', $failedJob->id));
133133
try {
134134
QueueManager::push(
135135
[$failedJob->class, $failedJob->method],
@@ -145,19 +145,21 @@ public function execute(Arguments $args, ConsoleIo $io): void
145145

146146
$succeededCount++;
147147
} catch (Exception $e) {
148-
$io->err("Exception occurred while requeueing FailedJob with ID {$failedJob->id}");
148+
$io->err('Exception occurred while requeueing FailedJob with ID ' . $failedJob->id);
149149
$io->err((string)$e);
150150

151151
$failedCount++;
152152
}
153153
}
154154

155-
if ($failedCount) {
156-
$io->err("Failed to requeue {$failedCount} jobs.");
155+
if ($failedCount !== 0) {
156+
$io->err(sprintf('Failed to requeue %d jobs.', $failedCount));
157157
}
158158

159-
if ($succeededCount) {
160-
$io->success("{$succeededCount} jobs requeued.");
159+
if ($succeededCount !== 0) {
160+
$io->success($succeededCount . ' jobs requeued.');
161161
}
162+
163+
return self::CODE_SUCCESS;
162164
}
163165
}

0 commit comments

Comments
 (0)