aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/feed.php
diff options
context:
space:
mode:
authorerangamapa <erangamapa@gmail.com>2013-03-17 02:17:52 +0530
committerDhruv <dhruv.goel92@gmail.com>2013-09-15 15:42:09 +0530
commit098fdf95aea8cca5bf738d3b6a2121702c3c4c49 (patch)
tree468123bed3f955009825eb7f37b462d8d5747c84 /phpBB/feed.php
parent224c8633777720e271210d8e845ab0c0c0aa2882 (diff)
downloadforums-098fdf95aea8cca5bf738d3b6a2121702c3c4c49.tar
forums-098fdf95aea8cca5bf738d3b6a2121702c3c4c49.tar.gz
forums-098fdf95aea8cca5bf738d3b6a2121702c3c4c49.tar.bz2
forums-098fdf95aea8cca5bf738d3b6a2121702c3c4c49.tar.xz
forums-098fdf95aea8cca5bf738d3b6a2121702c3c4c49.zip
[ticket/11271] Fetched feed attachments before loop.
Fetched feed attachments before looping through feed items and send them to method 'feed_generate_content' for each feed item. PHPBB3-11271
Diffstat (limited to 'phpBB/feed.php')
-rw-r--r--phpBB/feed.php54
1 files changed, 38 insertions, 16 deletions
diff --git a/phpBB/feed.php b/phpBB/feed.php
index 5a42ca6c37..570240fe93 100644
--- a/phpBB/feed.php
+++ b/phpBB/feed.php
@@ -72,6 +72,40 @@ if ($feed === false)
trigger_error('NO_FEED');
}
+$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 ($topic_id)
+{
+ $sql_array['WHERE'] .= 'AND a.topic_id = ' . $topic_id;
+}
+else if ($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 = ' . $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))
+{
+ $attachments[$row['post_msg_id']][] = $row;
+}
+$db->sql_freeresult($result);
+
// Open Feed
$feed->open();
@@ -107,7 +141,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(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], $row['post_id'], $row['post_attachment'])),
+ 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], (($row['post_attachment']) ? $attachments[$row['post_id']] : null))),
'statistics' => '',
);
@@ -274,7 +308,7 @@ function feed_format_date($time)
/**
* Generate text content
**/
-function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $post_id, $post_attachment)
+function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $post_attachments)
{
global $user, $db, $config, $phpbb_root_path, $phpEx, $board_url;
@@ -324,22 +358,10 @@ function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $
$content = preg_replace( '#<(script|iframe)([^[]+)\1>#siU', ' <strong>$1</strong> ', $content);
// Parse inline images to display with the feed
- if ($post_attachment)
+ if ($post_attachments != null)
{
- $sql = 'SELECT *
- FROM ' . ATTACHMENTS_TABLE . '
- WHERE post_msg_id = ' . $post_id . '
- AND in_message = 0
- ORDER BY filetime DESC, post_msg_id ASC';
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $attachments[$row['post_msg_id']][] = $row;
- }
- $db->sql_freeresult($result);
$update_count = array();
- parse_attachments($forum_id, $content, $attachments[$post_id], $update_count);
+ parse_attachments($forum_id, $content, $post_attachments, $update_count);
}
// Remove Comments from inline attachments [ia]