Administrator
- Join Date:
- Sep 2009
- Location:
- Stuart, FL
- Posts:
- 14,065
- Plugin Contributions:
- 56
SitemapXML v.2
yesaul:
Hello, another one short notice...
As in "box_news" table all datetime columns (not only 'news_modified_date') can be NULL, it would be wise to use IFNULL function also for checking 'news_published_date' column in sql-queries in includes\modules\pages\sitemapxml\sitemapxml_boxnews.php file:
echo '<h3>' . TEXT_HEAD_BOXNEWS . '</h3>';
$last_date = $db->Execute(
"SELECT MAX(GREATEST(n.news_added_date, IFNULL(n.news_modified_date, '0001-01-01 00:00:00'), IFNULL(n.news_published_date, '0001-01-01 00:00:00'))) AS last_date
FROM " . TABLE_BOX_NEWS . " n
WHERE n.news_status = 1
AND NOW() BETWEEN n.news_start_date AND n.news_end_date"
);
$table_status = $db->Execute("SHOW TABLE STATUS LIKE '" . TABLE_BOX_NEWS . "'");
$last_date = max($table_status->fields['Update_time'], $last_date->fields['last_date']);
if ($sitemapXML->SitemapOpen('boxnews', $last_date)) {
$news = $db->Execute(
"SELECT n.box_news_id, GREATEST(n.news_added_date, IFNULL(n.news_modified_date, '0001-01-01 00:00:00'), IFNULL(n.news_published_date, '0001-01-01 00:00:00')) AS last_date, nc.languages_id AS language_id
FROM " . TABLE_BOX_NEWS . " n
INNER JOIN " . TABLE_BOX_NEWS_CONTENT . " nc
ON n.box_news_id = nc.box_news_id
AND nc.languages_id IN (" . $sitemapXML->getLanguagesIDs() . ")
AND nc.news_title != ''
WHERE n.news_status = 1
AND NOW() BETWEEN n.news_start_date AND n.news_end_date" .
(SITEMAPXML_BOXNEWS_ORDERBY !== '' ? ' ORDER BY ' . SITEMAPXML_BOXNEWS_ORDERBY : '')
);
$sitemapXML->SitemapSetMaxItems($news->RecordCount());
foreach ($news as $next_item) {
$sitemapXML->writeItem(FILENAME_MORE_NEWS, 'news_id=' . $next_item['box_news_id'], $next_item['language_id'], $next_item['last_date'], SITEMAPXML_BOXNEWS_CHANGEFREQ);
}
$sitemapXML->SitemapClose();
unset($news);
}
>
> This will help to avoid PHP-warnings by passing ***NULL*** as parameter
>
> As "*box_news*" table is an 'external' table for this addon (created in another module), no additional verification can be excessive, I think
Yet another GitHub issue opened: <https://github.com/lat9/sitemapxml/issues/53>