Merge branch '4.2'

* 4.2:
  [Cache] fix connecting using socket with phpredis
  [HttpKernel] fix nested calls to serialize when using DataCollector
This commit is contained in:
Nicolas Grekas 2019-01-29 11:17:58 +01:00
commit a3b45eb034
2 changed files with 6 additions and 3 deletions

View File

@ -156,7 +156,7 @@ trait RedisTrait
$initializer = function ($redis) use ($connect, $params, $dsn, $auth, $hosts) {
try {
@$redis->{$connect}($hosts[0]['host'], $hosts[0]['port'], $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']);
@$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']);
} catch (\RedisException $e) {
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s', $e->getMessage(), $dsn));
}

View File

@ -36,12 +36,15 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
public function serialize()
{
return serialize($this->data);
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
$isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object'];
return $isCalledFromOverridingMethod ? $this->data : serialize($this->data);
}
public function unserialize($data)
{
$this->data = unserialize($data);
$this->data = \is_array($data) ? $data : unserialize($data);
}
/**