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:
commit
a3b45eb034
@ -156,7 +156,7 @@ trait RedisTrait
|
|||||||
|
|
||||||
$initializer = function ($redis) use ($connect, $params, $dsn, $auth, $hosts) {
|
$initializer = function ($redis) use ($connect, $params, $dsn, $auth, $hosts) {
|
||||||
try {
|
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) {
|
} catch (\RedisException $e) {
|
||||||
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s', $e->getMessage(), $dsn));
|
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s', $e->getMessage(), $dsn));
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,15 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
|
|||||||
|
|
||||||
public function serialize()
|
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)
|
public function unserialize($data)
|
||||||
{
|
{
|
||||||
$this->data = unserialize($data);
|
$this->data = \is_array($data) ? $data : unserialize($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user