From 018528b0623dab807c478e2bd3345606faa95ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sun, 19 Mar 2017 17:29:11 +0100 Subject: [PATCH 1/3] [ticket/15134] Replace php native functions for filesystem service methods PHPBB3-15134 --- phpBB/phpbb/avatar/driver/upload.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index 2640e1ad1e..93b2353098 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -281,9 +281,13 @@ class upload extends \phpbb\avatar\driver\driver ); extract($this->dispatcher->trigger_event('core.avatar_driver_upload_delete_before', compact($vars))); - if (!sizeof($error) && file_exists($filename)) + if (!sizeof($error) && $this->filesystem->exists($filename)) { - @unlink($filename); + try + { + $this->filesystem->remove($filename); + } + catch(\phpbb\filesystem\exception\filesystem_exception $e) {} } return true; @@ -304,6 +308,6 @@ class upload extends \phpbb\avatar\driver\driver */ protected function can_upload() { - return (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && $this->filesystem->is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')); + return ($this->filesystem->exists($this->phpbb_root_path . $this->config['avatar_path']) && $this->filesystem->is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')); } } From 29ce6e63527e395f086aff7936c8c4f32086956c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sun, 19 Mar 2017 19:26:08 +0100 Subject: [PATCH 2/3] [ticket/15134] Follow coding guideliness PHPBB3-15134 --- phpBB/phpbb/avatar/driver/upload.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index 93b2353098..607db9067c 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -287,7 +287,10 @@ class upload extends \phpbb\avatar\driver\driver { $this->filesystem->remove($filename); } - catch(\phpbb\filesystem\exception\filesystem_exception $e) {} + catch (\phpbb\filesystem\exception\filesystem_exception $e) + { + // Do nothing + } } return true; From 27ab639fbea160af2a003cb6ce3b2394195da297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Mon, 20 Mar 2017 11:49:34 +0100 Subject: [PATCH 3/3] [ticket/15134] Return false if error PHPBB3-15134 --- phpBB/phpbb/avatar/driver/upload.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index 607db9067c..4effa4c410 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -286,14 +286,15 @@ class upload extends \phpbb\avatar\driver\driver try { $this->filesystem->remove($filename); + return true; } catch (\phpbb\filesystem\exception\filesystem_exception $e) { - // Do nothing + // Fail is covered by return statement below } } - return true; + return false; } /**