From e7f970e26d636d69ea742bf591dc5fc9dc15a0a9 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 16 Apr 2014 23:41:10 +0200 Subject: [ticket/12413] Fatal Error for feed.php?mode=forums https://tracker.phpbb.com/browse/PHPBB3-12413 http://area51.phpbb.com/phpBB/viewtopic.php?f=81&t=45475 PHPBB3-12413 --- phpBB/phpbb/feed/attachments_base.php | 81 +++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 phpBB/phpbb/feed/attachments_base.php (limited to 'phpBB/phpbb/feed/attachments_base.php') diff --git a/phpBB/phpbb/feed/attachments_base.php b/phpBB/phpbb/feed/attachments_base.php new file mode 100644 index 0000000000..b497d3b3f7 --- /dev/null +++ b/phpBB/phpbb/feed/attachments_base.php @@ -0,0 +1,81 @@ +fetch_attachments(); + } + + /** + * Retrieve the list of attachments that may be displayed + */ + function fetch_attachments() + { + global $db; + + $sql_array = array( + 'SELECT' => 'a.*', + 'FROM' => array( + ATTACHMENTS_TABLE => 'a' + ), + 'WHERE' => 'a.in_message = 0 ', + 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC', + ); + + if (isset($this->topic_id)) + { + $sql_array['WHERE'] .= 'AND a.topic_id = ' . (int)$this->topic_id; + } + else if (isset($this->forum_id)) + { + $sql_array['LEFT_JOIN'] = array( + array( + 'FROM' => array(TOPICS_TABLE => 't'), + 'ON' => 'a.topic_id = t.topic_id', + ) + ); + $sql_array['WHERE'] .= 'AND t.forum_id = ' . (int)$this->forum_id; + } + + $sql = $db->sql_build_query('SELECT', $sql_array); + $result = $db->sql_query($sql); + + // Set attachments in feed items + while ($row = $db->sql_fetchrow($result)) + { + $this->attachments[$row['post_msg_id']][] = $row; + } + $db->sql_freeresult($result); + } + + /** + * Get attachments related to a given post + * + * @param $post_id Post id + * @return mixed Attachments related to $post_id + */ + function get_attachments($post_id) + { + return $this->attachments[$post_id]; + } +} -- cgit v1.2.1 From edf0fd0fbd4e76e57bb3899aaffeee730eec8261 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Tue, 22 Apr 2014 19:07:03 +0200 Subject: [ticket/12413] Adding the missing visibilities PHPBB3-12413 --- phpBB/phpbb/feed/attachments_base.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'phpBB/phpbb/feed/attachments_base.php') diff --git a/phpBB/phpbb/feed/attachments_base.php b/phpBB/phpbb/feed/attachments_base.php index b497d3b3f7..b8c72a7fb1 100644 --- a/phpBB/phpbb/feed/attachments_base.php +++ b/phpBB/phpbb/feed/attachments_base.php @@ -21,15 +21,10 @@ abstract class attachments_base extends \phpbb\feed\base */ protected $attachments = array(); - function open() - { - $this->fetch_attachments(); - } - /** * Retrieve the list of attachments that may be displayed */ - function fetch_attachments() + protected function fetch_attachments() { global $db; @@ -68,13 +63,18 @@ abstract class attachments_base extends \phpbb\feed\base $db->sql_freeresult($result); } + public function open() + { + $this->fetch_attachments(); + } + /** * Get attachments related to a given post * - * @param $post_id Post id - * @return mixed Attachments related to $post_id + * @param $post_id int Post id + * @return mixed Attachments related to $post_id */ - function get_attachments($post_id) + public function get_attachments($post_id) { return $this->attachments[$post_id]; } -- cgit v1.2.1 From 7d8d8394fc36b1564ea083447329ab9f54a3db01 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Fri, 25 Apr 2014 17:00:24 +0200 Subject: [ticket/12413] Fix: coding style PHPBB3-12413 --- phpBB/phpbb/feed/attachments_base.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'phpBB/phpbb/feed/attachments_base.php') diff --git a/phpBB/phpbb/feed/attachments_base.php b/phpBB/phpbb/feed/attachments_base.php index b8c72a7fb1..e61d637afa 100644 --- a/phpBB/phpbb/feed/attachments_base.php +++ b/phpBB/phpbb/feed/attachments_base.php @@ -26,8 +26,6 @@ abstract class attachments_base extends \phpbb\feed\base */ protected function fetch_attachments() { - global $db; - $sql_array = array( 'SELECT' => 'a.*', 'FROM' => array( @@ -39,7 +37,7 @@ abstract class attachments_base extends \phpbb\feed\base if (isset($this->topic_id)) { - $sql_array['WHERE'] .= 'AND a.topic_id = ' . (int)$this->topic_id; + $sql_array['WHERE'] .= 'AND a.topic_id = ' . (int) $this->topic_id; } else if (isset($this->forum_id)) { @@ -49,22 +47,25 @@ abstract class attachments_base extends \phpbb\feed\base 'ON' => 'a.topic_id = t.topic_id', ) ); - $sql_array['WHERE'] .= 'AND t.forum_id = ' . (int)$this->forum_id; + $sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id; } - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query($sql); // Set attachments in feed items - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $this->attachments[$row['post_msg_id']][] = $row; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); } - + /** + * {@inheritDoc} + */ public function open() { + parent::open(); $this->fetch_attachments(); } -- cgit v1.2.1 From 80b4a7f33726280f523ee84f11f11e852ef71db7 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Tue, 29 Apr 2014 23:27:43 +0200 Subject: [ticket/12413] Fix coding style PHPBB3-12413 --- phpBB/phpbb/feed/attachments_base.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/feed/attachments_base.php') diff --git a/phpBB/phpbb/feed/attachments_base.php b/phpBB/phpbb/feed/attachments_base.php index e61d637afa..a9a8175928 100644 --- a/phpBB/phpbb/feed/attachments_base.php +++ b/phpBB/phpbb/feed/attachments_base.php @@ -60,6 +60,7 @@ abstract class attachments_base extends \phpbb\feed\base } $this->db->sql_freeresult($result); } + /** * {@inheritDoc} */ -- cgit v1.2.1