Skip to content

Commit 95d434d

Browse files
derrabusandrew-dembolsavmicbeberlei
authored
Merge 2.10.x into 2.11.x (#9276)
* Docs: consistency for FQCN, spacing, etc (#9232) * Docs: consistent spacing, consistent array-style, consistent FQCN, avoid double escaped slashes, avoid double quotes if not necessary * Docs: use special note block instead of markdown-based style * Docs: Quote FQCN in table with backticks to be compatible with all render engines * Drop all mentions API doc - it is not available anymore * Add missed FQCN for code snippets * Revert "Fix SchemaValidator with abstract child class in discriminator map (#9096)" (#9262) This reverts commit bbb68d0. * [docs] Fix wording for attributes=>parameters. (#9265) Co-authored-by: Andrii Dembitskyi <andrew.dembitskiy@gmail.com> Co-authored-by: olsavmic <molsavsky1@gmail.com> Co-authored-by: Benjamin Eberlei <kontakt@beberlei.de>
2 parents 70c651e + fa2b52c commit 95d434d

File tree

3 files changed

+46
-96
lines changed

3 files changed

+46
-96
lines changed

docs/en/reference/second-level-cache.rst

+45-55
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,31 @@ Each cache region resides in a specific cache namespace and has its own lifetime
3131
Notice that when caching collection and queries only identifiers are stored.
3232
The entity values will be stored in its own region
3333

34-
Something like below for an entity region :
34+
Something like below for an entity region:
3535

3636
.. code-block:: php
3737
3838
<?php
3939
[
40-
'region_name:entity_1_hash' => ['id'=> 1, 'name' => 'FooBar', 'associationName'=>null],
41-
'region_name:entity_2_hash' => ['id'=> 2, 'name' => 'Foo', 'associationName'=>['id'=>11]],
42-
'region_name:entity_3_hash' => ['id'=> 3, 'name' => 'Bar', 'associationName'=>['id'=>22]]
40+
'region_name:entity_1_hash' => ['id' => 1, 'name' => 'FooBar', 'associationName' => null],
41+
'region_name:entity_2_hash' => ['id' => 2, 'name' => 'Foo', 'associationName' => ['id' => 11]],
42+
'region_name:entity_3_hash' => ['id' => 3, 'name' => 'Bar', 'associationName' => ['id' => 22]]
4343
];
4444
4545
4646
If the entity holds a collection that also needs to be cached.
47-
An collection region could look something like :
47+
An collection region could look something like:
4848

4949
.. code-block:: php
5050
5151
<?php
5252
[
53-
'region_name:entity_1_coll_assoc_name_hash' => ['ownerId'=> 1, 'list' => [1, 2, 3]],
54-
'region_name:entity_2_coll_assoc_name_hash' => ['ownerId'=> 2, 'list' => [2, 3]],
55-
'region_name:entity_3_coll_assoc_name_hash' => ['ownerId'=> 3, 'list' => [2, 4]]
53+
'region_name:entity_1_coll_assoc_name_hash' => ['ownerId' => 1, 'list' => [1, 2, 3]],
54+
'region_name:entity_2_coll_assoc_name_hash' => ['ownerId' => 2, 'list' => [2, 3]],
55+
'region_name:entity_3_coll_assoc_name_hash' => ['ownerId' => 3, 'list' => [2, 4]]
5656
];
5757
58-
A query region might be something like :
58+
A query region might be something like:
5959

6060
.. code-block:: php
6161
@@ -93,8 +93,6 @@ Cache region
9393
``Doctrine\ORM\Cache\Region`` defines a contract for accessing a particular
9494
cache region.
9595

96-
`See API Doc <https://www.doctrine-project.org/api/orm/current/Doctrine/ORM/Cache/Region.html>`_.
97-
9896
Concurrent cache region
9997
~~~~~~~~~~~~~~~~~~~~~~~
10098

@@ -105,17 +103,13 @@ If you want to use an ``READ_WRITE`` cache, you should consider providing your o
105103

106104
``Doctrine\ORM\Cache\ConcurrentRegion`` defines a contract for concurrently managed data region.
107105

108-
`See API Doc <https://www.doctrine-project.org/api/orm/current/Doctrine/ORM/Cache/ConcurrentRegion.html>`_.
109-
110106
Timestamp region
111107
~~~~~~~~~~~~~~~~
112108

113109
``Doctrine\ORM\Cache\TimestampRegion``
114110

115111
Tracks the timestamps of the most recent updates to particular entity.
116112

117-
`See API Doc <https://www.doctrine-project.org/api/orm/current/Doctrine/ORM/Cache/TimestampRegion.html>`_.
118-
119113
.. _reference-second-level-cache-mode:
120114

121115
Caching mode
@@ -132,7 +126,7 @@ Caching mode
132126

133127
* Read Write Cache doesn’t employ any locks but can do reads, inserts, updates and deletes.
134128
* Good if the application needs to update data rarely.
135-
129+
136130

137131
* ``READ_WRITE``
138132

@@ -147,21 +141,21 @@ Built-in cached persisters
147141

148142
Cached persisters are responsible to access cache regions.
149143

150-
+-----------------------+-------------------------------------------------------------------------------------------+
151-
| Cache Usage | Persister |
152-
+=======================+===========================================================================================+
153-
| READ_ONLY | Doctrine\\ORM\\Cache\\Persister\\Entity\\ReadOnlyCachedEntityPersister |
154-
+-----------------------+-------------------------------------------------------------------------------------------+
155-
| READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Entity\\ReadWriteCachedEntityPersister |
156-
+-----------------------+-------------------------------------------------------------------------------------------+
157-
| NONSTRICT_READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Entity\\NonStrictReadWriteCachedEntityPersister |
158-
+-----------------------+-------------------------------------------------------------------------------------------+
159-
| READ_ONLY | Doctrine\\ORM\\Cache\\Persister\\Collection\\ReadOnlyCachedCollectionPersister |
160-
+-----------------------+-------------------------------------------------------------------------------------------+
161-
| READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Collection\\ReadWriteCachedCollectionPersister |
162-
+-----------------------+-------------------------------------------------------------------------------------------+
163-
| NONSTRICT_READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Collection\\NonStrictReadWriteCachedCollectionPersister |
164-
+-----------------------+-------------------------------------------------------------------------------------------+
144+
+-----------------------+------------------------------------------------------------------------------------------+
145+
| Cache Usage | Persister |
146+
+=======================+==========================================================================================+
147+
| READ_ONLY | ``Doctrine\ORM\Cache\Persister\Entity\ReadOnlyCachedEntityPersister`` |
148+
+-----------------------+------------------------------------------------------------------------------------------+
149+
| READ_WRITE | ``Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister`` |
150+
+-----------------------+------------------------------------------------------------------------------------------+
151+
| NONSTRICT_READ_WRITE | ``Doctrine\ORM\Cache\Persister\Entity\NonStrictReadWriteCachedEntityPersister`` |
152+
+-----------------------+------------------------------------------------------------------------------------------+
153+
| READ_ONLY | ``Doctrine\ORM\Cache\Persister\Collection\ReadOnlyCachedCollectionPersister`` |
154+
+-----------------------+------------------------------------------------------------------------------------------+
155+
| READ_WRITE | ``Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister`` |
156+
+-----------------------+------------------------------------------------------------------------------------------+
157+
| NONSTRICT_READ_WRITE | ``Doctrine\ORM\Cache\Persister\Collection\NonStrictReadWriteCachedCollectionPersister`` |
158+
+-----------------------+------------------------------------------------------------------------------------------+
165159

166160
Configuration
167161
-------------
@@ -172,7 +166,7 @@ Enable Second Level Cache
172166
~~~~~~~~~~~~~~~~~~~~~~~~~
173167

174168
To enable the second-level-cache, you should provide a cache factory.
175-
``\Doctrine\ORM\Cache\DefaultCacheFactory`` is the default implementation.
169+
``Doctrine\ORM\Cache\DefaultCacheFactory`` is the default implementation.
176170

177171
.. code-block:: php
178172
@@ -196,7 +190,7 @@ Cache Factory
196190

197191
Cache Factory is the main point of extension.
198192

199-
It allows you to provide a specific implementation of the following components :
193+
It allows you to provide a specific implementation of the following components:
200194

201195
``QueryCache``
202196
stores and retrieves query cache results.
@@ -209,8 +203,6 @@ It allows you to provide a specific implementation of the following components :
209203
``CollectionHydrator``
210204
transforms collections into cache entries and cache entries into collections
211205

212-
`See API Doc <https://www.doctrine-project.org/api/orm/current/Doctrine/ORM/Cache/DefaultCacheFactory.html>`_.
213-
214206
Region Lifetime
215207
~~~~~~~~~~~~~~~
216208

@@ -234,7 +226,7 @@ Cache Log
234226
~~~~~~~~~
235227
By providing a cache logger you should be able to get information about all cache operations such as hits, misses and puts.
236228

237-
``\Doctrine\ORM\Cache\Logging\StatisticsCacheLogger`` is a built-in implementation that provides basic statistics.
229+
``Doctrine\ORM\Cache\Logging\StatisticsCacheLogger`` is a built-in implementation that provides basic statistics.
238230

239231
.. code-block:: php
240232
@@ -269,12 +261,9 @@ By providing a cache logger you should be able to get information about all cach
269261
$logger->getMissCount();
270262
271263
If you want to get more information you should implement
272-
``\Doctrine\ORM\Cache\Logging\CacheLogger`` and collect
264+
``Doctrine\ORM\Cache\Logging\CacheLogger`` and collect
273265
all the information you want.
274266

275-
`See API Doc <https://www.doctrine-project.org/api/orm/current/Doctrine/ORM/Cache/Logging/CacheLogger.html>`_.
276-
277-
278267
Entity cache definition
279268
-----------------------
280269
* Entity cache configuration allows you to define the caching strategy and region for an entity.
@@ -330,8 +319,8 @@ level cache region.
330319
Country:
331320
type: entity
332321
cache:
333-
usage : READ_ONLY
334-
region : my_entity_region
322+
usage: READ_ONLY
323+
region: my_entity_region
335324
id:
336325
id:
337326
type: integer
@@ -401,7 +390,7 @@ It caches the primary keys of association and cache each element will be cached
401390
</id>
402391
403392
<field name="name" type="string" column="name"/>
404-
393+
405394
<many-to-one field="country" target-entity="Country">
406395
<cache usage="NONSTRICT_READ_WRITE" />
407396
@@ -421,7 +410,7 @@ It caches the primary keys of association and cache each element will be cached
421410
State:
422411
type: entity
423412
cache:
424-
usage : NONSTRICT_READ_WRITE
413+
usage: NONSTRICT_READ_WRITE
425414
id:
426415
id:
427416
type: integer
@@ -439,17 +428,18 @@ It caches the primary keys of association and cache each element will be cached
439428
country_id:
440429
referencedColumnName: id
441430
cache:
442-
usage : NONSTRICT_READ_WRITE
431+
usage: NONSTRICT_READ_WRITE
443432
444433
oneToMany:
445434
cities:
446435
targetEntity:City
447436
mappedBy: state
448437
cache:
449-
usage : NONSTRICT_READ_WRITE
438+
usage: NONSTRICT_READ_WRITE
450439
440+
.. note::
451441

452-
> Note: for this to work, the target entity must also be marked as cacheable.
442+
for this to work, the target entity must also be marked as cacheable.
453443

454444
Cache usage
455445
~~~~~~~~~~~
@@ -466,8 +456,8 @@ Basic entity cache
466456
467457
$country1 = $em->find('Country', 1); // Retrieve item from cache
468458
469-
$country1->setName("New Name");
470-
459+
$country1->setName('New Name');
460+
471461
$em->flush(); // Hit database to update the row and update cache
472462
473463
$em->clear(); // Clear entity manager
@@ -492,7 +482,7 @@ Association cache
492482
$state = $em->find('State', 1);
493483
494484
// Hit database to update the row and update cache entry
495-
$state->setName("New Name");
485+
$state->setName('New Name');
496486
$em->persist($state);
497487
$em->flush();
498488
@@ -550,7 +540,7 @@ The query cache stores the results of the query but as identifiers, entity value
550540
->setCacheable(true)
551541
->getResult();
552542
553-
$em->clear()
543+
$em->clear();
554544
555545
// Check if query result is valid and load entities from cache
556546
$result2 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name')
@@ -573,7 +563,7 @@ The Cache Mode controls how a particular query interacts with the second-level c
573563
/* @var $em \Doctrine\ORM\EntityManager */
574564
// Will refresh the query cache and all entities the cache as it reads from the database.
575565
$result1 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name')
576-
->setCacheMode(Cache::MODE_GET)
566+
->setCacheMode(\Doctrine\ORM\Cache::MODE_GET)
577567
->setCacheable(true)
578568
->getResult();
579569
@@ -597,7 +587,7 @@ Execute the ``UPDATE`` and invalidate ``all cache entries`` using ``Query::HINT_
597587
<?php
598588
// Execute and invalidate
599589
$this->_em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
600-
->setHint(Query::HINT_CACHE_EVICT, true)
590+
->setHint(\Doctrine\ORM\Query::HINT_CACHE_EVICT, true)
601591
->execute();
602592
603593
@@ -712,11 +702,11 @@ For performance reasons the cache API does not extract from composite primary ke
712702
$article = $em->find('Article', $article);
713703
714704
// Supported
715-
$id = array('source' => 1, 'target' => 2);
705+
$id = ['source' => 1, 'target' => 2];
716706
$reference = $em->find('Reference', $id);
717707
718708
// NOT Supported
719-
$id = array('source' => new Article(1), 'target' => new Article(2));
709+
$id = ['source' => new Article(1), 'target' => new Article(2)];
720710
$reference = $em->find('Reference', $id);
721711
722712
Distributed environments

lib/Doctrine/ORM/Tools/SchemaValidator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function validateClass(ClassMetadataInfo $class)
239239
}
240240
}
241241

242-
if (! $class->isInheritanceTypeNone() && ! $class->isRootEntity() && ! $class->reflClass->isAbstract() && ! $class->isMappedSuperclass && array_search($class->name, $class->discriminatorMap, true) === false) {
242+
if (! $class->isInheritanceTypeNone() && ! $class->isRootEntity() && ! $class->isMappedSuperclass && array_search($class->name, $class->discriminatorMap, true) === false) {
243243
$ce[] = "Entity class '" . $class->name . "' is part of inheritance hierarchy, but is " .
244244
"not mapped in the root entity '" . $class->rootEntityName . "' discriminator map. " .
245245
'All subclasses must be listed in the discriminator map.';

tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php

-40
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,6 @@ public function testMappedSuperclassNotPresentInDiscriminator(): void
225225

226226
$this->assertEquals([], $ce);
227227
}
228-
229-
/**
230-
* @group 9095
231-
*/
232-
public function testAbstractChildClassNotPresentInDiscriminator(): void
233-
{
234-
$class1 = $this->em->getClassMetadata(Issue9095AbstractChild::class);
235-
$ce = $this->validator->validateClass($class1);
236-
237-
$this->assertEquals([], $ce);
238-
}
239228
}
240229

241230
/**
@@ -267,35 +256,6 @@ class ChildEntity extends MappedSuperclassEntity
267256
{
268257
}
269258

270-
/**
271-
* @Entity
272-
* @InheritanceType("SINGLE_TABLE")
273-
* @DiscriminatorMap({"child" = Issue9095Child::class})
274-
*/
275-
abstract class Issue9095Parent
276-
{
277-
/**
278-
* @var mixed
279-
* @Id
280-
* @Column
281-
*/
282-
protected $key;
283-
}
284-
285-
/**
286-
* @Entity
287-
*/
288-
abstract class Issue9095AbstractChild extends Issue9095Parent
289-
{
290-
}
291-
292-
/**
293-
* @Entity
294-
*/
295-
class Issue9095Child extends Issue9095AbstractChild
296-
{
297-
}
298-
299259
/**
300260
* @Entity
301261
*/

0 commit comments

Comments
 (0)