Skip to content

Commit 97d118b

Browse files
authored
Merge branch 'main' into introduce-migrator
2 parents c7e1397 + 0dbf292 commit 97d118b

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/BasicExecutor/CommandExecutor.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use ApacheBorys\Retry\Entity\Message;
88
use ApacheBorys\Retry\Interfaces\Executor;
99
use Psr\Log\LoggerInterface;
10+
use Throwable;
1011

1112
class CommandExecutor implements Executor
1213
{
@@ -75,8 +76,8 @@ public function handle(Message $message): bool
7576
sleep(1);
7677
}
7778

78-
proc_close($process);
79-
} catch (\Throwable $e) {
79+
$returnValue = proc_close($process);
80+
} catch (Throwable $e) {
8081
$this->rollbackEnvironmentVariables();
8182
if ($this->logger) {
8283
$this->logger->debug(
@@ -96,26 +97,30 @@ public function handle(Message $message): bool
9697
return true;
9798
}
9899

99-
public function compilePayload(\Throwable $exception, Config $config): array
100+
public function compilePayload(Throwable $exception, Config $config): array
100101
{
101102
$result = [];
102103

103104
foreach ($this->arguments as $argName => $argRegExp) {
104-
preg_match($argRegExp, $exception->getMessage(), $matches);
105-
if ($matches && isset($matches[0])) {
106-
$result[$argName] = $matches[0];
105+
$matches = [];
106+
107+
try {
108+
preg_match($argRegExp, $exception->getMessage(), $matches);
109+
} catch (Throwable $e) {
107110
}
111+
112+
$result[$argName] = count($matches) > 0 ? $matches[0] : $argRegExp;
108113
}
109114

110115
return $result;
111116
}
112117

113-
public function getCorrelationId(\Throwable $exception, Config $config): string
118+
public function getCorrelationId(Throwable $exception, Config $config): string
114119
{
115120
$id = getenv(self::ALIAS_FOR_CORRELATION_ID);
116121

117122
if (!$id) {
118-
$config->getTransport()->getNextId($exception, $config);
123+
$id = $config->getTransport()->getNextId($exception, $config);
119124
}
120125

121126
return (string) $id;

src/BasicExecutor/HttpExecutor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getCorrelationId(\Throwable $exception, Config $config): string
9797
$id = $_SERVER['HTTP_' . self::CID] ?? apache_request_headers()[self::CID] ?? null;
9898

9999
if (!$id) {
100-
$config->getTransport()->getNextId($exception, $config);
100+
$id = $config->getTransport()->getNextId($exception, $config);
101101
}
102102

103103
return (string) $id;

src/BasicTransport/FileTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function howManyTriesWasBefore(\Throwable $exception, Config $config): in
142142

143143
$correlationId = $config->getExecutor()->getCorrelationId($exception, $config);
144144

145-
$keysFromIndex = array_keys($this->fileIndexPosition[$correlationId]);
145+
$keysFromIndex = array_keys($this->fileIndexPosition[$correlationId] ?? []);
146146

147147
return isset($this->fileIndexPosition[$correlationId]) && count($keysFromIndex) > 0 ? max($keysFromIndex) : 0;
148148
}

0 commit comments

Comments
 (0)