From 4fed28577902a363749dc3f63df1c02f06d6d051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Fri, 15 Jun 2018 15:58:16 +0200 Subject: [PATCH] [ticket/15692] Reduce storage api calls PHPBB3-15692 --- phpBB/phpbb/storage/storage.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/storage/storage.php b/phpBB/phpbb/storage/storage.php index b9c20ed7cf..f2fabdcb94 100644 --- a/phpBB/phpbb/storage/storage.php +++ b/phpBB/phpbb/storage/storage.php @@ -154,7 +154,7 @@ class storage */ public function exists($path) { - return $this->get_adapter()->exists($path); + return $this->is_tracked($path); } /** @@ -376,6 +376,23 @@ class storage $this->cache->destroy('_storage_' . $this->get_name() . '_numfiles'); } + public function is_tracked($path) + { + $sql_ary = array( + 'file_path' => $path, + 'storage' => $this->get_name(), + ); + + // Get file, if exist update filesize, if not add new record + $sql = 'SELECT file_id FROM ' . $this->storage_table . ' + WHERE ' . $this->db->sql_build_array('SELECT', $sql_ary); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return ($row) ? true : false; + } + /** * Rename tracked file *