From f9cef159897624360bc24f1162ae17bf29ae9659 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 9 Jan 2014 12:43:33 -0800 Subject: [PATCH 1/4] [ticket/12104] Replace shadow topics $sql with $sql_array for better Event handling PHPBB3-12104 --- phpBB/viewforum.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 2c7a0a4829..587cb90a23 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -556,9 +556,16 @@ if (sizeof($topic_list)) // If we have some shadow topics, update the rowset to reflect their topic information if (sizeof($shadow_topic_list)) { - $sql = 'SELECT * - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', array_keys($shadow_topic_list)); + // SQL array for obtaining shadow topics + $sql_array = array( + 'SELECT' => 't.*', + 'FROM' => array( + TOPICS_TABLE => 't' + ), + 'LEFT_JOIN' => array(), + + 'WHERE' => $db->sql_in_set('t.topic_id', array_keys($shadow_topic_list)), + ); /** * Event to modify the SQL query before the shadowtopic data is retrieved @@ -567,9 +574,10 @@ if (sizeof($shadow_topic_list)) * @var string sql The SQL string to get the data of any shadowtopics * @since 3.1-A1 */ - $vars = array('sql'); + $vars = array('sql_array'); extract($phpbb_dispatcher->trigger_event('core.viewforum_get_shadowtopic_data', compact($vars))); + $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) From b95631b163e4f7248f194ba2b2d77be9d35a232c Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 9 Jan 2014 15:42:25 -0800 Subject: [PATCH 2/4] [ticket/12104] Remove empty LEFT_JOIN array PHPBB3-12104 --- phpBB/viewforum.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 587cb90a23..0e24404937 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -562,7 +562,6 @@ if (sizeof($shadow_topic_list)) 'FROM' => array( TOPICS_TABLE => 't' ), - 'LEFT_JOIN' => array(), 'WHERE' => $db->sql_in_set('t.topic_id', array_keys($shadow_topic_list)), ); From c2c677d4f2a6bbaf4b06e7adb6837693673d0b65 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 9 Jan 2014 15:45:24 -0800 Subject: [PATCH 3/4] [ticket/12104] Remove newline before WHERE parameter PHPBB3-12104 --- phpBB/viewforum.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 0e24404937..1ea6c08aa6 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -562,7 +562,6 @@ if (sizeof($shadow_topic_list)) 'FROM' => array( TOPICS_TABLE => 't' ), - 'WHERE' => $db->sql_in_set('t.topic_id', array_keys($shadow_topic_list)), ); From f14ca6df6fb6051a20ca9a1b53463581ba0c32ea Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 9 Jan 2014 15:48:32 -0800 Subject: [PATCH 4/4] [ticket/12104] Update the event's doc block to reflect new variable PHPBB3-12104 --- phpBB/viewforum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 1ea6c08aa6..9a229a0770 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -569,7 +569,7 @@ if (sizeof($shadow_topic_list)) * Event to modify the SQL query before the shadowtopic data is retrieved * * @event core.viewforum_get_shadowtopic_data - * @var string sql The SQL string to get the data of any shadowtopics + * @var array sql_array SQL array to get the data of any shadowtopics * @since 3.1-A1 */ $vars = array('sql_array');