8000 bug #23985 [Cache] Workaround zend.detect_unicode + zend.multibyte (n… · symfony/symfony@8a38f88 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a38f88

Browse files
committed
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 ------- 1cab07e [Cache] Workaround zend.detect_unicode + zend.multibyte
2 parents ebd14ee + 1cab07e commit 8a38f88

File tree

6 files changed

+23
-2
lines changed

6 files changed

+23
-2
lines changed

src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function __construct($file, AdapterInterface $fallbackPool)
3838
{
3939
$this->file = $file;
4040
$this->fallbackPool = $fallbackPool;
41+
$this->zendMultiByte = ini_get('zend.multibyte');
4142
$this->createCacheItem = \Closure::bind(
4243
function ($key, $value, $isHit) {
4344
$item = new CacheItem();

src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ public function __construct($namespace = '', $defaultLifetime = 0, $directory =
3535

3636
$e = new \Exception();
3737
$this->includeHandler = function () use ($e) { throw $e; };
38+
$this->zendMultiByte = ini_get('zend.multibyte');
3839
}
3940
}

src/Symfony/Component/Cache/Simple/PhpArrayCache.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct($file, CacheInterface $fallbackPool)
3434
{
3535
$this->file = $file;
3636
$this->fallbackPool = $fallbackPool;
37+
$this->zendMultiByte = ini_get('zend.multibyte');
3738
}
3839

3940
/**

src/Symfony/Component/Cache/Simple/PhpFilesCache.php

< 8000 span class="prc-TooltipV2-Tooltip-cYMVY" data-direction="s" role="tooltip" aria-hidden="true" id=":R13edlab:">Expand all lines: src/Symfony/Component/Cache/Simple/PhpFilesCache.php
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ public function __construct($namespace = '', $defaultLifetime = 0, $directory =
3535

3636
$e = new \Exception();
3737
$this->includeHandler = function () use ($e) { throw $e; };
38+
$this->zendMultiByte = ini_get('zend.multibyte');
3839
}
3940
}

src/Symfony/Component/Cache/Traits/PhpArrayTrait.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ trait PhpArrayTrait
2525
private $file;
2626
private $values;
2727
private $fallbackPool;
28+
private $zendMultiByte;
2829

2930
/**
3031
* Store an array of cached values.
@@ -106,7 +107,7 @@ public function warmUp(array $values)
106107

107108
@rename($tmpFile, $this->file);
108109

109-
$this->values = (include $this->file) ?: array();
110+
$this->initialize();
110111
}
111112

112113
/**
@@ -126,6 +127,15 @@ public function clear()
126127
*/
127128
private function initialize()
128129
{
129-
$this->values = file_exists($this->file) ? (include $this->file ?: array()) : array();
130+
if ($this->zendMultiByte) {
131+
$zmb = ini_set('zend.multibyte', 0);
132+
}
133+
try {
134+
$this->values = file_exists($this->file) ? (include $this->file ?: array()) : array();
135+
} finally {
136+
if ($this->zendMultiByte) {
137+
ini_set('zend.multibyte', $zmb);
138+
}
139+
}
130140
}
131141
}

src/Symfony/Component/Cache/Traits/PhpFilesTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ trait PhpFilesTrait
2525
use FilesystemCommonTrait;
2626

2727
private $includeHandler;
28+
private $zendMultiByte;
2829

2930
public static function isSupported()
3031
{
@@ -39,6 +40,9 @@ protected function doFetch(array $ids)
3940
$values = array();
4041
$now = time();
4142

43+
if ($this->zendMultiByte) {
44+
$zmb = ini_set('zend.multibyte', 0);
45+
}
4246
set_error_handler($this->includeHandler);
4347
try {
4448
foreach ($ids as $id) {
@@ -54,6 +58,9 @@ protected function doFetch(array $ids)
5458
}
5559
} finally {
5660
restore_error_handler();
61+
if ($this->zendMultiByte) {
62+
ini_set('zend.multibyte', $zmb);
63+
}
5764
}
5865

5966
foreach ($values as $id => $value) {

0 commit comments

Comments
 (0)
0