diff --git a/libraries/src/Filesystem/File.php b/libraries/src/Filesystem/File.php index c68d553f14a6e..e048e16777c5e 100644 --- a/libraries/src/Filesystem/File.php +++ b/libraries/src/Filesystem/File.php @@ -442,9 +442,10 @@ public static function append($file, $buffer, $use_streams = false) * @param boolean $allow_unsafe Allow the upload of unsafe files * @param boolean $safeFileOptions Options to InputFilter::isSafeFile * - * @return boolean True on success + * @return boolean True on success, throws exception on failure. * * @since 1.7.0 + * @throws \RuntimeException */ public static function upload($src, $dest, $use_streams = false, $allow_unsafe = false, $safeFileOptions = array()) { @@ -463,8 +464,7 @@ public static function upload($src, $dest, $use_streams = false, $allow_unsafe = if (!$isSafe) { Log::add(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR03', $dest), Log::WARNING, 'jerror'); - - return false; + throw new \RuntimeException(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR03', $dest), 1); } } @@ -486,8 +486,7 @@ public static function upload($src, $dest, $use_streams = false, $allow_unsafe = if (!$stream->upload($src, $dest)) { Log::add(Text::sprintf('JLIB_FILESYSTEM_ERROR_UPLOAD', $stream->getError()), Log::WARNING, 'jerror'); - - return false; + throw new \RuntimeException(Text::sprintf('JLIB_FILESYSTEM_ERROR_UPLOAD', $stream->getError()), 2); } return true; @@ -514,6 +513,7 @@ public static function upload($src, $dest, $use_streams = false, $allow_unsafe = else { Log::add(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR04', $src, $dest), Log::WARNING, 'jerror'); + throw new \RuntimeException(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR04', $src, $dest), 3); } } else @@ -528,11 +528,13 @@ public static function upload($src, $dest, $use_streams = false, $allow_unsafe = else { Log::add(Text::_('JLIB_FILESYSTEM_ERROR_WARNFS_ERR01'), Log::WARNING, 'jerror'); + throw new \RuntimeException(Text::_('JLIB_FILESYSTEM_ERROR_WARNFS_ERR01'), 4); } } else { Log::add(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR04', $src, $dest), Log::WARNING, 'jerror'); + throw new \RuntimeException(Text::sprintf('JLIB_FILESYSTEM_ERROR_WARNFS_ERR04', $src, $dest), 3); } }