Merge branch '3.2'
* 3.2: [Config] ConfigCache::isFresh() should return false on __PHP_Incomplete_Class [VarDumper] Use default color for ellipsed namespaces/paths mark alias as private during creation [Serializer] Remove unused GetSetMethodNormalizer::denormalize
This commit is contained in:
commit
2cdc6d2a07
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
|
||||
use Symfony\Component\Cache\Adapter\AdapterInterface;
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
@ -1248,8 +1249,7 @@ class FrameworkExtension extends Extension
|
||||
}
|
||||
foreach (array('doctrine', 'psr6', 'redis') as $name) {
|
||||
if (isset($config[$name = 'default_'.$name.'_provider'])) {
|
||||
$container->setAlias('cache.'.$name, Compiler\CachePoolPass::getServiceProvider($container, $config[$name]));
|
||||
$container->getAlias('cache.'.$name)->setPublic(false);
|
||||
$container->setAlias('cache.'.$name, new Alias(Compiler\CachePoolPass::getServiceProvider($container, $config[$name]), false));
|
||||
}
|
||||
}
|
||||
foreach (array('app', 'system') as $name) {
|
||||
|
@ -900,6 +900,7 @@ table.logs .metadata {
|
||||
#collector-content .sf-dump-note { color: #6897BB; }
|
||||
#collector-content .sf-dump-key { color: #789339; }
|
||||
#collector-content .sf-dump-ref { color: #6E6E6E; }
|
||||
#collector-content .sf-dump-ellipsis { color: #CC7832; max-width: 100em; }
|
||||
|
||||
#collector-content .sf-dump {
|
||||
margin: 0;
|
||||
|
@ -77,8 +77,37 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
$metadata = $this->getMetaFile();
|
||||
if (!is_file($metadata)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$e = null;
|
||||
$meta = false;
|
||||
$time = filemtime($this->file);
|
||||
$meta = unserialize(file_get_contents($metadata));
|
||||
$signalingException = new \UnexpectedValueException();
|
||||
$prevUnserializeHandler = ini_set('unserialize_callback_func', '');
|
||||
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context) use (&$prevErrorHandler, $signalingException) {
|
||||
if (E_WARNING === $type && 'Class __PHP_Incomplete_Class has no unserializer' === $msg) {
|
||||
throw $signalingException;
|
||||
}
|
||||
|
||||
return $prevErrorHandler ? $prevErrorHandler($type, $msg, $file, $line, $context) : false;
|
||||
});
|
||||
|
||||
try {
|
||||
$meta = unserialize(file_get_contents($metadata));
|
||||
} catch (\Error $e) {
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
restore_error_handler();
|
||||
ini_set('unserialize_callback_func', $prevUnserializeHandler);
|
||||
if (null !== $e && $e !== $signalingException) {
|
||||
throw $e;
|
||||
}
|
||||
if (false === $meta) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($meta as $resource) {
|
||||
/* @var ResourceInterface $resource */
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Config\Tests;
|
||||
|
||||
use Symfony\Component\Config\Tests\Resource\ResourceStub;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Config\ResourceCheckerConfigCache;
|
||||
|
||||
class ResourceCheckerConfigCacheTest extends \PHPUnit_Framework_TestCase
|
||||
@ -108,6 +109,18 @@ class ResourceCheckerConfigCacheTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($cache->isFresh());
|
||||
}
|
||||
|
||||
public function testCacheIsNotFreshWhenUnserializeFails()
|
||||
{
|
||||
$checker = $this->getMock('\Symfony\Component\Config\ResourceCheckerInterface');
|
||||
$cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker));
|
||||
$cache->write('foo', array(new FileResource(__FILE__)));
|
||||
|
||||
$metaFile = "{$this->cacheFile}.meta";
|
||||
file_put_contents($metaFile, str_replace('FileResource', 'ClassNotHere', file_get_contents($metaFile)));
|
||||
|
||||
$this->assertFalse($cache->isFresh());
|
||||
}
|
||||
|
||||
public function testCacheKeepsContent()
|
||||
{
|
||||
$cache = new ResourceCheckerConfigCache($this->cacheFile);
|
||||
|
@ -36,40 +36,6 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer
|
||||
{
|
||||
private static $setterAccessibleCache = array();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function denormalize($data, $class, $format = null, array $context = array())
|
||||
{
|
||||
$allowedAttributes = $this->getAllowedAttributes($class, $context, true);
|
||||
$normalizedData = $this->prepareForDenormalization($data);
|
||||
|
||||
$reflectionClass = new \ReflectionClass($class);
|
||||
$object = $this->instantiateObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes, $format);
|
||||
|
||||
$classMethods = get_class_methods($object);
|
||||
foreach ($normalizedData as $attribute => $value) {
|
||||
if ($this->nameConverter) {
|
||||
$attribute = $this->nameConverter->denormalize($attribute);
|
||||
}
|
||||
|
||||
$allowed = $allowedAttributes === false || in_array($attribute, $allowedAttributes);
|
||||
$ignored = in_array($attribute, $this->ignoredAttributes);
|
||||
|
||||
if ($allowed && !$ignored) {
|
||||
$setter = 'set'.ucfirst($attribute);
|
||||
|
||||
if (in_array($setter, $classMethods) && !$reflectionClass->getMethod($setter)->isStatic()) {
|
||||
$object->$setter($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -43,6 +43,7 @@ class HtmlDumper extends CliDumper
|
||||
'meta' => 'color:#B729D9',
|
||||
'key' => 'color:#56DB3A',
|
||||
'index' => 'color:#1299DA',
|
||||
'ellipsis' => 'color:#FF8400',
|
||||
);
|
||||
|
||||
private $displayOptions = array(
|
||||
@ -380,7 +381,7 @@ pre.sf-dump .sf-dump-ellipsis {
|
||||
display: inline-block;
|
||||
overflow: visible;
|
||||
text-overflow: ellipsis;
|
||||
width: 5em;
|
||||
max-width: 5em;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
vertical-align: top;
|
||||
|
Reference in New Issue
Block a user