bug #23985 [Cache] Workaround zend.detect_unicode + zend.multibyte (nicolas-grekas)
This PR was merged into the 3.3 branch.
Discussion
----------
[Cache] Workaround zend.detect_unicode + zend.multibyte
| Q | A
| ------------- | ---
| Branch? | 3.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #22972
| License | MIT
| Doc PR | -
ping @patrickvane
Commits
-------
1cab07ebee
[Cache] Workaround zend.detect_unicode + zend.multibyte
This commit is contained in:
commit
8a38f887cb
@ -38,6 +38,7 @@ class PhpArrayAdapter implements AdapterInterface
|
|||||||
{
|
{
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
$this->fallbackPool = $fallbackPool;
|
$this->fallbackPool = $fallbackPool;
|
||||||
|
$this->zendMultiByte = ini_get('zend.multibyte');
|
||||||
$this->createCacheItem = \Closure::bind(
|
$this->createCacheItem = \Closure::bind(
|
||||||
function ($key, $value, $isHit) {
|
function ($key, $value, $isHit) {
|
||||||
$item = new CacheItem();
|
$item = new CacheItem();
|
||||||
|
@ -35,5 +35,6 @@ class PhpFilesAdapter extends AbstractAdapter
|
|||||||
|
|
||||||
$e = new \Exception();
|
$e = new \Exception();
|
||||||
$this->includeHandler = function () use ($e) { throw $e; };
|
$this->includeHandler = function () use ($e) { throw $e; };
|
||||||
|
$this->zendMultiByte = ini_get('zend.multibyte');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ class PhpArrayCache implements CacheInterface
|
|||||||
{
|
{
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
$this->fallbackPool = $fallbackPool;
|
$this->fallbackPool = $fallbackPool;
|
||||||
|
$this->zendMultiByte = ini_get('zend.multibyte');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,5 +35,6 @@ class PhpFilesCache extends AbstractCache
|
|||||||
|
|
||||||
$e = new \Exception();
|
$e = new \Exception();
|
||||||
$this->includeHandler = function () use ($e) { throw $e; };
|
$this->includeHandler = function () use ($e) { throw $e; };
|
||||||
|
$this->zendMultiByte = ini_get('zend.multibyte');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ trait PhpArrayTrait
|
|||||||
private $file;
|
private $file;
|
||||||
private $values;
|
private $values;
|
||||||
private $fallbackPool;
|
private $fallbackPool;
|
||||||
|
private $zendMultiByte;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store an array of cached values.
|
* Store an array of cached values.
|
||||||
@ -106,7 +107,7 @@ EOF;
|
|||||||
|
|
||||||
@rename($tmpFile, $this->file);
|
@rename($tmpFile, $this->file);
|
||||||
|
|
||||||
$this->values = (include $this->file) ?: array();
|
$this->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,6 +127,15 @@ EOF;
|
|||||||
*/
|
*/
|
||||||
private function initialize()
|
private function initialize()
|
||||||
{
|
{
|
||||||
$this->values = file_exists($this->file) ? (include $this->file ?: array()) : array();
|
if ($this->zendMultiByte) {
|
||||||
|
$zmb = ini_set('zend.multibyte', 0);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$this->values = file_exists($this->file) ? (include $this->file ?: array()) : array();
|
||||||
|
} finally {
|
||||||
|
if ($this->zendMultiByte) {
|
||||||
|
ini_set('zend.multibyte', $zmb);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ trait PhpFilesTrait
|
|||||||
use FilesystemCommonTrait;
|
use FilesystemCommonTrait;
|
||||||
|
|
||||||
private $includeHandler;
|
private $includeHandler;
|
||||||
|
private $zendMultiByte;
|
||||||
|
|
||||||
public static function isSupported()
|
public static function isSupported()
|
||||||
{
|
{
|
||||||
@ -39,6 +40,9 @@ trait PhpFilesTrait
|
|||||||
$values = array();
|
$values = array();
|
||||||
$now = time();
|
$now = time();
|
||||||
|
|
||||||
|
if ($this->zendMultiByte) {
|
||||||
|
$zmb = ini_set('zend.multibyte', 0);
|
||||||
|
}
|
||||||
set_error_handler($this->includeHandler);
|
set_error_handler($this->includeHandler);
|
||||||
try {
|
try {
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
@ -54,6 +58,9 @@ trait PhpFilesTrait
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
|
if ($this->zendMultiByte) {
|
||||||
|
ini_set('zend.multibyte', $zmb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($values as $id => $value) {
|
foreach ($values as $id => $value) {
|
||||||
|
Reference in New Issue
Block a user