Skip to content

Commit 5b49a51

Browse files
authored
Replace spl_object_hash with spl_object_id (#2738)
1 parent 13fccf6 commit 5b49a51

File tree

7 files changed

+130
-130
lines changed

7 files changed

+130
-130
lines changed

lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
use function is_object;
6262
use function is_scalar;
6363
use function is_string;
64-
use function spl_object_hash;
64+
use function spl_object_id;
6565
use function sprintf;
6666
use function strpos;
6767
use function strtolower;
@@ -96,14 +96,14 @@ final class DocumentPersister
9696
/**
9797
* Array of queued inserts for the persister to insert.
9898
*
99-
* @var array<string, object>
99+
* @var array<int, object>
100100
*/
101101
private array $queuedInserts = [];
102102

103103
/**
104104
* Array of queued inserts for the persister to insert.
105105
*
106-
* @var array<string, object>
106+
* @var array<int, object>
107107
*/
108108
private array $queuedUpserts = [];
109109

@@ -136,15 +136,15 @@ public function __construct(
136136
$this->bucket = $dm->getDocumentBucket($class->name);
137137
}
138138

139-
/** @return array<string, object> */
139+
/** @return array<int, object> */
140140
public function getInserts(): array
141141
{
142142
return $this->queuedInserts;
143143
}
144144

145145
public function isQueuedForInsert(object $document): bool
146146
{
147-
return isset($this->queuedInserts[spl_object_hash($document)]);
147+
return isset($this->queuedInserts[spl_object_id($document)]);
148148
}
149149

150150
/**
@@ -153,18 +153,18 @@ public function isQueuedForInsert(object $document): bool
153153
*/
154154
public function addInsert(object $document): void
155155
{
156-
$this->queuedInserts[spl_object_hash($document)] = $document;
156+
$this->queuedInserts[spl_object_id($document)] = $document;
157157
}
158158

159-
/** @return array<string, object> */
159+
/** @return array<int, object> */
160160
public function getUpserts(): array
161161
{
162162
return $this->queuedUpserts;
163163
}
164164

165165
public function isQueuedForUpsert(object $document): bool
166166
{
167-
return isset($this->queuedUpserts[spl_object_hash($document)]);
167+
return isset($this->queuedUpserts[spl_object_id($document)]);
168168
}
169169

170170
/**
@@ -173,7 +173,7 @@ public function isQueuedForUpsert(object $document): bool
173173
*/
174174
public function addUpsert(object $document): void
175175
{
176-
$this->queuedUpserts[spl_object_hash($document)] = $document;
176+
$this->queuedUpserts[spl_object_id($document)] = $document;
177177
}
178178

179179
/**

lib/Doctrine/ODM/MongoDB/Repository/AbstractRepositoryFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Doctrine\Persistence\ObjectRepository;
1212

1313
use function is_a;
14-
use function spl_object_hash;
14+
use function spl_object_id;
1515

1616
/**
1717
* Abstract factory for creating document repositories.
@@ -35,7 +35,7 @@ abstract class AbstractRepositoryFactory implements RepositoryFactory
3535
public function getRepository(DocumentManager $documentManager, string $documentName): ObjectRepository
3636
{
3737
$metadata = $documentManager->getClassMetadata($documentName);
38-
$hashKey = $metadata->getName() . spl_object_hash($documentManager);
38+
$hashKey = $metadata->getName() . '_' . spl_object_id($documentManager);
3939

4040
if (isset($this->repositoryList[$hashKey])) {
4141
return $this->repositoryList[$hashKey];

0 commit comments

Comments
 (0)