8000 Merge branch '3.1' into 3.2 · src-run/symfony@bd5af67 · GitHub
[go: up one dir, main page]

Skip to content

Commit bd5af67

Browse files
Merge branch '3.1' into 3.2
* 3.1: [Config] ConfigCache::isFresh() should return false on __PHP_Incomplete_Class mark alias as private during creation [Serializer] Remove unused GetSetMethodNormalizer::denormalize
2 parents 726c781 + b9ed4bf commit bd5af67

File tree

4 files changed

+45
-37
lines changed

4 files changed

+45
-37
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\Common\Annotations\Reader;
1515
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
1616
use Symfony\Component\Cache\Adapter\AdapterInterface;
17+
use Symfony\Component\DependencyInjection\Alias;
1718
use Symfony\Component\DependencyInjection\ContainerBuilder;
1819
use Symfony\Component\DependencyInjection\ContainerInterface;
1920
use Symfony\Component\DependencyInjection\Definition;
@@ -1248,8 +1249,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
12481249
}
12491250
foreach (array('doctrine', 'psr6', 'redis') as $name) {
12501251
if (isset($config[$name = 'default_'.$name.'_provider'])) {
1251-
$container->setAlias('cache.'.$name, Compiler\CachePoolPass::getServiceProvider($container, $config[$name]));
1252-
$container->getAlias('cache.'.$name)->setPublic(false);
1252+
$container->setAlias('cache.'.$name, new Alias(Compiler\CachePoolPass::getServiceProvider($container, $config[$name]), false));
12531253
}
12541254
}
12551255
foreach (array('app', 'system') as $name) {

src/Symfony/Component/Config/R 10000 esourceCheckerConfigCache.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,37 @@ public function isFresh()
7777
return true;
7878
}
7979

80+
$metadata = $this->getMetaFile();
81+
if (!is_file($metadata)) {
82+
return false;
83+
}
84+
85+
$e = null;
86+
$meta = false;
8087
$time = filemtime($this->file);
81-
$meta = unserialize(file_get_contents($metadata));
88+
$signalingException = new \UnexpectedValueException();
89+
$prevUnserializeHandler = ini_set('unserialize_callback_func', '');
90+
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context) use (&$prevErrorHandler, $signalingException) {
91+
if (E_WARNING === $type && 'Class __PHP_Incomplete_Class has no unserializer' === $msg) {
92+
throw $signalingException;
93+
}
94+
95+
return $prevErrorHandler ? $prevErrorHandler($type, $msg, $file, $line, $context) : false;
96+
});
97+
98+
try {
99+
$meta = unserialize(file_get_contents($metadata));
100+
} catch (\Error $e) {
101+
} catch (\Exception $e) {
102+
}
103+
restore_error_handler();
104+
ini_set('unserialize_callback_func', $prevUnserializeHandler);
105+
if (null !== $e && $e !== $signalingException) {
106+
throw $e;
107+
}
108+
if (false === $meta) {
109+
return false;
110+
}
82111

83112
foreach ($meta as $resource) {
84113
/* @var ResourceInterface $resource */

src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Config\Tests;
1313

1414
use Symfony\Component\Config\Tests\Resource\ResourceStub;
15+
use Symfony\Component\Config\Resource\FileResource;
1516
use Symfony\Component\Config\ResourceCheckerConfigCache;
1617

1718
class ResourceCheckerConfigCacheTest extends \PHPUnit_Framework_TestCase
@@ -108,6 +109,18 @@ public function testIsNotFreshWithchecker()
108109
$this->assertFalse($cache->isFresh());
109110
}
110111

112+
public function testCacheIsNotFreshWhenUnserializeFails()
113+
{
114+
$checker = $this->getMock('\Symfony\Component\Config\ResourceCheckerInterface');
115+
$cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker));
116+
$cache->write('foo', array(new FileResource(__FILE__)));
117+
118+
$metaFile = "{$this->cacheFile}.meta";
119+
file_put_contents($metaFile, str_replace('FileResource', 'ClassNotHere', file_get_contents($metaFile)));
120+
121+
$this->assertFalse($cache->isFresh());
122+
}
123+
111124
public function testCacheKeepsContent()
112125
{
113126
$cache = new ResourceCheckerConfigCache($this->cacheFile);

src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,6 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer
3636
{
3737
private static $setterAccessibleCache = array();
3838

39-
/**
40-
* {@inheritdoc}
41-
*
42-
* @throws RuntimeException
43-
*/
44-
public function denormalize($data, $class, $format = null, array $context = array())
45-
{
46-
$allowedAttributes = $this->getAllowedAttributes($class, $context, true);
47-
$normalizedData = $this->prepareForDenormalization($data);
48-
49-
$reflectionClass = new \ReflectionClass($class);
50-
$object = $this->instantiateObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes, $format);
51-
52-
$classMethods = get_class_methods($object);
53-
foreach ($normalizedData as $attribute => $value) {
54-
if ($this->nameConverter) {
55-
$attribute = $this->nameConverter->denormalize($attribute);
56-
}
57-
58-
$allowed = $allowedAttributes === false || in_array($attribute, $allowedAttributes);
59-
$ignored = in_array($attribute, $this->ignoredAttributes);
60-
61-
if ($allowed && !$ignored) {
62-
$setter = 'set'.ucfirst($attribute);
63-
64-
if (in_array($setter, $classMethods) && !$reflectionClass->getMethod($setter)->isStatic()) {
65-
$object->$setter($value);
66-
}
67-
}
68-
}
69-
70-
return $object;
71-
}
72-
7339
/**
7440
* {@inheritdoc}
7541
*/

0 commit comments

Comments
 (0)
0