mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 06:35:15 +00:00
Wrap stdio calls in error_handler save and restore as @functions are deprecated in php81.
This commit is contained in:
parent
636688e432
commit
f67a6896f6
2 changed files with 17 additions and 13 deletions
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -8,19 +8,14 @@ Class Stdio {
|
|||
|
||||
static public function mkdir($path, $mode = 0777, $recursive = false) {
|
||||
$result = false;
|
||||
try {
|
||||
$oldumask = umask(0);
|
||||
set_error_handler(function() { /* ignore warnings */ });
|
||||
$result = mkdir($path, $mode, $recursive);
|
||||
} catch (\Exception $e) {
|
||||
// null operation
|
||||
} finally {
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue