Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 2.2.3 into 2.3.x #2393

Merged
merged 15 commits into from
Nov 30, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use spl_object_id instead of of spl_object_hash
  • Loading branch information
pepeh committed Nov 11, 2021
commit aeaa4a38d7c06648f1f500860a99de4b94ad43f7
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use function count;
use function get_class;
use function is_object;
use function spl_object_hash;

/**
* Trait with methods needed to implement PersistentCollectionInterface.
Expand Down Expand Up @@ -257,13 +256,9 @@ static function ($a, $b) {
/** {@inheritdoc} */
public function getDeletedDocuments()
{
$callback = static function ($val) {
return is_object($val) ? spl_object_hash($val) : $val;
};

$coll = $this->coll->toArray();
$loadedObjectsByOid = array_combine(array_map($callback, $this->snapshot), $this->snapshot);
$newObjectsByOid = array_combine(array_map($callback, $coll), $coll);
$loadedObjectsByOid = array_combine(array_map('spl_object_id', $this->snapshot), $this->snapshot);
$newObjectsByOid = array_combine(array_map('spl_object_id', $coll), $coll);

return array_values(array_diff_key($loadedObjectsByOid, $newObjectsByOid));
}
Expand All @@ -283,13 +278,9 @@ static function ($a, $b) {
/** {@inheritdoc} */
public function getInsertedDocuments()
{
$callback = static function ($val) {
return is_object($val) ? spl_object_hash($val) : $val;
};

$coll = $this->coll->toArray();
$newObjectsByOid = array_combine(array_map($callback, $coll), $coll);
$loadedObjectsByOid = array_combine(array_map($callback, $this->snapshot), $this->snapshot);
$newObjectsByOid = array_combine(array_map('spl_object_id', $coll), $coll);
$loadedObjectsByOid = array_combine(array_map('spl_object_id', $this->snapshot), $this->snapshot);

return array_values(array_diff_key($newObjectsByOid, $loadedObjectsByOid));
}
Expand Down