1
0
Fork 0

Fix disk_free_space being called even when not available, fixes #10936

pull/10985/head
Jordi Boggiano 2022-07-13 10:35:32 +02:00
parent f600ea46c7
commit a481dfce3f
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
3 changed files with 7 additions and 3 deletions

View File

@ -162,11 +162,11 @@ class Cache
unlink($tempFileName); unlink($tempFileName);
$message = sprintf( $message = sprintf(
'<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available</warning>', '<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$s bytes of free space available</warning>',
$tempFileName, $tempFileName,
$m[1], $m[1],
$m[2], $m[2],
@disk_free_space(dirname($tempFileName)) function_exists('disk_free_space') ? @disk_free_space(dirname($tempFileName)) : 'unknown'
); );
$this->io->writeError($message); $this->io->writeError($message);

View File

@ -370,6 +370,10 @@ EOT
*/ */
private function checkDiskSpace(Config $config) private function checkDiskSpace(Config $config)
{ {
if (!function_exists('disk_free_space')) {
return true;
}
$minSpaceFree = 1024 * 1024; $minSpaceFree = 1024 * 1024;
if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree) if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
|| (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree) || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)

View File

@ -386,7 +386,7 @@ class Application extends BaseApplication
Silencer::suppress(); Silencer::suppress();
try { try {
$composer = $this->getComposer(false, true); $composer = $this->getComposer(false, true);
if ($composer) { if (null !== $composer && function_exists('disk_free_space')) {
$config = $composer->getConfig(); $config = $composer->getConfig();
$minSpaceFree = 1024 * 1024; $minSpaceFree = 1024 * 1024;