mirror of
https://github.com/itflow-org/itflow
synced 2026-06-20 00:31:05 +00:00
Allow PHP-8.2 and up Compatibility instead of just PHP-8.4
This commit is contained in:
@@ -187,7 +187,7 @@ class UploadedFile extends File
|
||||
|
||||
$target = $this->getTargetFile($directory, $name);
|
||||
|
||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
set_error_handler(static function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
try {
|
||||
$moved = move_uploaded_file($this->getPathname(), $target);
|
||||
} finally {
|
||||
@@ -197,29 +197,37 @@ class UploadedFile extends File
|
||||
throw new FileException(\sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, strip_tags($error)));
|
||||
}
|
||||
|
||||
@chmod($target, 0666 & ~umask());
|
||||
@chmod($target, 0o666 & ~umask());
|
||||
|
||||
return $target;
|
||||
}
|
||||
|
||||
switch ($this->error) {
|
||||
case \UPLOAD_ERR_INI_SIZE:
|
||||
throw new IniSizeFileException($this->getErrorMessage());
|
||||
throw new IniSizeFileException($this->getExceptionMessage());
|
||||
case \UPLOAD_ERR_FORM_SIZE:
|
||||
throw new FormSizeFileException($this->getErrorMessage());
|
||||
throw new FormSizeFileException($this->getExceptionMessage());
|
||||
case \UPLOAD_ERR_PARTIAL:
|
||||
throw new PartialFileException($this->getErrorMessage());
|
||||
throw new PartialFileException($this->getExceptionMessage());
|
||||
case \UPLOAD_ERR_NO_FILE:
|
||||
throw new NoFileException($this->getErrorMessage());
|
||||
throw new NoFileException($this->getExceptionMessage());
|
||||
case \UPLOAD_ERR_CANT_WRITE:
|
||||
throw new CannotWriteFileException($this->getErrorMessage());
|
||||
throw new CannotWriteFileException($this->getExceptionMessage());
|
||||
case \UPLOAD_ERR_NO_TMP_DIR:
|
||||
throw new NoTmpDirFileException($this->getErrorMessage());
|
||||
throw new NoTmpDirFileException($this->getExceptionMessage());
|
||||
case \UPLOAD_ERR_EXTENSION:
|
||||
throw new ExtensionFileException($this->getErrorMessage());
|
||||
throw new ExtensionFileException($this->getExceptionMessage());
|
||||
}
|
||||
|
||||
throw new FileException($this->getErrorMessage());
|
||||
throw new FileException($this->getExceptionMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a user-friendly error message for file upload issues, if any.
|
||||
*/
|
||||
public function getErrorMessage(): string
|
||||
{
|
||||
return \UPLOAD_ERR_OK !== $this->error ? $this->getExceptionMessage() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,7 +276,7 @@ class UploadedFile extends File
|
||||
/**
|
||||
* Returns an informative upload error message.
|
||||
*/
|
||||
public function getErrorMessage(): string
|
||||
private function getExceptionMessage(): string
|
||||
{
|
||||
static $errors = [
|
||||
\UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB).',
|
||||
|
||||
Reference in New Issue
Block a user