Skip to content

Commit 2cd3dae

Browse files
authored
Merge pull request #140 from cakephp/1x-merge
1x merge
2 parents 74b1a89 + 0db6d31 commit 2cd3dae

File tree

16 files changed

+180
-55
lines changed

16 files changed

+180
-55
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name: CI
33
on:
44
push:
55
branches:
6-
- master
7-
- cake5
6+
- 2.x
87
pull_request:
98
branches:
109
- '*'

.github/workflows/deploy_docs_1x.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ name: 'deploy_docs_1x'
44
on:
55
push:
66
branches:
7-
- master
7+
- 1.x
88
workflow_dispatch:
99

1010
jobs:
1111
deploy:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Cloning repo
15-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0
1818

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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)
66
[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/queue.svg?style=flat-square)](https://packagist.org/packages/cakephp/queue)
77

8-
This is a Queue system for CakePHP 4.
8+
This is a Queue system for CakePHP.
99

1010
The plugin consists of a CakePHP shell wrapper and Queueing libraries for the [php-queue](https://php-enqueue.github.io) queue library.
1111

@@ -34,7 +34,7 @@ bin/cake plugin load Cake/Queue
3434

3535
Or you can manually add the loading statement in the **src/Application.php** file of your application:
3636
```php
37-
public function bootstrap()
37+
public function bootstrap(): void
3838
{
3939
parent::bootstrap();
4040
$this->addPlugin('Cake/Queue');

composer.json

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
{
22
"name": "cakephp/queue",
33
"description": "Queue plugin for CakePHP",
4-
"keywords": ["cakephp", "queue"],
5-
"homepage": "https://github.com/cakephp/queue",
6-
"type": "cakephp-plugin",
74
"license": "MIT",
5+
"type": "cakephp-plugin",
6+
"keywords": [
7+
"cakephp",
8+
"queue"
9+
],
810
"authors": [
911
{
1012
"name": "CakePHP Community",
1113
"homepage": "https://github.com/cakephp/queue/graphs/contributors"
1214
}
1315
],
16+
"homepage": "https://github.com/cakephp/queue",
1417
"support": {
1518
"issues": "https://github.com/cakephp/queue/issues",
1619
"forum": "https://stackoverflow.com/tags/cakephp",
@@ -29,21 +32,27 @@
2932
"enqueue/fs": "^0.10",
3033
"phpunit/phpunit": "^10.1.0"
3134
},
35+
"suggest": {
36+
"cakephp/bake": "Required if you want to generate jobs.",
37+
"cakephp/migrations": "Needed for running the migrations necessary for using Failed Jobs."
38+
},
3239
"autoload": {
3340
"psr-4": {
3441
"Cake\\Queue\\": "src/"
3542
}
3643
},
3744
"autoload-dev": {
3845
"psr-4": {
39-
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/",
4046
"Cake\\Queue\\Test\\": "tests/",
47+
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/",
4148
"TestApp\\": "tests/test_app/src/"
4249
}
4350
},
44-
"suggest": {
45-
"cakephp/bake": "Required if you want to generate jobs.",
46-
"cakephp/migrations": "Needed for running the migrations necessary for using Failed Jobs."
51+
"config": {
52+
"allow-plugins": {
53+
"dealerdirect/phpcodesniffer-composer-installer": true
54+
},
55+
"sort-packages": true
4756
},
4857
"scripts": {
4958
"check": [
@@ -63,11 +72,5 @@
6372
"stan-setup": "phive install",
6473
"test": "phpunit",
6574
"test-coverage": "phpunit --coverage-clover=clover.xml"
66-
},
67-
"config": {
68-
"sort-packages": true,
69-
"allow-plugins": {
70-
"dealerdirect/phpcodesniffer-composer-installer": true
71-
}
7275
}
7376
}

docs/config/all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
# The GitHub branch name for this version of the docs
3434
# for edit links to point at.
35-
branch = 'master'
35+
branch = '1.x'
3636

3737
# Current version being built
3838
version = '2.x'

docs/en/index.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,15 @@ queue jobs, you can use the ``QueueTransport``. In your application's
299299

300300
return [
301301
// ... other configuration
302-
'EmailTransport' => [
302+
'EmailTransport' => [
303+
'default' => [
304+
'className' => MailTransport::class,
305+
// Configuration for MailTransport.
306+
]
303307
'queue' => [
304308
'className' => QueueTransport::class,
305-
// The transport to use inside the queue job.
306-
'transport' => MailTransport::class,
307-
'config' => [
308-
// Configuration for MailTransport.
309-
]
309+
// The transport name to use inside the queue job.
310+
'transport' => 'default',
310311
]
311312
],
312313
'Email' => [
@@ -320,7 +321,7 @@ queue jobs, you can use the ``QueueTransport``. In your application's
320321

321322
With this configuration in place, any time you send an email with the ``default``
322323
email profile CakePHP will generate a queue message. Once that queue message is
323-
processed the ``MailTransport`` will be used to deliver the email messages.
324+
processed the default ``MailTransport`` will be used to deliver the email messages.
324325

325326
Run the worker
326327
==============

phpstan.neon

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
parameters:
2-
level: 6
2+
level: 8
33
checkMissingIterableValueType: false
44
checkGenericClassInNonGenericObjectType: false
55
treatPhpDocTypesAsCertain: false
66
bootstrapFiles:
77
- tests/bootstrap.php
88
paths:
99
- src/
10+
ignoreErrors:
11+
- '#Parameter \#1 \$callback of static method Closure::fromCallable\(\) expects callable\(\): mixed, array\{mixed, string\} given.#'
12+
- '#Method Cake\\Queue\\Job\\Message::getTarget\(\) should return array\{class-string, string\} but returns non-empty-array.#'

psalm-baseline.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<files psalm-version="dev-master@">
3-
<file src="src/Model/Table/FailedJobsTable.php">
4-
<LessSpecificImplementedReturnType occurrences="4">
5-
<code>\Cake\Queue\Model\Entity\FailedJob[]|\Cake\Datasource\ResultSetInterface</code>
6-
<code>\Cake\Queue\Model\Entity\FailedJob[]|\Cake\Datasource\ResultSetInterface</code>
7-
<code>\Cake\Queue\Model\Entity\FailedJob[]|\Cake\Datasource\ResultSetInterface|false</code>
8-
<code>\Cake\Queue\Model\Entity\FailedJob[]|\Cake\Datasource\ResultSetInterface|false</code>
9-
</LessSpecificImplementedReturnType>
10-
</file>
113
</files>

src/Job/Message.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public function getCallable(): Closure
108108
*/
109109
public function getTarget(): array
110110
{
111+
/** @var array|null $target */
111112
$target = $this->parsedBody['class'] ?? null;
112113

113114
if (!is_array($target) || count($target) !== 2) {
@@ -161,7 +162,7 @@ public function getMaxAttempts(): ?int
161162
*/
162163
public function __toString(): string
163164
{
164-
return json_encode($this);
165+
return (string)json_encode($this);
165166
}
166167

167168
/**

src/Job/SendMailJob.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
use Cake\Log\Log;
2020
use Cake\Mailer\AbstractTransport;
21-
use Cake\Mailer\Message as CakeMessage;
21+
use Cake\Mailer\Message as MailerMessage;
22+
use Cake\Mailer\TransportFactory;
2223
use Cake\Queue\Queue\Processor;
2324
use Exception;
2425
use InvalidArgumentException;
@@ -40,7 +41,7 @@ public function execute(Message $message): ?string
4041
/** @var \Cake\Mailer\AbstractTransport $transport */
4142
$transport = $this->getTransport($transportClassName, $config);
4243

43-
$emailMessage = new CakeMessage();
44+
$emailMessage = new MailerMessage();
4445
$data = json_decode($message->getArgument('emailMessage'), true);
4546
if (!is_array($data)) {
4647
throw new InvalidArgumentException('Email Message cannot be decoded.');
@@ -68,12 +69,15 @@ public function execute(Message $message): ?string
6869
*/
6970
protected function getTransport(string $transportClassName, array $config): AbstractTransport
7071
{
72+
if ($transportClassName === '') {
73+
throw new InvalidArgumentException('Transport class name is empty.');
74+
}
75+
7176
if (
72-
empty($transportClassName) ||
7377
!class_exists($transportClassName) ||
7478
!method_exists($transportClassName, 'send')
7579
) {
76-
throw new InvalidArgumentException(sprintf('Transport class name is not valid: %s', $transportClassName));
80+
return TransportFactory::get($transportClassName);
7781
}
7882

7983
$transport = new $transportClassName($config);

0 commit comments

Comments
 (0)