Skip to content

Commit 295dbdb

Browse files
dereuromarkwww-data
authored andcommitted
Auto-fix CS - CS master branch
1 parent cb2221a commit 295dbdb

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

src/Controller/Admin/QueueProcessesController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Controller\AppController;
77
use Cake\Core\Configure;
88
use Exception;
9+
use const SIGTERM;
910

1011
/**
1112
* @property \Queue\Model\Table\QueueProcessesTable $QueueProcesses
@@ -112,7 +113,7 @@ public function delete(?int $id = null, ?int $sig = null) {
112113
$queueProcess = $this->QueueProcesses->get($id);
113114

114115
if (!Configure::read('Queue.multiserver')) {
115-
$this->QueueProcesses->terminateProcess($queueProcess->pid, $sig ?: \SIGTERM);
116+
$this->QueueProcesses->terminateProcess($queueProcess->pid, $sig ?: SIGTERM);
116117
}
117118

118119
if ($this->QueueProcesses->delete($queueProcess)) {

src/Model/Table/QueueProcessesTable.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Cake\Validation\Validator;
1212
use Queue\Model\ProcessEndingException;
1313
use Queue\Queue\Config;
14+
use const SIGTERM;
15+
use const SIGUSR1;
1416

1517
/**
1618
* QueueProcesses Model
@@ -298,7 +300,7 @@ public function terminateProcess(string $pid, int $sig = 0): void {
298300

299301
// In the Windows operating system the SIGTERM constant is not defined
300302
if (!$sig && defined('SIGTERM')) {
301-
$sig = \SIGTERM;
303+
$sig = SIGTERM;
302304
}
303305

304306
$killed = false;
@@ -327,7 +329,7 @@ public function wakeUpWorkers(): void {
327329
foreach ($processes as $process) {
328330
$pid = (int)$process->pid;
329331
if ($pid > 0) {
330-
posix_kill($pid, \SIGUSR1);
332+
posix_kill($pid, SIGUSR1);
331333
}
332334
}
333335
}

src/Queue/Processor.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
use Queue\Model\Table\QueueProcessesTable;
2222
use RuntimeException;
2323
use Throwable;
24+
use const SIGINT;
25+
use const SIGQUIT;
26+
use const SIGTERM;
27+
use const SIGTSTP;
28+
use const SIGUSR1;
2429

2530
declare(ticks=1);
2631

@@ -123,16 +128,16 @@ public function run(array $args): int {
123128
gc_enable();
124129
}
125130
if (function_exists('pcntl_signal')) {
126-
pcntl_signal(\SIGTERM, [&$this, 'exit']);
127-
pcntl_signal(\SIGINT, [&$this, 'abort']);
128-
pcntl_signal(\SIGTSTP, [&$this, 'abort']);
129-
pcntl_signal(\SIGQUIT, [&$this, 'abort']);
131+
pcntl_signal(SIGTERM, [&$this, 'exit']);
132+
pcntl_signal(SIGINT, [&$this, 'abort']);
133+
pcntl_signal(SIGTSTP, [&$this, 'abort']);
134+
pcntl_signal(SIGQUIT, [&$this, 'abort']);
130135
if (Configure::read('Queue.canInterruptSleep')) {
131136
// Defining a signal handler here will make the worker wake up
132137
// from its sleep() when SIGUSR1 is received. Since waking it
133138
// up is all we need, there is no further code to execute,
134139
// hence the empty function.
135-
pcntl_signal(\SIGUSR1, function (): void {
140+
pcntl_signal(SIGUSR1, function (): void {
136141
});
137142
}
138143
}

tests/TestCase/Model/Table/QueueProcessesTableTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Cake\ORM\TableRegistry;
99
use Cake\TestSuite\TestCase;
1010
use Queue\Model\Table\QueueProcessesTable;
11+
use const SIG_DFL;
12+
use const SIGUSR1;
1113

1214
/**
1315
* Queue\Model\Table\QueueProcessesTable Test Case
@@ -132,15 +134,15 @@ public function testWakeUpWorkersSendsSigUsr1() {
132134
$queuedProcessesTable->saveOrFail($queuedProcess);
133135

134136
$gotSignal = false;
135-
pcntl_signal(\SIGUSR1, function () use (&$gotSignal) {
137+
pcntl_signal(SIGUSR1, function () use (&$gotSignal) {
136138
$gotSignal = true;
137139
});
138140

139141
$queuedProcessesTable->wakeUpWorkers();
140142
pcntl_signal_dispatch();
141143

142144
$this->assertTrue($gotSignal);
143-
pcntl_signal(\SIGUSR1, \SIG_DFL);
145+
pcntl_signal(SIGUSR1, SIG_DFL);
144146
}
145147

146148
/**

tests/TestCase/Queue/ProcessorTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use RuntimeException;
2121
use Shim\TestSuite\ConsoleOutput;
2222
use Shim\TestSuite\TestTrait;
23+
use const SIGTERM;
2324

2425
class ProcessorTest extends TestCase {
2526

@@ -221,7 +222,7 @@ public function testWorkerTimeoutHandling() {
221222
}
222223

223224
// Call the exit method which handles SIGTERM signal (timeout scenario)
224-
$this->invokeMethod($processor, 'exit', [\SIGTERM]);
225+
$this->invokeMethod($processor, 'exit', [SIGTERM]);
225226

226227
// Check that exit flag was set
227228
if ($reflection->hasProperty('exit')) {
@@ -267,7 +268,7 @@ public function testWorkerTimeoutHandlingIntegration() {
267268
}
268269

269270
// Call the exit method which handles SIGTERM signal (timeout scenario)
270-
$this->invokeMethod($processor, 'exit', [\SIGTERM]);
271+
$this->invokeMethod($processor, 'exit', [SIGTERM]);
271272

272273
// Reload the job to check its status
273274
$updatedJob = $QueuedJobs->get($job->id);

0 commit comments

Comments
 (0)