Wrap stdio calls in error_handler save and restore as @functions are deprecated in php81.

This commit is contained in:
Mike Macgirvin 2022-06-26 18:39:23 -07:00
parent 636688e432
commit f67a6896f6
2 changed files with 17 additions and 13 deletions

View file

@ -782,10 +782,10 @@ class Setup extends Controller
set_config('system', 'allowed_themes', 'redbasic');
// if imagick converter is installed, use it
if (@is_executable('/usr/bin/magick')) {
if (Stdio::is_executable('/usr/bin/magick')) {
set_config('system', 'imagick_convert_path', '/usr/bin/magick');
}
elseif (@is_executable('/usr/bin/convert')) {
elseif (Stdio::is_executable('/usr/bin/convert')) {
set_config('system', 'imagick_convert_path', '/usr/bin/convert');
}

View file

@ -8,19 +8,14 @@ Class Stdio {
static public function mkdir($path, $mode = 0777, $recursive = false) {
$result = false;
try {
$oldumask = umask(0);
$result = mkdir($path, $mode, $recursive);
} catch (\Exception $e) {
// null operation
} finally {
umask($oldumask);
}
$oldumask = umask(0);
set_error_handler(function() { /* ignore warnings */ });
$result = mkdir($path, $mode, $recursive);
restore_error_handler();
umask($oldumask);
return $result;
}
/**
* @brief Pipes $infile to $outfile in $bufsize chunks
*
@ -29,6 +24,7 @@ Class Stdio {
static public function fcopy($infile, $outfile, $bufsize = 65535, $read_mode = 'rb', $write_mode = 'wb')
{
$size = false;
set_error_handler(function() { /* ignore warnings */ });
$in = fopen($infile, $read_mode);
$out = fopen($outfile, $write_mode);
if ($in && $out) {
@ -36,6 +32,7 @@ Class Stdio {
}
fclose($in);
fclose($out);
restore_error_handler();
return $size;
}
@ -56,4 +53,11 @@ Class Stdio {
return $size;
}
}
static public function is_executable($path) {
set_error_handler(function() { /* ignore warnings */ });
$result = is_executable($path);
restore_error_handler();
return $result;
}
}