The MU forums have moved to WordPress.org

$wpdb->blogs.last_updated internals (5 posts)

  1. Deadpan110
    Member
    Posted 15 years ago #

    Hiya all,

    Im very new to WordPress MU but an old hand at WordPress hacking and I am now using MU for one of my sites.

    I am currently writing hacks based on other peoples plugins, namely better ways to get sitewide comments and posts (2 database queries with clever mySQL usage seems the way to go, although I don't have any users yet - just a home and a test blog).

    To my question - I get a list of last_updated blogs from $wpdb->blogs (filtering out spam/mature/deleted/etc) and I am wondering on what events exactly the timestamp is updated.

    I could spend some time testing out different things, but figured I would ask this forum.

    I would assume that when a post is Created/Updated, then the last_updated timestamp is also updated.

    Would Created/Updated Pages and Newly Accepted Comments also cause the $wpdb->blogs.last_updated timestamp to change?

    Thanks in advance :)

  2. andrea_r
    Moderator
    Posted 15 years ago #

    Newly Accepted Comments causes the timestamp to change, but new pages don't.

    Basically ANY activity on a particular post - a new comment, an edit, anything - cause the last_updated to update with a new timestamp.

    I wanna see that query when you're done. :D

  3. Deadpan110
    Member
    Posted 15 years ago #

    Thanks for the reply, thats exactly what I was hoping for!

    I have written a function for use in my home themes functions.php and so far, it spits out an array of all approved comments across blogs (could be easily converted into a plugin).

    I was going to paste a link to a comment on wpmudev.org from where I found the original mySQL query, but it appears they have changed the site in the last 24 hours and comments no longer appear to exist (just as well I managed to make use of it before it vanished).

    I am unsure of limitations with mySQL and query size, but basically my function gets a list of all updated blogs from the last 30 days and then builds the 2nd query using this (hence the query could become quite long).

    A site-wide recent posts function could be created using the above method just by modifying the 2nd SQL statement.

    For anyone interested in this (to use/test/modify/etc), I will post it onto a SVN server somewhere later today.

  4. Deadpan110
    Member
    Posted 15 years ago #

    Oops... originally posted twice, this was a duplicate of the above... heh, there was a delay - so I shouted at my screen - thinking my post was ignored - and posted again :)

  5. Deadpan110
    Member
    Posted 15 years ago #

    OK, turned the code into a nice class and tried to comment it with usage.

    Basically, it can return an array of data for sitewide recent comments (including blog_name, blog_domain, post_title and guid Permalinks) which you can use however you see fit within your own code.

    I will be writing a similar function within the class for sitewide recent posts later on today and if i can think of anything else at a later date, then I will add that too.

    USAGE:

    <?php require_once(dirname(__FILE__) . '/wpmu_sitewide_recent.php');
    $wpmu_sitewide_recent = new wpmu_sitewide_recent();
    print_r($wpmu_sitewide_recent->comments()); ?>

    DOWNLOAD:

    http://svn.assembla.com/svn/wpmu_sitewide_recent/trunk/wpmu_sitewide_recent.php

    Feel free to use this code within your own sites/plugins/etc and don't forget to send any patches/bug fixes/feedback my way...

    Also, if anyone wants to be added to svn write access - just lemmie know :)

  6. Deadpan110
    Member
    Posted 15 years ago #

    OK, a quick update!

    The php class now supports recently updated posts now too.. this is not for the feint hearted as of yet because you really really need to know howto get data from an array (I say this after reading a few posts to the forum)!

    I have a couple of working examples I hope to include to explain its usage, but I would still love for people to test (if they are able) so I can correct any errors/patch etc...

    Its working great on my site... but alas, I have no users (just a friends account... a test account... a dev account and home)...

    I am really curious on the maximum length of an mySQL query as it could be the downfall of using this.

About this Topic

  • Started 15 years ago by Deadpan110
  • Latest reply from Deadpan110