From 80e5fe255bc11030d6c23780ef42e8f57a0ab6ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sun, 10 Jun 2018 13:57:07 +0200 Subject: [PATCH] [ticket/15342] Add method to storage to get number of tracked files PHPBB3-15342 --- phpBB/phpbb/storage/storage.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/storage/storage.php b/phpBB/phpbb/storage/storage.php index a9f48827ae..16920ee129 100644 --- a/phpBB/phpbb/storage/storage.php +++ b/phpBB/phpbb/storage/storage.php @@ -299,8 +299,6 @@ class storage /** * Get total storage size. * - * @param string $path The file - * * @return int Size in bytes */ public function get_size() @@ -314,4 +312,21 @@ class storage return $row; } + + /** + * Get number of storage files. + * + * @return int Number of files + */ + public function get_num_files() + { + $sql = 'SELECT COUNT(file_id) AS total + FROM ' . $this->storage_table . " + WHERE storage = '" . $this->get_name() . "'"; + $result = $this->db->sql_query($sql); + $total = (int) $this->db->sql_fetchfield('total'); + $this->db->sql_freeresult($result); + + return $total; + } }