mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-06 07:35:29 +02:00
Merge pull request #2336 from Nicofuma/ticket/12413
[ticket/12413] Fatal Error log created for feed.php file
This commit is contained in:
commit
fa1ac3c54d
@ -73,9 +73,6 @@ if ($feed === false)
|
|||||||
trigger_error('NO_FEED');
|
trigger_error('NO_FEED');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get attachments for this feed
|
|
||||||
$feed->fetch_attachments();
|
|
||||||
|
|
||||||
// Open Feed
|
// Open Feed
|
||||||
$feed->open();
|
$feed->open();
|
||||||
|
|
||||||
@ -111,7 +108,7 @@ while ($row = $feed->get_item())
|
|||||||
'title' => censor_text($title),
|
'title' => censor_text($title),
|
||||||
'category' => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '',
|
'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'] : '',
|
'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' => '',
|
'statistics' => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
83
phpBB/phpbb/feed/attachments_base.php
Normal file
83
phpBB/phpbb/feed/attachments_base.php
Normal file
@ -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];
|
||||||
|
}
|
||||||
|
}
|
@ -80,6 +80,8 @@ class forum extends \phpbb\feed\post_base
|
|||||||
|
|
||||||
unset($forum_ids_passworded);
|
unset($forum_ids_passworded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent::open();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_sql()
|
function get_sql()
|
||||||
|
@ -14,7 +14,7 @@ namespace phpbb\feed;
|
|||||||
*
|
*
|
||||||
* @package phpBB3
|
* @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 $num_items = 'feed_limit_post';
|
||||||
var $attachments = array();
|
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'] : '');
|
. (($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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,8 @@ class topic extends \phpbb\feed\post_base
|
|||||||
|
|
||||||
unset($forum_ids_passworded);
|
unset($forum_ids_passworded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent::open();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_sql()
|
function get_sql()
|
||||||
|
@ -14,7 +14,7 @@ namespace phpbb\feed;
|
|||||||
*
|
*
|
||||||
* @package phpBB3
|
* @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';
|
var $num_items = 'feed_limit_topic';
|
||||||
|
|
||||||
|
1506
tests/functional/feed_test.php
Normal file
1506
tests/functional/feed_test.php
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user