Implement suggestion as per Bug #53305 - Send time of last item instead of current time in ATOM Feeds.

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10281 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Andreas Fischer 2009-11-20 21:14:34 +00:00
parent 4701b446f5
commit f5cbd9ea0e
2 changed files with 27 additions and 15 deletions

View file

@ -92,6 +92,7 @@
<li>[Fix] Allow ban reason and length to be selected and copied in ACP and subsilver2 MCP. (Bug #51095)</li> <li>[Fix] Allow ban reason and length to be selected and copied in ACP and subsilver2 MCP. (Bug #51095)</li>
<li>[Fix] Force full date for board online record date.</li> <li>[Fix] Force full date for board online record date.</li>
<li>[Fix] Correctly reset login keys if passed value is the current user. (Bug #54125)</li> <li>[Fix] Correctly reset login keys if passed value is the current user. (Bug #54125)</li>
<li>[Change] Send time of last item instead of current time in ATOM Feeds. (Bug #53305)</li>
</ul> </ul>
<a name="v305"></a><h3>1.ii. Changes since 3.0.5</h3> <a name="v305"></a><h3>1.ii. Changes since 3.0.5</h3>

View file

@ -41,6 +41,7 @@ $params = false;
// We do not use a template, therefore we simply define the global template variables here // We do not use a template, therefore we simply define the global template variables here
$global_vars = $item_vars = array(); $global_vars = $item_vars = array();
$feed_updated_time = 0;
// Generate params array for use in append_sid() to correctly link back to this page // Generate params array for use in append_sid() to correctly link back to this page
if ($forum_id || $topic_id || $mode) if ($forum_id || $topic_id || $mode)
@ -67,19 +68,6 @@ if ($feed === false)
// Open Feed // Open Feed
$feed->open(); $feed->open();
// Some default assignments
// FEED_IMAGE is not used (atom)
$global_vars = array(
'FEED_IMAGE' => ($user->img('site_logo', '', false, '', 'src')) ? $board_url . '/' . substr($user->img('site_logo', '', false, '', 'src'), strlen($phpbb_root_path)) : '',
'SELF_LINK' => feed_append_sid('/feed.' . $phpEx, $params),
'FEED_LINK' => $board_url . '/index.' . $phpEx,
'FEED_TITLE' => $config['sitename'],
'FEED_SUBTITLE' => $config['site_desc'],
'FEED_UPDATED' => $user->format_date(time(), $feed_date_format, true),
'FEED_LANG' => $user->lang['USER_LANG'],
'FEED_AUTHOR' => $config['sitename'],
);
// Iterate through items // Iterate through items
while ($row = $feed->get_item()) while ($row = $feed->get_item())
{ {
@ -102,9 +90,11 @@ while ($row = $feed->get_item())
$title = ($row[$feed->get('title')]) ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : ''); $title = ($row[$feed->get('title')]) ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : '');
$title = censor_text($title); $title = censor_text($title);
$item_time = (int) $row[$feed->get('date')];
$item_row = array( $item_row = array(
'author' => ($feed->get('creator') !== NULL) ? $row[$feed->get('creator')] : '', 'author' => ($feed->get('creator') !== NULL) ? $row[$feed->get('creator')] : '',
'pubdate' => $user->format_date($row[$feed->get('date')], $feed_date_format, true), 'pubdate' => $user->format_date($item_time, $feed_date_format, true),
'link' => '', 'link' => '',
'title' => censor_text($title), 'title' => censor_text($title),
'category' => ($config['feed_item_statistics']) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '', 'category' => ($config['feed_item_statistics']) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '',
@ -117,8 +107,29 @@ while ($row = $feed->get_item())
$feed->adjust_item($item_row, $row); $feed->adjust_item($item_row, $row);
$item_vars[] = $item_row; $item_vars[] = $item_row;
$feed_updated_time = max($feed_updated_time, $item_time);
} }
// If we do not have any items at all, sending the current time is better than sending no time.
if (!$feed_updated_time)
{
$feed_updated_time = time();
}
// Some default assignments
// FEED_IMAGE is not used (atom)
$global_vars = array(
'FEED_IMAGE' => ($user->img('site_logo', '', false, '', 'src')) ? $board_url . '/' . substr($user->img('site_logo', '', false, '', 'src'), strlen($phpbb_root_path)) : '',
'SELF_LINK' => feed_append_sid('/feed.' . $phpEx, $params),
'FEED_LINK' => $board_url . '/index.' . $phpEx,
'FEED_TITLE' => $config['sitename'],
'FEED_SUBTITLE' => $config['site_desc'],
'FEED_UPDATED' => $user->format_date($feed_updated_time, $feed_date_format, true),
'FEED_LANG' => $user->lang['USER_LANG'],
'FEED_AUTHOR' => $config['sitename'],
);
$feed->close(); $feed->close();
// Output page // Output page
@ -136,7 +147,7 @@ if ($config['gzip_compress'])
if (!defined('DEBUG_EXTRA') || !request_var('explain', 0) || !$auth->acl_get('a_')) if (!defined('DEBUG_EXTRA') || !request_var('explain', 0) || !$auth->acl_get('a_'))
{ {
header("Content-Type: application/atom+xml; charset=UTF-8"); header("Content-Type: application/atom+xml; charset=UTF-8");
header("Last-Modified: " . gmdate('D, d M Y H:i:s', time()) . ' GMT'); header("Last-Modified: " . gmdate('D, d M Y H:i:s', $feed_updated_time) . ' GMT');
} }
else else
{ {