Skip to content

Commit 6aef381

Browse files
authored
Merge branch 'main' into bug/fix-bugs
2 parents e33a835 + 0dbf292 commit 6aef381

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
{
@@ -74,8 +75,8 @@ public function handle(Message $message): bool
7475
sleep(1);
7576
}
7677

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

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

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

109114
return $result;
110115
}
111116

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

116121
if (!$id) {
117-
$config->getTransport()->getNextId($exception, $config);
122+
$id = $config->getTransport()->getNextId($exception, $config);
118123
}
119124

120125
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
@@ -137,7 +137,7 @@ public function howManyTriesWasBefore(\Throwable $exception, Config $config): in
137137

138138
$correlationId = $config->getExecutor()->getCorrelationId($exception, $config);
139139

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

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

0 commit comments

Comments
 (0)