Tag Archives: php

Of WordPress Caches and Fast PHPs

Example of a Plug-In Framework
Image via Wikipedia

Improving the speed of this and my two other sites has always been a major issue for me. Ever since I’ve switched to WordPress I’ve never been fully satisfied with the loading time and it seems I’ve been trying since forever to improve it.  My main methods were through the use of caching plugins such a WP-Cache and later on WP-Supercache and through manual performance tweaking. For a while it seemed to have worked to a degree until again my performance started dropping without any apparent reason.

It was at this point that I jumped to the VPS offering in a desperate attempt to get a site which loads in this century. Again, for a while things looked to be working well but now and then I would get horrible site b0rks which would take me hours to troubleshoot and resolve. The latest one was the reason I discovered that WP-Supercache didn’t play nice with VPS and thus I had to find something else, or live with it in a state of half-on.

To my delight, it seems that now there are new caching plugins available which I can try. I already mentioned Hyper Cache last time and today I discovered DB Cache (h/t  diTii.com) which seems particularly promising, especially because it works not by caching the fully loaded page, but rather by caching the Database queries themselves. This is an interesting take on caching since it now can improve performance for web crawlers as well as normal users. It also provides an extra benefit to me since I’m proving a gallery through the wordpress interface, and that means that the database queries for that are also cached.

So I ditched Super Cache from all my blogs and installed DB Cache on the Division by Zer0 and the Wesnoth Journals and Hyper Cache on the ACP. It’s of course always difficult to figure out how much difference a caching plugin has done to your site. As of now, I can’t say I notice a significant difference on loading times with DB Cache, however I did notice that the number of SQL queries that are made each time the page loads have dropped from >60 to about 15 which means that there some difference.

I  have also noticed anotther thing. In the past it could take a few seconds before my site even started loading (I guess while it was running the SQL queries) but after that it would be displayed very quickly (especially if it had been supercached) whereas now, the site starts loading very quickly but it takes more time to actually finish loading the content, in effect loading in parts (first the header, then the content etc) but in a way that is much more exaggerated than before.

Another thing I also decided to do is to finally activate Fast CGI for PHP. I hadn’t done this before as it wouldn’t have made much difference when Supercache was in use but now that the code is executed every time, it seems like a good idea. There’s also the added bonus that for VPS, the Xcache opcoder is available which further improves php performance when on high load. I do not think it will make much of a difference as my problem is not one of traffic but it may come in handy for those rare reddit moments.

As of now, the performance seems comparable to SuperCache times and I am hoping that this time I will not have any more random Internal Server Errors. Unfortunately my WordPress admin panel is still quite slower than I’d like with loading times randing frmo 5 to 15 seconds or more on occasion. I honestly don’t know what I can do to fix that but at least the admin panel is not something that is used very often.

Next step will be to see if Hyper Cache is better than DB Cache and if they can both play well together for a combined improvement.

So what do you think of the current speed?

Reblog this post [with Zemanta]

Is Dreamhost PS simply a way for Dreamhost to wash their hands of support?

Another month, another total crapdown of my sites which are hosted at the moment in Dreamhost’s Virtual Private Server offering. Once again the story begins in the usual way, all three of my  sites start puking Internal Server Errors all over the place which generally means that you are out of available RAM on your server. As I generally have about 180 Mb of availability, it would meant that either I have a huge amount of traffic that my Cache did not alleviate, or that something is going wrong on the server.

Going to the Resource Management, I am greeted by a classic figure

Up, up and away!
Up, up and away!

Having looked at my traffic already which had stayed steady in the last days, I know that this is certainly caused by some server/app malfunction. I know this from experience because the same goddamn problem happens to me so regularly, it’s not even funny anymore.

Since this happened while I was at work, I could troubleshoot it through the terminal as they have the ssh ports blocked so I had to wait until I came back home to investigate. Once I arrived, I fired up an ssh connection and checked what processes were running. As expected, it was PHP in CGI mode that was sucking my life’s blood.

Bad PHP. Baaaad!
Bad PHP. Baaaad!

Now mind you, I know all this because I’ve done it before where I had to google around and learn which commands to use to discover this info. The first time it happened, my ram usage was slowly creeping upwards in jumps of 30 Mb per week or so. After that, it simply happens all at once suddenly.

Now this is extremelly difficult to troubleshoot as you can have no idea what is causing this. A php5.cgi process can be anything under the sun that runs on PHP. Basically the whole wordpress interface or any of the dozens of plugins I have installed. You can kill the processes but this will not tell you what is happening and as it does not happen persistently, you can’t figure out which plugin might be causing it as shutting down a plugin does not stop the process and you don’t know when a process will get stuck again.

Unfortunately, and this is what is annoying me mostly, Dreamhost’s answer in the past has been that “It’s not our fault. Figure it out yourself”. A very unfulfilling answer as you might guess. But at least I know that I can expect very little help from them anymore so I avoid them.

So then I got to process killing. Unfortunately this time it seems that I had found a resistant strain of bug. As soon as I killed a process, 5 seconds later and a new one would be spawned, then another and another, until all my RAM was eaten up, no matter how much I increased my available. At this point I was fast reaching a deadend with my current skills as I couldn’t make the problem go away. I couldn’t even access my wordpress’ admin panel to disable plugins.

At this point, a former colleague suggested that this might be caused by a known PHP 5.2 bug which leaves processes hanging when done with them. I thought this might be a good thing to suggest to Dreamhost support to check so I fired up a support ticket.

A while later, I noticed that the RAM usage seemed to have dropped off so I thought that the problem had resolved itself. Unfortunately, while the main page was working the admin panel refused to work.

What admin panel. There's no such thing here
What admin panel. There's no such thing here

In desperation I did a quick server reboot and this was the point where the universe b0rked. After the reboot the whole site was off and my memory usage was stuck at around 20Mb which means that basically the whole thing failed to load. I fired a new ticket to support and waited.

I had to wait until today for an answer which basically told me that they managed to get the sites running again but advised me that my RAM usage was high so I should be checking that and no, they still can’t help me. Thanks Sherlock…

Looking around the interwebs however, I did stumble on a page in the dreamhost wiki where there was a note under supercache under caching that warned not to utilize the “super” part of WP Super Cache as it may drive resource use up on Private Servers. Gee, it would be nice if I knew of this a bit before. It would also be nice if Super Cache was not installed as part of the standard one-click installation of WordPress by Dreamhost which makes people assume that if anything, this plugin will be working well.

So I disabled Supercache on the Division by Zer0 and on the Wesnoth Journals and killed the remaining php processes. Lo and behold, no more processes were spawned. Unfortunately I was lucky that I could access the admin panel of these two sites after I increased my available resources to some ungawdly amount (1.5Gb of RAM or so). Unfortunately I was not so lucky in the Antichristian Phenomenon where not only I could not access the admin panel (never finished loading) anymore but the php processes kept spawning repeatedly and fast.

I tried deleting the plugin directory which led to my whole page being turned off. I tried fixing the .htaccess file. Nothing. Anything I tried, I couldn’t get the site to work properly. So I did the only thing I could do, renamed the whole wordpress directory and reinstalled again. At least this gave me an opportunity to finally rename the prefix of my database tables which helps avoid zero-day exploits by script kiddies. After a few hours, the site was back online.

Unfortunately the latest ordeal has really disillusioned me about Dreamhost’s PS and their support of those. From the 3 times I’ve contacted them about issues in randomly increasing resources, their reply has been “Deal with it yourself” because apparently now I control everything on the server and if anything goes wrong, it must be my own scripts or whatever. Seeing as I only use standard software like WordPress and Gallery this reply does not help me much.

Basically what seems to be happening is that when one decides to go to a PS in order to get a bit more speed (since shared hosting seems at time to be powered by hamsters) you’re on your own. If you’re not a (quite) techical user and have made the grave error of installing wordpress plugins on your site, you’re fucked. It seems that as far as Dreamhost is concerned, you shouldn’t be running plugins in the first place. Just vanilla WordPress for you.

Luckily for me, I know a few UNIX commands and how to use an ssh shell to do some troubleshooting. However even for me this kind of response is definitelly inferior. It would be nice if I could expect the Dreamhost support to ask questions like “Are you using WP Super Cache?”, or something similar. It would be nice to expect the support people to know of a few issues that generally might cause this kind of trouble. Is this is all too much to ask? Is it too much to ask to expect some attempt to help your users?

Last time I was delighted when the support tech gave me a simple command to help me trouble shoot but since then, all replies have been to explain me that it’s my own damn fault and this is very disheartening. To everyone considering the Private Server offering, if you’re not very technical and open to spending a few hours now and then to troubleshoot random issues that occur without you changing anything, then stay away from it and stick to simple shared hosting.

As for me, now my sites are all in the classic WP Cache mode and I’ve used Hyper Cache for the ACP to see how it goes. If all goes fine, I will switch everything to Hyper Cache and drop Super Cache altogether. ‘Till next time my site craps down…

Reblog this post [with Zemanta]

Barefoot Bum's New Slum

So, Barefoot bum’s new shiny, wordpress-powered self-hosted blog is now ready. I’ve finally finished with all the imports and the thing is ready to use. Of course the layout might change if Larry wishes but the thing is ready to be used.

Here’s a step-by-step summary of the setup process, just to get an overview of what was required. Keep in mind that for a new blog, you don’t need more than 10 or so of these.

Day 1

  1. Setup the domain to use php5 and not to use the needless www. prefix.
  2. Use One-click install to setup wordpress and wait 5 minutes.
  3. Setup WordPress password.
  4. Install One Click Plugin Updater through FTP.
  5. Deactivate Wp-Cache.
  6. Acticate the plugin Wp-Super Cache (Installed with wordpress).
  7. Delete all other plugins except Akismet and Hello Dolly (Just in case he likes it).
  8. Go to Settings > General and copy the blog desc from the original blog.
  9. In Settings, Go to Writing and add http://rpc.blogrolling.com/pinger/ to the ping so that the Atheist Blogroll is pinged.
  10. In Settings, Went to Discussion and deactivated the option to require one approved comment before posting it. Increased the number of links before moderation to 3.
  11. Updated the admin password to a temp password from the default of WP.
  12. Added a new admin user for me and Larry and deleted the default admin to avoid 0-day attacks.
  13. Went Manage > Import > Blogger. Sent email to Larry to authorize wordpress for his blogger account.
  14. Downloading some themes closer to the original blog style.
  15. Larry started the import procedure. It finished in about 10 minutes for 1200+ posts and 3000+ comments.
  16. Installed a cartload of plugins. Activated them.
  17. Set Permalinks to /blog/
  18. Setting up feedburner.
  19. Setup Yadis for blogger
  20. Setup Photodropper
  21. Enabled wp-supercache and .htaccess settings.
  22. Added Similar & Recent posts to sidebar and feed.
  23. Added Socrates Image to right sidebar.
  24. Extended sidebar size.
  25. Added We-Op-Ed image and rss for larry.
  26. Added Atheist Out Scarlet A.
  27. Added more wigets.
  28. Got stuck on how to import the IDC comments from blogger

Total time to setup all these, from start to finish, while also doing other stuff (like chatting on ICQ and reading blogs): 5 hours.

Day 2

  1. Finally received some help from Intense Debate on how to import IDC comments from blogspot to WordPress. I got a plugin which automates this in the mail.
  2. Plugin did not work as my host does not support a php function for security reasons.
  3. Contacted the Josh Fraser, the author of the plugin for help. He was amazingly responsive and helpful and provided me with an updated version of the plugin that could work around the php restriction. Josh you rock!
  4. Import went perfectly and all comments were back into wordpress. Unfortunately one post did not get them as the title has italics which wordpress stripped and they names did not match. Nevertheless, the rest worked. (I will do a follow-up post on this later)

Total time for this part: 1 hour.

Thoughts

Of course this process was a learning experience for me as not only did Larry have a pretty customized blog with widgets, images, etc) but he is also subscibed to a lot of services I do not have access (Feeburner, Scoutle, etc). Finally this was the first time I was trying to migrate ID comments from blogger to wordpress sso this took some extra research as well.

For someone who has a very simple and uncustomized blog, the migration time can be cut to 1/3 easily.

Nevertheless, this first experience will now allow me to know what I need and streamline the process. Specifically, there is the issue that I cannot setup a lot of stuff without access to one’s accounts, while other times I may need feedback.

This is the stuff I need to know in order to bug people less:

  • Feedburner password: In order to setup your blogspot feed to redirected to your new blog
  • WordPress.com password or API: So that I can setup your stats
  • Blogger password and username: So that I can start the import process and see the codes for any widgets you have on your sidebar (Mybloglog, scoutle etc)
  • If the codes are not visible through the blogger gadgets, I need to have them so that I can put them in the sidebar.
  • How do you want your tags and categories? As blogger only supports the generic “labels” which gets translated to wordpress categories, I need to know which ones (if any) to turn into tags
  • How do you want your permalink structure to be? By date (as in blogger, like a newspaper), with categories? with a custom text (like here under /blog/ ?)

All of these are information that I will need to set it up with the minimum of input from you. If any of these is missing, unfortunately I will have to ask you or you do it yourself (for the last two options I can just make a choice myself which you can change later on).

All in all, it went quite well and nothing horribly broke. So I’m quite glad. This will go much faster for someone with a more simple blog (as in, one hosted in wordpress.com, or not very customized blogspot)

I’m only a bit saddened that Larry chose not to start using it yet. If he keeps using his old blog, new comments and posts will be more difficult to transfer over as it cannot be done as part of a mass import.

Anyway, so what do you think?

Memberlist for Collaborative WordPress Blogs

In case you have a self-hosted Worpdress blog which has multiple authors you may have noticed that you don’t have lots of option to show information about each one. You can have each author create a post for himself and link it from the sidebar (Which is how Debunking Christianity does it), or you can create a page for each one after they provide you some information about themselves. Finally you can just leave each author’s page to be the default list of posts.

I wasn’t satisfied with either of those options so I looked around and found something better. So I have just finished with my custom member list setup at the Antichristian Phenomenon and I thought I’d share how I did it in case anyone wishes to implement it as well.

I started after I discovered this excellent guide from WPDesigner. Although I didn’t need the role manager, the rest of the instructions were perfect for my purpose. So I installed the necessary plugins (plus Register Plus to stop spammers registering) and started adding fields.

I then needed to display those fields in each author’s page somehow. In also wanted to do that without making the page totally different from the reast of the site. So I copied the archive.php file to author.php. I enterred the file and inserted all the necessary variables for my fields (as described in the guide) and deleted all archive loops except the author’s. This way the user visiting the author page could see the author profile but also a list of articles they have written.

The curauthor variable was used to grab information for some of the default fields. Unfortunately the Wp User Manager plugin does not give you the names for all the default wordpress fields but fortunately the documentation in curauthor is complete. I copied the html div the archive loop was in (so as to have the same format) and created a little list to show each author’s profile. Here’s how it looks like currently

Once that was done, I decided to see if I could also put comments in each author’s page as well. Unfortunately, just putting the php call for the comments template between the info and the archives did not work. Apparently WordPress does not expect comments on archive pages. However since I am using Intense Debate Comments at the moment I figured that they would be agnostic on where I am putting their script.

Unfortunately since IDC works through the wordpress comments template, where that does not appear, so does IDC. I managed after all to work around this by copying the script itself into the template. It wasn’t easy to get the code for this since IDC insists on providing you with a WP plugin instead of allowing you the option to paste the script somewhere. I finally got the code by telling IDC that I wanted to install it on my gallery. Unfortunately, the script then had the wrong ID and I needed the correct one to have my comments logged at the correct blog. For this, I was able to just edit the WP plugin code and copy the ID from there. So I pasted the script in the template itself and, lo and behold, it worked! I now had comment capability on each author’s profile page 😀

Once this was done, I made a quick test comment to check if it works and noticed that IDC was logging a strange page title for the Author’s profiles. It seems that my theme is using a title for author archives as if they were a category archive and that would not do. I thus edited my header file and placed an if statement to check if it is an author page. On a positive, I changed the page to show a more appropriate title as well as the author’s nickname (through curauth again). Unfortunately IDC still kept grabbing some weird titles (or not at all) but it’s not caused by the title anymore.

Finally, I listed the authors of the blog on the sidebar through a php widget, I looked at it, and it was nice.

An easier way to track your comments in your lifestream

I’ve been trying to find a better way to allow my lifestream to track my comments that would require less manual activity from me as well as allow me to track my own comments in my own site.

When I started using google reader to archive and extend my lifestream, I briefly considered using it to track my comments as well but I decided against it as I wanted first to see if comment services like Cocomments or co.mments might work (they didn’t). I also could not see a way so as to get it to track only the thread titles where I’ve placed a comment (so as to insert it in the areas I am commenting) or how to get my lifestream to display only my own comments.

However, after managing to set up google reader as an archive, I discovered how much more information an atom feed is providing, part or which is the author or each comment post. Just what I needed 🙂

I quickly cooked up a bit of code to just keep the comments left from me in each thread’s feed. This is something I was not able to achieve with Cocomments and co.mments as they don’t provide you with an actual feed of the whole thread but rather they copy the text and provide you with a raw html formatted to simply look separated.

There was also a little problem that many feeds included various words in the title like “Comments on:” which just looked bad when I appended my extra “Commented on:” text. I needed to find a way to remove them so a little search and the php solution appeared. Perfect!

Last step was to trigger it even if I happened to comment with differing case in my alias. the “if” statement is quite anal about cases that way. All in lowercase then.

The end result is this:

if ($feedurl == $greader_comment_feed) {
if ($author = $item->get_author()) {
$name = strtolower($author->get_name());
if ($name == get_option('greader_comments_author')) {
$item_title_crops = array('Comments on:', 'Comments for', 'Σχόλια στο:');
$item_title = str_replace($item_title_crops,'',$item->get_source()->get_title());}
else {continue;}}}

Finally, all you need to do is setup a google reader public tag where you’re grouping in all the thread feeds of any place you comment in. You can see mine here for example. Get the feed of it, put the number of items you want to see (the default is 20) by appending ?n=# in the end, where # is the number of items you want. In this case you should put something sufficiently large as this will also include comments from others.

Unfortunately, once this was setup, I realized a limitation of simplelife. It still could not limit the number of items you received by date. This is apparently on the “To Do” list but seeing how long it is taking for new versions to come out, my only option was to code it myself. And code it I did 🙂


if (get_option('simple_datelimit') > 0) {$date_limit = get_option('simple_datelimit')*86400;}
if ($item->get_date(U) < date(U)-$date_limit) {continue;}

Not only that, but I decided to try my hand at adding it as an option on the plugins config page in the WordPress admin panel. This is why the “get_option” exists instead of hard-coded entries :).

What it does it take the number of days the user submits and multiplies it by the number of seconds in a 24h day (86400). After that, for each entry, I get the date in a UNIX epoch format and compare if the day the item was recorded is within the number of days I’ve set. If not, I just skip the current iteration.

The new option to set how many days of history you need.

Finally, since I already managed to edit a new option in the config, I thought why not to create the option for the Google Reader feed as well. And lo! There was code.

The Google Reader Comments menu config

Since this wasn’t really hard, I’m planning now to prepare the plugin for general consumption and perhaps upload it to the Codex. I’ve was waiting for the 1.3 version to come out so that I could take that as it has some more improvements, but it just does not seem to be happening.

I also have some nice ideas to improve the config, like Ajax dynamic menus etc but that’s for the future.

Hacked Simplelife

At the request of a commenter who is also playing around with his simplelife plugin, I’m uploading my currently hacked version.

It’s not pretty so you won’t be able to change all options on the profile (only the ones included in the original) but I’ve included comments in the code so you should be able to figure out what is what.

You will need the Simplepie core WordPress plugin in order to use it.

Currently this version supports the following extras (Over the original simplelife)

In order to make it work for your own lifefeeds, you will need to edit the php code directly. You will have to edit either the ones I’ve set up (for example, change your digg username) or add your own.

To add a new feed you need to do the following

  • Add the new class for it (Defining colour, background and icon)
  • Add a new variable for the feed url
  • Add a new variable for the title that will be used in the chart. Optionaly you can set it to something specific but if you don’t want to, the script will just draw it out of the feed
  • Add a new variable for the counter.
  • Add the new feed url variable in the SimplePie array. Your new feed will need dates so don’t use something like Ponyfish.
  • Create a new if statement (just follow my comments)
  • Optionally, if you’re using getboo or something similar, add a new switch for the subtags
  • Add the title and counter variables to the chart if you want them tracked. You’re better off copy-pasting one of the current entries in the middle and pasting it below. If you copy and paste to the bottom of the chart, you’ll probably add an extra comma where you shouldn’t. Don’t forget to change the small chart as well.

If you have any questions, let me know.

PS: I am currently waiting for version 1.3 to come out so that I can merge all my changes in the new code but it seems to be taking too long. I think I might as well start beatifying it in order to upload it as standalone.

Download the hacked version of the Simplelife WordPress plugin here.

How to track anything and everything in your lifestream

Usually, most lifestream services out there only allow you to track specific places and usually these places are only the most popular like facebook, flickr, del.icio.us etc. Furthermore they only give you limited control on the look.

This is mainly the reason why I went for my own hosted lifestream. It allows me to track anything I can get a feed for as well as modify it as much as I want to look the way I want it.

However there is always the problem of how to track things that do not provide a feed of some sort. Sure, you might be able to use co.mments to track you blog comments but what if you want to log the comments you left on a forum, in a bug tracker or in a private location? How about when you need to track something completely different than that, like an email of yours to a mailing list or a new torrent you’ve uploaded?

The answer is: Simple. Bookmarking.

All you need to do is utilize an online bookmarking service like del.icio.us or getboo to tag your actions and then use the tag feeds to import them into your lifestream. Not only then can you get a feed for the various actions of yours, but if you utilize extra tags, you can categorize it further afterwards, provided your lifestream services can play with categories.

For example, I am currently bookmarking all the comments I leave on the internet and tag them as “mycomments“. If you check these bookmarks you will also see that they are further tagged as “blogcomments”, “comment_start” etc. Once a comment is tagged, Getboo provides it as a tag feed which I import into my google reader lifestream (for archiving purposes). Finally, my lifestream takes that and depending on the original tag feed the item comes from, it formats it appropriately in the list. Thus you will see all the comments use the same icon & colour while the FSD actions another. However they are both in the same service (getboo) and in the same feed (Google reader lifestream).

Not only that, but if you look deeper you will see that even items from the same source have further differences. Under the FSD class you can see items marked as “Voted Up”, “Buried” or “Commented on”. They are all however coming from the same original getboo tag feed and this is where the tags/categories of a bookmarking service come especially handy. Using the amazing capabilities of SimplePie and some newfound php knowledge I’ve cooked up a method to query the categories of each lifestream item and further format them based on what I find.

At this point, (with only free software tools mind you: getboo, wordpress, simplepie and simplelife) I have a lifestream that is much more inclusive than, I believe, any other option out there, and the capabilities I have are truly endless.

Currently, I am planning to getting logs for mailing lists, bug fixings, wiki edits and whatever else I do on the intertubes. Once everything is ready, I just need to wrap everything up and give it to you as an enhanced WordPress plugin 😉

PS: I suggest getboo throughout this article because del.icio.us is already used by many other lifestreams out there already. If you start bookmarking your actions there, you’ll get them double unless you unregister del.icio.us totally it from your service. That will mean however that your normal bookmarks won’t be tracked anymore. By using an alternative, you avoid that fate and get the best of both worlds.

Oh, and did I mention that if you really have to, you can also host your own getboo? 😉

So what are you waiting for. Start tagging 😉

Using a Google Reader as a lifestream archive

After I set up my lifestream to track a host of custom actions (like comments on other blogs, or votes on FSD) I discovered that many of the feeds I was using were having a item limit (from 10 to 20). That meant that if I made, say, 11 or more comments in various other blogs, the older ones would dissapear from the list, even if the date was still in the limit I’ve set. Only the newer 10 would always be shown and it would seem as If I made no comments below that date.

It was not a bigg issue but I really wanted it to work right so as to get a more accurate overall idea of where I am spending my time (graphs and so).

I remembered then, that Google Reader seems to always have the option to go back into older posts in the feed, up to the time that you made the subscription through it. This meant that it archives everything in that feed and stores it in its own server (Damn that Google storage is endless). Also, Google Reader has the option to put various subscriptions under a specific folder/tag, allowing you to read all the subscriptions together.

It also allows you to make that tag public. A Public tag allows anyone to see the feeds that you share through it but also gives you a feed to subscribe in turn. This feed, unlike the original ones, can provide feeds data as far back as the time you made the Google Reader subscription (and even further if someone else had subscribed to it before you, I believe). All I needed to to is append ?n=# at the end of my google reader feed where # is the number of items I want to see each time the feed is polled. (I selected 100)

So there I had it. An easy way to make an arvhive of my tracked activities without setting up my own database.

The only problem now was to make the lifestream plugin recognise from which feed in turn each item comes and then assign it the correct class. This was a more challenging question as my previous method to compare the original feed with the current item’s could not work. I discovered that I could filter by the items target link but since I wanted to use the same service to track different activites, it would always filter them the same way. In case you’re wondering, I use Getboo to bookmark pages that I commented on as well as FSD articles I’ve voted up, down or commented (Since, unfortunately, FSD does not provide such feeds by itself until now). The number of things I track through Getboo will only increase as I find more actions that don’t provide feeds.

Thus I needed some way to the original feed through my Google Reader lifestream feed.

Well, how very fortunate of me that Google Reader publishes an Atom feed and not only that but it includes the source of the original feed for your convenience. 😀

A little trial & error with the (truly excellent) SimplePie APIs, and I’d managed to find and write the code that I needed to use.


if ($feedurl == $greader_lifestream_feed) {
if ($source = $item->get_source()) {$source_url = $source->get_permalink();}
if (stripos($source_url, 'twitter') !== false) {
$class = 'twitter';
$tf_counter = $tf_counter+1;
$current_title = 'Status Update (Twitter)';
}
if (stripos($source_url, 'mycomments') !== false) {
$class = 'comments';
$extra_text = 'Commented on: ';
$getboo_comment_feed_counter = $getboo_comment_feed_counter+1;
$current_title = 'Comments Elsewhere';
}
if (stripos($source_url, 'fsd') !== false) {
$class = 'fsd';
$extra_text = 'Voted up: ';
$fsd_counter = $fsd_counter+1;
$current_title = 'Votes up on Free Software Daily Article';
}
}

And yes. I’m proud of my little code snippet. 😀

So now, if I have any feed with a sufficiently low item limit, all I need to do is subscribe to it through Google Reader and add the appropriate if statement in my plugin code and presto! Instant archiving. There is only a (very) slight problem in the sense that the lifestream update is delayed by the time it takes for google reader to refresh the original feed and then update the public tag.

All I need to do now is figure out a way to separate items in the google reader feed through the category tags that getboo provides. That would be sweet as it would cut down on line number but unfortunately the get_category() simplepie function does not seem to work as intended for me 🙁