diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-05-02 15:08:15 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-05-02 15:08:15 +0200 |
commit | fa1ac3c54d471f93b0fb10ef58aba13008dfa119 (patch) | |
tree | ab69fbc46128753bf4f2bd9968913635bf33fcea /phpBB | |
parent | 4f17d0653ab9eaa51c730f2e1f5ad6fbcfc279ba (diff) | |
parent | 8812cfcfbf4ae82eb0270c268d227ba729b42107 (diff) | |
download | forums-fa1ac3c54d471f93b0fb10ef58aba13008dfa119.tar forums-fa1ac3c54d471f93b0fb10ef58aba13008dfa119.tar.gz forums-fa1ac3c54d471f93b0fb10ef58aba13008dfa119.tar.bz2 forums-fa1ac3c54d471f93b0fb10ef58aba13008dfa119.tar.xz forums-fa1ac3c54d471f93b0fb10ef58aba13008dfa119.zip |
Merge pull request #2336 from Nicofuma/ticket/12413
[ticket/12413] Fatal Error log created for feed.php file
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/feed.php | 5 | ||||
-rw-r--r-- | phpBB/phpbb/feed/attachments_base.php | 83 | ||||
-rw-r--r-- | phpBB/phpbb/feed/forum.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/feed/post_base.php | 39 | ||||
-rw-r--r-- | phpBB/phpbb/feed/topic.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/feed/topic_base.php | 2 |
6 files changed, 90 insertions, 43 deletions
diff --git a/phpBB/feed.php b/phpBB/feed.php index 9ff8c66b9d..0c4cc32fdb 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -73,9 +73,6 @@ if ($feed === false) trigger_error('NO_FEED'); } -// Get attachments for this feed -$feed->fetch_attachments(); - // Open Feed $feed->open(); @@ -111,7 +108,7 @@ while ($row = $feed->get_item()) 'title' => censor_text($title), 'category' => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '', 'category_name' => ($config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '', - 'description' => censor_text($phpbb_feed_helper->generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], (($row['post_attachment']) ? $feed->attachments[$row['post_id']] : array()))), + 'description' => censor_text($phpbb_feed_helper->generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], ((isset($row['post_attachment']) && $row['post_attachment']) ? $feed->get_attachments($row['post_id']) : array()))), 'statistics' => '', ); diff --git a/phpBB/phpbb/feed/attachments_base.php b/phpBB/phpbb/feed/attachments_base.php new file mode 100644 index 0000000000..a9a8175928 --- /dev/null +++ b/phpBB/phpbb/feed/attachments_base.php @@ -0,0 +1,83 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\feed; + +/** +* Abstract class for feeds displaying attachments +* +* @package phpBB3 +*/ +abstract class attachments_base extends \phpbb\feed\base +{ + /** + * Attachments that may be displayed + */ + protected $attachments = array(); + + /** + * Retrieve the list of attachments that may be displayed + */ + protected function fetch_attachments() + { + $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 = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query($sql); + + // Set attachments in feed items + while ($row = $this->db->sql_fetchrow($result)) + { + $this->attachments[$row['post_msg_id']][] = $row; + } + $this->db->sql_freeresult($result); + } + + /** + * {@inheritDoc} + */ + public function open() + { + parent::open(); + $this->fetch_attachments(); + } + + /** + * Get attachments related to a given post + * + * @param $post_id int Post id + * @return mixed Attachments related to $post_id + */ + public function get_attachments($post_id) + { + return $this->attachments[$post_id]; + } +} diff --git a/phpBB/phpbb/feed/forum.php b/phpBB/phpbb/feed/forum.php index 85ecb60f7e..8e6490923d 100644 --- a/phpBB/phpbb/feed/forum.php +++ b/phpBB/phpbb/feed/forum.php @@ -80,6 +80,8 @@ class forum extends \phpbb\feed\post_base unset($forum_ids_passworded); } + + parent::open(); } function get_sql() diff --git a/phpBB/phpbb/feed/post_base.php b/phpBB/phpbb/feed/post_base.php index c797d6a8ca..de98f446f3 100644 --- a/phpBB/phpbb/feed/post_base.php +++ b/phpBB/phpbb/feed/post_base.php @@ -14,7 +14,7 @@ namespace phpbb\feed; * * @package phpBB3 */ -abstract class post_base extends \phpbb\feed\base +abstract class post_base extends \phpbb\feed\attachments_base { var $num_items = 'feed_limit_post'; var $attachments = array(); @@ -49,41 +49,4 @@ abstract class post_base extends \phpbb\feed\base . (($this->is_moderator_approve_forum($row['forum_id']) && $row['post_visibility'] !== ITEM_APPROVED) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POST_UNAPPROVED'] : ''); } } - - function fetch_attachments() - { - $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 = $this->db->sql_build_query('SELECT', $sql_array); - $result = $this->db->sql_query($sql); - - // Set attachments in feed items - while ($row = $this->db->sql_fetchrow($result)) - { - $this->attachments[$row['post_msg_id']][] = $row; - } - $this->db->sql_freeresult($result); - } } diff --git a/phpBB/phpbb/feed/topic.php b/phpBB/phpbb/feed/topic.php index a7acfb502f..fb49aa65cc 100644 --- a/phpBB/phpbb/feed/topic.php +++ b/phpBB/phpbb/feed/topic.php @@ -83,6 +83,8 @@ class topic extends \phpbb\feed\post_base unset($forum_ids_passworded); } + + parent::open(); } function get_sql() diff --git a/phpBB/phpbb/feed/topic_base.php b/phpBB/phpbb/feed/topic_base.php index 7e28e67b82..e8639a6fa6 100644 --- a/phpBB/phpbb/feed/topic_base.php +++ b/phpBB/phpbb/feed/topic_base.php @@ -14,7 +14,7 @@ namespace phpbb\feed; * * @package phpBB3 */ -abstract class topic_base extends \phpbb\feed\base +abstract class topic_base extends \phpbb\feed\attachments_base { var $num_items = 'feed_limit_topic'; |