summaryrefslogtreecommitdiff
path: root/feed.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2005-09-18 14:10:08 +0200
committerAndreas Gohr <andi@splitbrain.org>2005-09-18 14:10:08 +0200
commitd437bcc4a25f62fad65e625f4bc13cab8873f994 (patch)
tree8036cb2794b499b87ff9d3a193148e181e9a8914 /feed.php
parentb7af031cf80338a83187f1fb75cfacf0bb24c103 (diff)
downloadrpg-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.php31
1 files changed, 15 insertions, 16 deletions
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('|<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&amp;rev='.$recents[$id]['date'],true);
+ $item->link = wl($recent['id'],'do=revisions&amp;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&amp;'.$recents[$id]['date'],true);
+ $item->link = wl($recent['id'],'do=diff&amp;'.$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);
}