1
mudikins
News 1.44 RSS bug?
  • 2005/12/19 19:09

  • mudikins

  • Just popping in

  • Posts: 7

  • Since: 2005/11/29


Looks like template caching or something is messing up the News 1.44 RSS feed... if I open an RSS feed from one category, then within a certain amount of time open an RSS feed from a different category, it will open the cached version of the first (wrong) category.

I hope I described this correctly.

I tried disabling caching in backendt.php, but what I did didn't work... any suggestions? Bugfixes? Whatever?

2
mudikins
Re: News 1.44 RSS bug?
  • 2005/12/19 19:17

  • mudikins

  • Just popping in

  • Posts: 7

  • Since: 2005/11/29


I fixed this by changing this:
Quote:
$tpl->xoops_setCaching(some number here);
$tpl->xoops_setCacheTime(some number here);


to this:
Quote:
$tpl->xoops_setCaching(0);
$tpl->xoops_setCacheTime(0);


It works, but I don't like it for obvious reasons. Any better way to do it?

3
Rhomal
Re: News 1.44 RSS bug?
  • 2005/12/19 19:38

  • Rhomal

  • Quite a regular

  • Posts: 274

  • Since: 2004/10/5


I posted about this bug both public and private but sadly didnt not get a reply :(

If someone does have a perm soluation please do post, thanks!

4
StarShaper
Re: News 1.44 RSS bug?
  • 2005/12/24 6:23

  • StarShaper

  • Just popping in

  • Posts: 29

  • Since: 2005/7/25


I just have made an update from 1.42 to 1.44. I can confirm your problem. The reason for this behaviour is that the news module is caching RSS files.

Take a look at the function in backendt.php:

...
header ('Content-Type:text/xml; charset=utf-8');
$story = new NewsStory();    
$tpl = new XoopsTpl();
$tpl->xoops_setCaching(2);
$tpl->xoops_setCacheTime(3600);
if (!
$tpl->is_cached('db:system_rss.html')) {
    
$xt = new NewsTopicT($topicid);
...
}
$tpl->display('db:system_rss.html');


If you set caching for this template on the if clause won't be called and you always get the last result of the category which has been cached. This cached file is:

--> %%0B^0B9^0B9E10B9%%db%3Asystem_rss.html

One possibility to solve this problem is to disable caching. But usually it is better to make an individual rss file for every category. It seems that the template engine only generates one file. The file above. This is insufficient for caching.

I'm not a php coder but the php syntax is very similar to C/C++. So it isn't really difficult to solve this problem. The Smarty template engine supports CacheID's. It is the second parameter. So we only have to give the name of the actual category as the cache id.

Replace the last code in backendt.php through this one:

header ('Content-Type:text/xml; charset=utf-8');
$story = new NewsStory();
$tpl = new XoopsTpl();
$tpl->xoops_setCaching(2);
$tpl->xoops_setCacheTime(3600);
$xt = new NewsTopic($topicid);
if (!
$tpl->is_cached('db:system_rss.html'htmlspecialchars($xt->topic_title(), ENT_QUOTES) )) {
    
$sarray $story->getAllPublished($newsnumber0$restricted$topicid);
    if (
is_array($sarray) && count($sarray)>0) {
        
$sitename htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES);
        
$slogan htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES);
        
$tpl->assign('channel_title'xoops_utf8_encode($sitename));
        
$tpl->assign('channel_link'XOOPS_URL.'/');
        
$tpl->assign('channel_desc'xoops_utf8_encode($slogan));
        
$tpl->assign('channel_lastbuild'formatTimestamp(time(), 'rss'));
        
$tpl->assign('channel_webmaster'checkEmail($xoopsConfig['adminmail'],true));    // Fed up with spam
        
$tpl->assign('channel_editor'checkEmail($xoopsConfig['adminmail'],true));    // Fed up with spam
        
$tpl->assign('channel_category'htmlspecialchars($xt->topic_title(), ENT_QUOTES));
        
$tpl->assign('channel_generator''XOOPS');
        
$tpl->assign('channel_language'_LANGCODE);
        
$tpl->assign('image_url'XOOPS_URL.'/images/logo.gif');
        
$dimention getimagesize(XOOPS_ROOT_PATH.'/images/logo.gif');
        if (empty(
$dimention[0])) {
            
$width 88;
        } else {
            
$width = ($dimention[0] > 144) ? 144 $dimention[0];
        }
        if (empty(
$dimention[1])) {
            
$height 31;
        } else {
            
$height = ($dimention[1] > 400) ? 400 $dimention[1];
        }
        
$tpl->assign('image_width'$width);
        
$tpl->assign('image_height'$height);
        
$count $sarray;
        foreach (
$sarray as $story) {
            
$storytitle htmlspecialchars($story->title(), ENT_QUOTES);
            
$description htmlspecialchars($story->hometext(), ENT_QUOTES);
            
$tpl->append('items', array('title' => xoops_utf8_encode($storytitle), 'link' => XOOPS_URL.'/modules/news/article.php?storyid='.$story->storyid(), 'guid' => XOOPS_URL.'/modules/news/article.php?storyid='.$story->storyid(), 'pubdate' => formatTimestamp($story->published(), 'rss'), 'description' => xoops_utf8_encode($description)));
        }
    }
    
$tpl->display('db:system_rss.html'htmlspecialchars($xt->topic_title(), ENT_QUOTES));
}
else
    
$tpl->display('db:system_rss.html'htmlspecialchars($xt->topic_title(), ENT_QUOTES));
?>


This solves the bug in the news module.

cu

5
Rhomal
Re: News 1.44 RSS bug?
  • 2005/12/29 0:56

  • Rhomal

  • Quite a regular

  • Posts: 274

  • Since: 2004/10/5


Thank you so very much for this fix!

Login

Who's Online

173 user(s) are online (106 user(s) are browsing Support Forums)


Members: 0


Guests: 173


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits