8000 Replace spl_object_hash by spl_object_id · symfony/symfony@0c8604c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0c8604c

Browse files
committed
Replace spl_object_hash by spl_object_id
1 parent 83bae94 commit 0c8604c

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(RequestStack $requestStack = null)
3333

3434
private function doInvoke(array|LogRecord $record): array|LogRecord
3535
{
36-
$hash = $this->requestStack && ($request = $this->requestStack->getCurrentRequest()) ? spl_object_hash($request) : '';
36+
$key = $this->requestStack && ($request = $this->requestStack->getCurrentRequest()) ? spl_object_id($request) : '';
3737

3838
$timestamp = $timestampRfc3339 = false;
3939
if ($record['datetime'] instanceof \DateTimeInterface) {
@@ -43,7 +43,7 @@ private function doInvoke(array|LogRecord $record): array|LogRecord
4343
$timestampRfc3339 = (new \DateTimeImmutable($record['datetime']))->format(\DateTimeInterface::RFC3339_EXTENDED);
4444
}
4545

46-
$this->records[$hash][] = [
46+
$this->records[$key][] = [
4747
'timestamp' => $timestamp,
4848
'timestamp_rfc3339' => $timestampRfc3339,
4949
'message' => $record['message'],
@@ -53,16 +53,16 @@ private function doInvoke(array|LogRecord $record): array|LogRecord
5353
'channel' => $record['channel'] ?? '',
5454
];
5555

56-
if (!isset($this->errorCount[$hash])) {
57-
$this->errorCount[$hash] = 0;
56+
if (!isset($this->errorCount[$key])) {
57+
$this->errorCount[$key] = 0;
5858
}
5959

6060
switch ($record['level']) {
6161
case Logger::ERROR:
6262
case Logger::CRITICAL:
6363
case Logger::ALERT:
6464
case Logger::EMERGENCY:
65-
++$this->errorCount[$hash];
65+
++$this->errorCount[$key];
6666
}
6767

6868
return $record;
@@ -71,7 +71,7 @@ private function doInvoke(array|LogRecord $record): array|LogRecord
7171
public function getLogs(Request $request = null): array
7272
{
7373
if (null !== $request) {
74-
return $this->records[spl_object_hash($request)] ?? [];
74+
return $this->records[spl_object_id($request)] ?? [];
7575
}
7676

7777
if (0 === \count($this->records)) {
@@ -84,7 +84,7 @@ public function getLogs(Request $request = null): array
8484
public function countErrors(Request $request = null): int
8585
{
8686
if (null !== $request) {
87-
return $this->errorCount[spl_object_hash($request)] ?? 0;
87+
return $this->errorCount[spl_object_id($request)] ?? 0;
8888
}
8989

9090
return array_sum($this->errorCount);

src/Symfony/Component/HttpKernel/Log/Logger.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function log($level, $messa 8000 ge, array $context = []): void
114114
public function getLogs(Request $request = null): array
115115
{
116116
if ($request) {
117-
return $this->logs[spl_object_hash($request)] ?? [];
117+
return $this->logs[spl_object_id($request)] ?? [];
118118
}
119119

120120
return array_merge(...array_values($this->logs));
@@ -123,7 +123,7 @@ public function getLogs(Request $request = null): array
123123
public function countErrors(Request $request = null): int
124124
{
125125
if ($request) {
126-
return $this->errorCount[spl_object_hash($request)] ?? 0;
126+
return $this->errorCount[spl_object_id($request)] ?? 0;
127127
}
128128

129129
return array_sum($this->errorCount);
@@ -165,9 +165,9 @@ private function format(string $level, string $message, array $context, bool $pr
165165
private function record($level, $message, array $context): void
166166
{
167167
$request = $this->requestStack->getCurrentRequest();
168-
$hash = $request ? spl_object_hash($request) : '';
168+
$key = $request ? spl_object_id($request) : '';
169169

170-
$this->logs[$hash][] = [
170+
$this->logs[$key][] = [
171171
'channel' => null,
172172
'context' => $context,
173173
'message' => $message,
@@ -177,13 +177,13 @@ private function record($level, $message, array $context): void
177177
'timestamp_rfc3339' => date(\DATE_RFC3339_EXTENDED),
178178
];
179179

180-
$this->errorCount[$hash] ??= 0;
180+
$this->errorCount[$key] ??= 0;
181181
switch ($level) {
182182
case LogLevel::ERROR:
183183
case LogLevel::CRITICAL:
184184
case LogLevel::ALERT:
185185
case LogLevel::EMERGENCY:
186-
++$this->errorCount[$hash];
186+
++$this->errorCount[$key];
187187
}
188188
}
189189
}

0 commit comments

Comments
 (0)
0