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 3.3.x up into 3.4.x #11724

Merged
merged 29 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0a49274
Update aggregate-fields.rst
d-ph Mar 8, 2024
129553d
Allow overriding association's cascade
malarzm Jul 11, 2024
e7efded
Update README.md
beberlei Oct 18, 2024
039b032
Inherit issue templates
greg0ire Oct 20, 2024
85fc950
Merge pull request #11691 from greg0ire/inherit-issue-templates
greg0ire Oct 20, 2024
4d821cb
Remove config.yml
greg0ire Oct 20, 2024
af54a16
Merge pull request #11692 from greg0ire/inherit-issue-templates
greg0ire Oct 20, 2024
021a9cc
UPGRADE: mention `SqlWalker` deprecations in 3.3 (#11693)
janedbal Oct 22, 2024
05f5486
Merge pull request #11549 from doctrine/feature/allow-overriding-cascade
greg0ire Oct 22, 2024
439b4da
Is not correctly generated sql when changed/switched sqlFilter parame…
dbannik Oct 22, 2024
3ca9529
Merge pull request #11694 from dbannik/Bug-join-sql-when-change-sqlFi…
greg0ire Oct 23, 2024
44fa8bb
Merge pull request #11344 from d-ph/patch-2
greg0ire Oct 24, 2024
9e2bfa8
Run tests against PostgreSQL 17 (#11697)
IndraGunawan Oct 25, 2024
4b03ec7
Refine Explanations of Doctrine orm Package Structure (#11710)
Speelwolf Nov 11, 2024
ff3ccff
Add `isEmpty()` method to the Extra Lazy Associations tutorial
acasademont Nov 13, 2024
d9aa6ef
Merge pull request #11716 from acasademont/patch-1
greg0ire Nov 14, 2024
43ce0be
lazy and eager collection refresh
goetas Sep 26, 2022
7d1b24f
attempt a fix
goetas Sep 26, 2022
486e406
Merge pull request #10065 from goetas/lazy-eager-collection-refresh
greg0ire Nov 14, 2024
4fbce94
Bump codecov/codecov-action from 4 to 5
dependabot[bot] Nov 18, 2024
ba11851
Merge pull request #11718 from doctrine/dependabot/github_actions/2.2…
greg0ire Nov 18, 2024
bb5b2a3
Ignore deprecation about StaticReflectionService
greg0ire Nov 18, 2024
f140651
Merge pull request #11719 from greg0ire/ignore-deprecation
greg0ire Nov 18, 2024
346c498
Fix `Events::onFlush` and `PostFlush()` documentation: events are alw…
lyrixx Nov 7, 2024
58ad1d9
Merge pull request #11709 from lyrixx/fix-event-doc
greg0ire Nov 18, 2024
8422a41
unitofwork.rst: php => PHP
k00ni Jul 22, 2024
82e2c98
Merge pull request #11556 from k00ni/patch-1
greg0ire Nov 19, 2024
2ff998d
Merge remote-tracking branch 'origin/2.20.x' into 3.3.x
greg0ire Nov 23, 2024
71e038c
Merge pull request #11723 from greg0ire/3.3.x
greg0ire Nov 23, 2024
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
4 changes: 2 additions & 2 deletions src/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -2473,13 +2473,13 @@ private function doRefresh($entity, array &$visited, ?int $lockMode = null): voi
throw ORMInvalidArgumentException::entityNotManaged($entity);
}

$this->cascadeRefresh($entity, $visited, $lockMode);

$this->getEntityPersister($class->name)->refresh(
array_combine($class->getIdentifierFieldNames(), $this->entityIdentifiers[$oid]),
$entity,
$lockMode
);

$this->cascadeRefresh($entity, $visited, $lockMode);
}

/**
Expand Down
161 changes: 161 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/LazyEagerCollectionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\Tests\OrmFunctionalTestCase;

class LazyEagerCollectionTest extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();

$this->createSchemaForModels(
LazyEagerCollectionUser::class,
LazyEagerCollectionAddress::class,
LazyEagerCollectionPhone::class
);
}

public function testRefreshRefreshesBothLazyAndEagerCollections(): void
{
$user = new LazyEagerCollectionUser();
$user->data = 'Guilherme';

$ph = new LazyEagerCollectionPhone();
$ph->data = '12345';
$user->addPhone($ph);

$ad = new LazyEagerCollectionAddress();
$ad->data = '6789';
$user->addAddress($ad);

$this->_em->persist($user);
$this->_em->persist($ad);
$this->_em->persist($ph);
$this->_em->flush();
$this->_em->clear();

$user = $this->_em->find(LazyEagerCollectionUser::class, $user->id);
$ph = $user->phones[0];
$ad = $user->addresses[0];

$ph->data = 'abc';
$ad->data = 'def';

$this->_em->refresh($user);

self::assertSame('12345', $ph->data);
self::assertSame('6789', $ad->data);
}
}

/**
* @Entity
*/
class LazyEagerCollectionUser
{
/**
* @var int
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public $id;

/**
* @var string
* @Column(type="string", length=255)
*/
public $data;

/**
* @ORM\OneToMany(targetEntity="LazyEagerCollectionPhone", cascade={"refresh"}, fetch="EAGER", mappedBy="user")
*
* @var LazyEagerCollectionPhone[]
*/
public $phones;

/**
* @ORM\OneToMany(targetEntity="LazyEagerCollectionAddress", cascade={"refresh"}, mappedBy="user")
*
* @var LazyEagerCollectionAddress[]
*/
public $addresses;

public function __construct()
{
$this->addresses = new ArrayCollection();
$this->phones = new ArrayCollection();
}

public function addPhone(LazyEagerCollectionPhone $phone): void
{
$phone->user = $this;
$this->phones[] = $phone;
}

public function addAddress(LazyEagerCollectionAddress $address): void
{
$address->user = $this;
$this->addresses[] = $address;
}
}

/** @Entity */
class LazyEagerCollectionPhone
{
/**
* @var int
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public $id;

/**
* @var string
* @Column(type="string", length=255)
*/
public $data;

/**
* @ORM\ManyToOne(targetEntity="LazyEagerCollectionUser", inversedBy="phones")
*
* @var LazyEagerCollectionUser
*/
public $user;
}

/** @Entity */
class LazyEagerCollectionAddress
{
/**
* @var int
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public $id;

/**
* @var string
* @Column(type="string", length=255)
*/
public $data;

/**
* @ORM\ManyToOne(targetEntity="LazyEagerCollectionUser", inversedBy="addresses")
*
* @var LazyEagerCollectionUser
*/
public $user;
}
Loading