Skip to content

Commit 1020337

Browse files
committed
Use phpBB filesystem class
1 parent 02c8f9d commit 1020337

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

imcger/imgupload/config/services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ services:
1818
- '@auth'
1919
- '@language'
2020
- '@ext.manager'
21+
- '@filesystem'
2122
- '%core.root_path%'
2223
- '%core.php_ext%'
2324

imcger/imgupload/controller/save_rotated_img_controller.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class save_rotated_img_controller
3939
/** @var \phpbb\extension\manager */
4040
protected $ext_manager;
4141

42+
/** @var \phpbb\filesystem\filesystem */
43+
protected $filesystem;
44+
4245
/** @var string phpBB root path */
4346
protected $root_path;
4447

@@ -53,6 +56,7 @@ class save_rotated_img_controller
5356
* @param \phpbb\auth\auth $auth
5457
* @param \phpbb\language\language $language
5558
* @param \phpbb\extension\manager $ext_manager
59+
* @param \phpbb\filesystem\filesystem $filesystem
5660
* @param string $root_path
5761
* @param string $php_ext
5862
*/
@@ -64,6 +68,7 @@ public function __construct(
6468
\phpbb\auth\auth $auth,
6569
\phpbb\language\language $language,
6670
\phpbb\extension\manager $ext_manager,
71+
\phpbb\filesystem\filesystem $filesystem,
6772
$root_path,
6873
$php_ext
6974
)
@@ -75,6 +80,7 @@ public function __construct(
7580
$this->auth = $auth;
7681
$this->language = $language;
7782
$this->ext_manager = $ext_manager;
83+
$this->filesystem = $filesystem;
7884
$this->root_path = $root_path;
7985
$this->php_ext = $php_ext;
8086

@@ -145,7 +151,7 @@ public function save_image()
145151
$image_file_path = $this->root_path . trim($this->config['upload_path'], '/') . '/' . $img_data['physical_filename'];
146152
$thumb_file_path = $this->root_path . trim($this->config['upload_path'], '/') . '/' . 'thumb_' . $img_data['physical_filename'];
147153

148-
if (file_exists($image_file_path))
154+
if ($this->filesystem->exists($image_file_path))
149155
{
150156
$img_data['filesize'] = $this->rotate_image($image_file_path, $img_rotate_deg);
151157
}
@@ -154,7 +160,7 @@ public function save_image()
154160
$this->json_response(4, $ext_display_name, $this->language->lang('IUL_IMG_NOT_EXIST'));
155161
}
156162

157-
if ($img_data['thumbnail'] && file_exists($thumb_file_path))
163+
if ($img_data['thumbnail'] && $this->filesystem->exists($thumb_file_path))
158164
{
159165
$this->rotate_image($thumb_file_path, $img_rotate_deg);
160166
}

0 commit comments

Comments
 (0)