Merge branch '4.3' into 4.4
* 4.3: use utf8mb4_bin to align code with documentation [HttpClient] make pushed responses retry-able [VarDumper] ignore failing __debugInfo()
This commit is contained in:
commit
b450a2bed7
@ -119,23 +119,6 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
|
|||||||
$options['normalized_headers']['user-agent'][] = $options['headers'][] = 'User-Agent: Symfony HttpClient/Curl';
|
$options['normalized_headers']['user-agent'][] = $options['headers'][] = 'User-Agent: Symfony HttpClient/Curl';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pushedResponse = $this->multi->pushedResponses[$url] ?? null) {
|
|
||||||
unset($this->multi->pushedResponses[$url]);
|
|
||||||
|
|
||||||
if (self::acceptPushForRequest($method, $options, $pushedResponse)) {
|
|
||||||
$this->logger && $this->logger->debug(sprintf('Accepting pushed response: "%s %s"', $method, $url));
|
|
||||||
|
|
||||||
// Reinitialize the pushed response with request's options
|
|
||||||
$pushedResponse->response->__construct($this->multi, $url, $options, $this->logger);
|
|
||||||
|
|
||||||
return $pushedResponse->response;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->logger && $this->logger->debug(sprintf('Rejecting pushed response: "%s".', $url));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->logger && $this->logger->info(sprintf('Request: "%s %s"', $method, $url));
|
|
||||||
|
|
||||||
$curlopts = [
|
$curlopts = [
|
||||||
CURLOPT_URL => $url,
|
CURLOPT_URL => $url,
|
||||||
CURLOPT_TCP_NODELAY => true,
|
CURLOPT_TCP_NODELAY => true,
|
||||||
@ -294,7 +277,26 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
|
|||||||
$curlopts[CURLOPT_TIMEOUT_MS] = 1000 * $options['max_duration'];
|
$curlopts[CURLOPT_TIMEOUT_MS] = 1000 * $options['max_duration'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$ch = curl_init();
|
if ($pushedResponse = $this->multi->pushedResponses[$url] ?? null) {
|
||||||
|
unset($this->multi->pushedResponses[$url]);
|
||||||
|
|
||||||
|
if (self::acceptPushForRequest($method, $options, $pushedResponse)) {
|
||||||
|
$this->logger && $this->logger->debug(sprintf('Accepting pushed response: "%s %s"', $method, $url));
|
||||||
|
|
||||||
|
// Reinitialize the pushed response with request's options
|
||||||
|
$ch = $pushedResponse->handle;
|
||||||
|
$pushedResponse = $pushedResponse->response;
|
||||||
|
$pushedResponse->__construct($this->multi, $url, $options, $this->logger);
|
||||||
|
} else {
|
||||||
|
$this->logger && $this->logger->debug(sprintf('Rejecting pushed response: "%s".', $url));
|
||||||
|
$pushedResponse = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$pushedResponse) {
|
||||||
|
$ch = curl_init();
|
||||||
|
$this->logger && $this->logger->info(sprintf('Request: "%s %s"', $method, $url));
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($curlopts as $opt => $value) {
|
foreach ($curlopts as $opt => $value) {
|
||||||
if (null !== $value && !curl_setopt($ch, $opt, $value) && CURLOPT_CERTINFO !== $opt) {
|
if (null !== $value && !curl_setopt($ch, $opt, $value) && CURLOPT_CERTINFO !== $opt) {
|
||||||
@ -306,7 +308,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CurlResponse($this->multi, $ch, $options, $this->logger, $method, self::createRedirectResolver($options, $host));
|
return $pushedResponse ?? new CurlResponse($this->multi, $ch, $options, $this->logger, $method, self::createRedirectResolver($options, $host));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -396,7 +398,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
|
|||||||
$url .= $headers[':path'][0];
|
$url .= $headers[':path'][0];
|
||||||
$logger && $logger->debug(sprintf('Queueing pushed response: "%s"', $url));
|
$logger && $logger->debug(sprintf('Queueing pushed response: "%s"', $url));
|
||||||
|
|
||||||
$multi->pushedResponses[$url] = new PushedResponse(new CurlResponse($multi, $pushed), $headers, $multi->openHandles[(int) $parent][1] ?? []);
|
$multi->pushedResponses[$url] = new PushedResponse(new CurlResponse($multi, $pushed), $headers, $multi->openHandles[(int) $parent][1] ?? [], $pushed);
|
||||||
|
|
||||||
return CURL_PUSH_OK;
|
return CURL_PUSH_OK;
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,13 @@ final class PushedResponse
|
|||||||
|
|
||||||
public $parentOptions = [];
|
public $parentOptions = [];
|
||||||
|
|
||||||
public function __construct(CurlResponse $response, array $requestHeaders, array $parentOptions)
|
public $handle;
|
||||||
|
|
||||||
|
public function __construct(CurlResponse $response, array $requestHeaders, array $parentOptions, $handle)
|
||||||
{
|
{
|
||||||
$this->response = $response;
|
$this->response = $response;
|
||||||
$this->requestHeaders = $requestHeaders;
|
$this->requestHeaders = $requestHeaders;
|
||||||
$this->parentOptions = $parentOptions;
|
$this->parentOptions = $parentOptions;
|
||||||
|
$this->handle = $handle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ class PdoSessionHandler extends AbstractSessionHandler
|
|||||||
// - trailing space removal
|
// - trailing space removal
|
||||||
// - case-insensitivity
|
// - case-insensitivity
|
||||||
// - language processing like é == e
|
// - language processing like é == e
|
||||||
$sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER UNSIGNED NOT NULL, $this->timeCol INTEGER UNSIGNED NOT NULL) COLLATE utf8_bin, ENGINE = InnoDB";
|
$sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER UNSIGNED NOT NULL, $this->timeCol INTEGER UNSIGNED NOT NULL) COLLATE utf8mb4_bin, ENGINE = InnoDB";
|
||||||
break;
|
break;
|
||||||
case 'sqlite':
|
case 'sqlite':
|
||||||
$sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER NOT NULL, $this->timeCol INTEGER NOT NULL)";
|
$sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER NOT NULL, $this->timeCol INTEGER NOT NULL)";
|
||||||
|
@ -47,6 +47,15 @@ class Caster
|
|||||||
*/
|
*/
|
||||||
public static function castObject($obj, string $class, bool $hasDebugInfo = false): array
|
public static function castObject($obj, string $class, bool $hasDebugInfo = false): array
|
||||||
{
|
{
|
||||||
|
if ($hasDebugInfo) {
|
||||||
|
try {
|
||||||
|
$debugInfo = $obj->__debugInfo();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// ignore failing __debugInfo()
|
||||||
|
$hasDebugInfo = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$a = $obj instanceof \Closure ? [] : (array) $obj;
|
$a = $obj instanceof \Closure ? [] : (array) $obj;
|
||||||
|
|
||||||
if ($obj instanceof \__PHP_Incomplete_Class) {
|
if ($obj instanceof \__PHP_Incomplete_Class) {
|
||||||
@ -82,7 +91,7 @@ class Caster
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hasDebugInfo && \is_array($debugInfo = $obj->__debugInfo())) {
|
if ($hasDebugInfo && \is_array($debugInfo)) {
|
||||||
foreach ($debugInfo as $k => $v) {
|
foreach ($debugInfo as $k => $v) {
|
||||||
if (!isset($k[0]) || "\0" !== $k[0]) {
|
if (!isset($k[0]) || "\0" !== $k[0]) {
|
||||||
$k = self::PREFIX_VIRTUAL.$k;
|
$k = self::PREFIX_VIRTUAL.$k;
|
||||||
|
Reference in New Issue
Block a user