Skip to content

Commit 82e363f

Browse files
committed
[PropertyAccessor] Remove the internal array cache and always rely on Doctrine
1 parent 42ccf65 commit 82e363f

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

+4-20
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
/**
2121
* Default implementation of {@link PropertyAccessorInterface}.
2222
*
23+
* Be sure to enable Doctrine Cache to improve performance of the accessor.
24+
*
2325
* @author Bernhard Schussek <bschussek@gmail.com>
2426
* @author Kévin Dunglas <dunglas@gmail.com>
2527
*/
@@ -57,16 +59,6 @@ class PropertyAccessor implements PropertyAccessorInterface
5759
*/
5860
private $cache;
5961

60-
/**
61-
* @var array
62-
*/
63-
private $readPropertyCache = array();
64-
65-
/**
66-
* @var array
67-
*/
68-
private $writePropertyCache = array();
69-
7062
/**
7163
* Should not be used by application code. Use
7264
* {@link PropertyAccess::createPropertyAccessor()} instead.
@@ -408,9 +400,7 @@ private function getReadAccessInfo($object, $property)
408400
{
409401
$key = get_class($object).'::'.$property;
410402

411-
if (isset($this->readPropertyCache[$key])) {
412-
$access = $this->readPropertyCache[$key];
413-
} elseif (!$this->cache || false === $access = $this->cache->fetch(self::CACHE_PREFIX_READ.$key)) {
403+
if (!$this->cache || false === $access = $this->cache->fetch(self::CACHE_PREFIX_READ.$key)) {
414404
$access = array();
415405

416406
$reflClass = new \ReflectionClass($object);
@@ -468,8 +458,6 @@ private function getReadAccessInfo($object, $property)
468458
if ($this->cache) {
469459
$this->cache->save(self::CACHE_PREFIX_READ.$key, $access);
470460
}
471-
472-
$this->readPropertyCache[$key] = $access;
473461
}
474462

475463
return $access;
@@ -594,9 +582,7 @@ private function getWriteAccessInfo($object, $property, $value)
594582
$key = get_class($object).'::'.$property;
595583
$guessedAdders = '';
596584

597-
if (isset($this->writePropertyCache[$key])) {
598-
$access = $this->writePropertyCache[$key];
599-
} elseif (!$this->cache || false === $access = $this->cache->fetch(self::CACHE_PREFIX_WRITE.$key)) {
585+
if (!$this->cache || false === $access = $this->cache->fetch(self::CACHE_PREFIX_WRITE.$key)) {
600586
$access = array();
601587

602588
$reflClass = new \ReflectionClass($object);
@@ -661,8 +647,6 @@ private function getWriteAccessInfo($object, $property, $value)
661647
if ($this->cache) {
662648
$this->cache->save(self::CACHE_PREFIX_WRITE.$key, $access);
663649
}
664-
665-
$this->writePropertyCache[$key] = $access;
666650
}
667651

668652
return $access;

0 commit comments

Comments
 (0)