From 84e0f5a2ebf8477a70c185c6496a02f0e2ed8918 Mon Sep 17 00:00:00 2001 From: kasimi Date: Thu, 17 Oct 2019 12:54:42 +0200 Subject: [ticket/16183] Add core.generate_smilies_count_sql_before PHPBB3-16183 --- phpBB/includes/functions_posting.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 2cce77e092..0fb4ef2c49 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -52,9 +52,28 @@ function generate_smilies($mode, $forum_id) page_header($user->lang['SMILIES']); - $sql = 'SELECT COUNT(smiley_id) AS item_count - FROM ' . SMILIES_TABLE . ' - GROUP BY smiley_url'; + $sql_ary = [ + 'SELECT' => 'COUNT(s.smiley_id) AS item_count', + 'FROM' => [ + SMILIES_TABLE => 's', + ], + 'GROUP_BY' => 's.smiley_url', + ]; + + /** + * Modify SQL query that fetches the total number of smilies in window mode + * + * @event core.generate_smilies_count_sql_before + * @var int forum_id Forum where smilies are generated + * @var array sql_ary Array with the SQL query + * @since 3.2.9-RC1 + */ + $vars = [ + 'forum_id', + 'sql_ary', + ]; + extract($phpbb_dispatcher->trigger_event('core.generate_smilies_count_sql_before', compact($vars))); + $result = $db->sql_query($sql, 3600); $smiley_count = 0; -- cgit v1.2.1 From 6df8b7f3678ba242480a0c50b651b1653a0d2d6b Mon Sep 17 00:00:00 2001 From: kasimi Date: Sun, 20 Oct 2019 20:50:34 +0200 Subject: [ticket/16183] Generate SQL query from array PHPBB3-16183 --- phpBB/includes/functions_posting.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 0fb4ef2c49..844481f1bd 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -74,6 +74,7 @@ function generate_smilies($mode, $forum_id) ]; extract($phpbb_dispatcher->trigger_event('core.generate_smilies_count_sql_before', compact($vars))); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql, 3600); $smiley_count = 0; -- cgit v1.2.1