It’s been quiet the last week or so: Rather than producing lots of releases, I’ve been busy working on v0.9.2.0.
Although it might not look like it on the surface, it has lots of changes deep down — all focused on cross-posting.
I’m about half-way through the changes; there are still a lot to do. If you’re interested in the internals of WP-United and why the changes are big, read on… The TL;DR is: WP-United v0.9.2.0 handle cross-posts better and faster.
Adding cross-posting to WP-United originally wasn’t a hard job: The WordPress plugin architecture made it easy. WordPress asks for comments: we return forum replies. WordPress asks to count comments: we count forum replies. WordPress wants a total comment count grouped by post status. OK… the list goes on…
Although easy, this quickly adds up to a bunch of quite expensive calls to phpBB. And this was without responding to WordPress requests in the dashboard, on the edit-comments page, and so on. In order not to end up with a painful mess, WP-United just responded to the bare minimum needed to get the job done.
However, I really wanted a deeper integration. I wanted cross-posted comments to show up anywhere normal WordPress comments do: In the dashboard, in the comments widget; and anywhere else. This would quickly balloon into a bunch of SQL queries taking place on a page, all for slightly different reasons and all without knowledge of each other.
Some of the requests were quite silly: e.g. a call for comments in ascending order, quickly followed by one in descending order. A waste of time.
So I’ve re-written all of that. Calls to cross-posted comments now take place through an access layer, which boils down a wide range of WordPress queries from different sources to broader-based forum queries. It then runs them and remembers the results. If another query comes in that can be served from a previous result set, it gets recycled. The way cross-posts are stored in phpBB has changed too, in order to make things faster.
The access layer also reads in any native WordPress comments and returns mixed result-sets. So if WordPress asks for “all comments waiting for approval”, WP-United can return all normal WordPress comments in posts that are waiting for moderation, together with any cross-posts by guests that are sitting in forums waiting to be approved. Similarly, “Last 10 comments in date order” would return comments both on cross-posted and non cross-posted posts.
This access layer is now nearing completion. It has taken some time as it is quite complex (particularly once you get into pagination and sorting of comments that can come from multiple sources), but the end result is much more modularity and simplicity elsewhere in WP-United. WP-United just does access_layer->get(query) and handles the results, without having to worry about performance or handling any state.
It is nearing completion, but I said I was only half-way done? Ideally I’d like the access layer to handle more than just comments — I’d like it to handle the main post too.
When WordPress calls a page up, we need to know if that post is cross-posted. Even if it doesn’t have any cross-posted comments, we still need to perform some queries to figure out if the current user can reply to it, if they need to log in to do so, and set up a few other things. All this should be built into the same access layer — ideally each page would have one or at most two requests to the phpBB database.
I hope this will all be ready in the next week or so.
If you download the nightly packages, you won’t see much — other than a few changes in the WordPress edit-comments page. But if you do see any outrageous bugs, please do let me know.