Skip to content

Commit 64540b6

Browse files
committed
Merge branch '5.1' into master
* 5.1: fix merge [Cache] fix previous PR add mising sr (latn & cyrl) translations [Cache] fix ProxyAdapter not persisting items with infinite expiration [HttpClient] fail properly when the server replies with HTTP/0.9 Fix CS [Cache] Limit cache version character range [Mailer] Fixed Mailgun API bridge JsonException when API response is not applicaton/json [String] improve fix fix tests [DI] dump OS-indepent paths in the compiled container [DI] dump OS-indepent paths in the preload file Run postgres setup trigger in transaction allow consumers to mock all methods
2 parents 110abe4 + 61e9e7b commit 64540b6

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

Dumper/PhpDumper.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,15 @@ private function export($value)
20562056
$suffix = $matches[0][1] + \strlen($matches[0][0]);
20572057
$matches[0][1] += \strlen($matches[1][0]);
20582058
$prefix = $matches[0][1] ? $this->doExport(substr($value, 0, $matches[0][1]), true).'.' : '';
2059-
$suffix = isset($value[$suffix]) ? '.'.$this->doExport(substr($value, $suffix), true) : '';
2059+
2060+
if ('\\' === \DIRECTORY_SEPARATOR && isset($value[$suffix])) {
2061+
$cookie = '\\'.random_int(100000, \PHP_INT_MAX);
2062+
$suffix = '.'.$this->doExport(str_replace('\\', $cookie, substr($value, $suffix)), true);
2063+
$suffix = str_replace('\\'.$cookie, "'.\\DIRECTORY_SEPARATOR.'", $suffix);
2064+
} else {
2065+
$suffix = isset($value[$suffix]) ? '.'.$this->doExport(substr($value, $suffix), true) : '';
2066+
}
2067+
20602068
$dirname = $this->asFiles ? '$this->containerDir' : '__DIR__';
20612069
$offset = 2 + $this->targetDirMaxMatches - \count($matches);
20622070

Dumper/Preloader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function append(string $file, array $list): void
2727

2828
foreach ($list as $item) {
2929
if (0 === strpos($item, $cacheDir)) {
30-
file_put_contents($file, sprintf("require_once __DIR__.%s;\n", var_export(substr($item, \strlen($cacheDir)), true)), \FILE_APPEND);
30+
file_put_contents($file, sprintf("require_once __DIR__.%s;\n", var_export(strtr(substr($item, \strlen($cacheDir)), \DIRECTORY_SEPARATOR, '/'), true)), \FILE_APPEND);
3131
continue;
3232
}
3333

Tests/Dumper/PhpDumperTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function testDumpAsFiles()
239239
$dumper = new PhpDumper($container);
240240
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot', 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false]), true);
241241
if ('\\' === \DIRECTORY_SEPARATOR) {
242-
$dump = str_replace('\\\\Fixtures\\\\includes\\\\foo.php', '/Fixtures/includes/foo.php', $dump);
242+
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
243243
}
244244
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_as_files.txt', $dump);
245245
}
@@ -266,7 +266,7 @@ public function testDumpAsFilesWithFactoriesInlined()
266266
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot', 'build_time' => 1563381341]), true);
267267

268268
if ('\\' === \DIRECTORY_SEPARATOR) {
269-
$dump = str_replace('\\\\Fixtures\\\\includes\\\\', '/Fixtures/includes/', $dump);
269+
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
270270
}
271271
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_inlined_factories.txt', $dump);
272272
}
@@ -292,7 +292,7 @@ public function testDumpAsFilesWithLazyFactoriesInlined()
292292
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot', 'build_time' => 1563381341]), true);
293293

294294
if ('\\' === \DIRECTORY_SEPARATOR) {
295-
$dump = str_replace('\\\\Fixtures\\\\includes\\\\', '/Fixtures/includes/', $dump);
295+
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
296296
}
297297
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_lazy_inlined_factories.txt', $dump);
298298
}
@@ -310,7 +310,7 @@ public function testNonSharedLazyDumpAsFiles()
310310
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false]), true);
311311

312312
if ('\\' === \DIRECTORY_SEPARATOR) {
313-
$dump = str_replace('\\\\Fixtures\\\\includes\\\\foo_lazy.php', '/Fixtures/includes/foo_lazy.php', $dump);
313+
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
314314
}
315315
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services_non_shared_lazy_as_files.txt', $dump);
316316
}
@@ -981,7 +981,7 @@ public function testArrayParameters()
981981

982982
$dumper = new PhpDumper($container);
983983

984-
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_array_params.php', str_replace('\\\\Dumper', '/Dumper', $dumper->dump(['file' => self::$fixturesPath.'/php/services_array_params.php', 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false])));
984+
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_array_params.php', str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dumper->dump(['file' => self::$fixturesPath.'/php/services_array_params.php', 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false])));
985985
}
986986

987987
public function testExpressionReferencingPrivateService()
@@ -1142,7 +1142,7 @@ public function testHotPathOptimizations()
11421142

11431143
$dump = $dumper->dump(['hot_path_tag' => 'container.hot_path', 'inline_class_loader_parameter' => 'inline_requires', 'file' => self::$fixturesPath.'/php/services_inline_requires.php']);
11441144
if ('\\' === \DIRECTORY_SEPARATOR) {
1145-
$dump = str_replace("'\\\\includes\\\\HotPath\\\\", "'/includes/HotPath/", $dump);
1145+
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
11461146
}
11471147

11481148
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_inline_requires.php', $dump);

0 commit comments

Comments
 (0)