Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit fe1776a

Browse files
author
Jamie Snape
committed
Allow for the lack of realpath on Cloud Storage
1 parent cfecd38 commit fe1776a

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

core/controllers/components/UtilityComponent.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public static function getDataDirectory($subDirectory = '', $createDirectory = t
425425
mkdir($path, 0777, true);
426426
}
427427

428-
return realpath($path);
428+
return UtilityComponent::realpath($path);
429429
}
430430

431431
/**
@@ -464,7 +464,7 @@ public static function getTempDirectory($subDirectory = 'misc', $createDirectory
464464
mkdir($path, 0777, true);
465465
}
466466

467-
return realpath($path);
467+
return UtilityComponent::realpath($path);
468468
}
469469

470470
/**
@@ -793,4 +793,23 @@ public static function diskTotalSpace($directory)
793793

794794
return $result;
795795
}
796+
797+
/**
798+
* Returns canonical absolute path.
799+
*
800+
* @param string $path
801+
* @return string
802+
*/
803+
public static function realpath($path)
804+
{
805+
UtilityComponent::beginIgnoreWarnings();
806+
$realpath = realpath($path);
807+
UtilityComponent::endIgnoreWarnings();
808+
809+
if ($realpath === false) {
810+
return $path;
811+
}
812+
813+
return $realpath;
814+
}
796815
}

0 commit comments

Comments
 (0)