Skip to content

Commit bf7b9d2

Browse files
Merge branch '5.4' into 6.0
* 5.4: Fix merge [Mime] Throw exception when body in Email attach method is not ok [VarDumper][VarExporter] Deal with DatePeriod->include_end_date on PHP 8.2 [Cache] Throw when "redis_sentinel" is used with a non-Predis "class" option fix merge Bootstrap 4 fieldset for row errors [Form] Fix same choice loader with different choice values [Filesystem] Safeguard (sym)link calls Fix dumping extension config without bundle [HttpClient] Honor "max_duration" when replacing requests with async decorators [HttpClient] Add missing HttpOptions::setMaxDuration() [HttpFoundation] [Session] Overwrite invalid session id
2 parents 6c9e4c4 + 36a017f commit bf7b9d2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Filesystem.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ private function isReadable(string $filename): bool
317317
*/
318318
public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false)
319319
{
320+
self::assertFunctionExists('symlink');
321+
320322
if ('\\' === \DIRECTORY_SEPARATOR) {
321323
$originDir = strtr($originDir, '/', '\\');
322324
$targetDir = strtr($targetDir, '/', '\\');
@@ -352,6 +354,8 @@ public function symlink(string $originDir, string $targetDir, bool $copyOnWindow
352354
*/
353355
public function hardlink(string $originFile, string|iterable $targetFiles)
354356
{
357+
self::assertFunctionExists('link');
358+
355359
if (!$this->exists($originFile)) {
356360
throw new FileNotFoundException(null, 0, null, $originFile);
357361
}
@@ -703,8 +707,17 @@ private function getSchemeAndHierarchy(string $filename): array
703707
return 2 === \count($components) ? [$components[0], $components[1]] : [null, $components[0]];
704708
}
705709

706-
private static function box(callable $func, mixed ...$args): mixed
710+
private static function assertFunctionExists(string $func): void
707711
{
712+
if (!\function_exists($func)) {
713+
throw new IOException(sprintf('Unable to perform filesystem operation because the "%s()" function has been disabled.', $func));
714+
}
715+
}
716+
717+
private static function box(string $func, mixed ...$args): mixed
718+
{
719+
self::assertFunctionExists($func);
720+
708721
self::$lastError = null;
709722
set_error_handler(__CLASS__.'::handleError');
710723
try {

0 commit comments

Comments
 (0)