1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-02 22:02:07 +02:00

[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
This commit is contained in:
Tristan Darricau 2014-04-16 23:41:10 +02:00 committed by Nicofuma
parent 76574d4b5e
commit e7f970e26d
6 changed files with 88 additions and 6 deletions

View File

@ -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' => '',
);

View File

@ -0,0 +1,81 @@
<?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();
function open()
{
$this->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];
}
}

View File

@ -80,6 +80,8 @@ class forum extends \phpbb\feed\post_base
unset($forum_ids_passworded);
}
$this->fetch_attachments();
}
function get_sql()

View File

@ -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();

View File

@ -83,6 +83,8 @@ class topic extends \phpbb\feed\post_base
unset($forum_ids_passworded);
}
$this->fetch_attachments();
}
function get_sql()

View File

@ -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';