From d437bcc4a25f62fad65e625f4bc13cab8873f994 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 18 Sep 2005 14:10:08 +0200 Subject: more efficient changelog reading for recent changes getRecents now reads the changelog backwards in 4KB chunks instead of loading the whole file into an array and rsort it. This should be more memory efficient (and probably faster) for large change logs. Note: the format of the array returned by getRecents changed slightly plugins relying on it need to be adjusted. Sorry. darcs-hash:20050918121008-7ad00-1fdba47d29b0c038c6e4e4edc1d4c93e5ba769e9.gz --- feed.php | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'feed.php') diff --git a/feed.php b/feed.php index 9454a9b95..c4c386261 100644 --- a/feed.php +++ b/feed.php @@ -98,19 +98,19 @@ function rssRecentChanges(&$rss,$num,$ltype,$ns){ //this can take some time if a lot of recaching has to be done @set_time_limit(90); // set max execution time - foreach(array_keys($recents) as $id){ + foreach($recents as $recent){ $item = new FeedItem(); - $item->title = $id; - $xhtml = p_wiki_xhtml($id,'',false); + $item->title = $recent['id']; + $xhtml = p_wiki_xhtml($recent['id'],'',false); if($conf['useheading']) { $matches = array(); if(preg_match('|(.*?)|', $xhtml, $matches)) $item->title = trim($matches[2]); } - if(!empty($recents[$id]['sum'])){ - $item->title .= ' - '.strip_tags($recents[$id]['sum']); + if(!empty($recent['sum'])){ + $item->title .= ' - '.strip_tags($recent['sum']); } $desc = cleanDesc($xhtml); @@ -120,27 +120,26 @@ function rssRecentChanges(&$rss,$num,$ltype,$ns){ switch ($ltype){ case 'page': - $item->link = wl($id,'rev='.$recents[$id]['date'],true); + $item->link = wl($recent['id'],'rev='.$recent['date'],true); break; case 'rev': - $item->link = wl($id,'do=revisions&rev='.$recents[$id]['date'],true); + $item->link = wl($recent['id'],'do=revisions&rev='.$recent['date'],true); break; case 'current': - $item->link = wl($id, '', true); + $item->link = wl($recent['id'], '', true); break; case 'diff': default: - $item->link = wl($id,'do=diff&'.$recents[$id]['date'],true); + $item->link = wl($recent['id'],'do=diff&'.$recent['date'],true); } $item->description = $desc; - $item->date = date('r',$recents[$id]['date']); - if(strpos($id,':')!==false){ - $item->category = substr($id,0,strrpos($id,':')); - } + $item->date = date('r',$recent['date']); + $cat = getNS($recent['id']); + if($cat) $item->category = $cat; $user = null; - $user = @$recents[$id]['user']; // the @ spares time repeating lookup + $user = @$recent['user']; // the @ spares time repeating lookup $item->author = ''; if($user){ @@ -148,12 +147,12 @@ function rssRecentChanges(&$rss,$num,$ltype,$ns){ $item->author = $userInfo['name']; if($guardmail) { //cannot obfuscate because some RSS readers may check validity - $item->authorEmail = $user.'@'.$recents[$id]['ip']; + $item->authorEmail = $user.'@'.$recent['ip']; }else{ $item->authorEmail = $userInfo['mail']; } }else{ - $item->authorEmail = 'anonymous@'.$recents[$id]['ip']; + $item->authorEmail = 'anonymous@'.$recent['ip']; } $rss->addItem($item); } -- cgit v1.2.3