diff options
author | Andreas Gohr <andi@splitbrain.org> | 2005-09-18 14:10:08 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2005-09-18 14:10:08 +0200 |
commit | d437bcc4a25f62fad65e625f4bc13cab8873f994 (patch) | |
tree | 8036cb2794b499b87ff9d3a193148e181e9a8914 /feed.php | |
parent | b7af031cf80338a83187f1fb75cfacf0bb24c103 (diff) | |
download | rpg-d437bcc4a25f62fad65e625f4bc13cab8873f994.tar.gz rpg-d437bcc4a25f62fad65e625f4bc13cab8873f994.tar.bz2 |
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
Diffstat (limited to 'feed.php')
-rw-r--r-- | feed.php | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -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('|<h([1-9])>(.*?)</h\1>|', $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); } |