Background tasks in PHP: pinging weblogs.com

A long time ago, Ivan looked at executing background tasks in PHP after the actual request by the browser was over. He explained that it disappeared in PHP 4.1, but should be (and is) part of PHP 4.3.1.
I modified b2edit.php to use the register_shutdown_function to call the pingWeblogs, and pingBlogs functions:
From (line 100 of b2edit.php):

rss_update($blog_ID);
pingWeblogs($blog_ID);
pingCafelog($cafelogID, $post_title, $post_ID);
pingBlogs($blog_ID);

to

//rss_update($blog_ID);
pingCafelog($cafelogID, $post_title, $post_ID);
register_shutdown_function( "pingWeblogs" );
register_shutdown_function( "pingBlogs" );

This probably won’t work if you’re using PHP 4.1, so test it after you make the change! Does it make posting to b2 faster? I’m not sure. I don’t think those functions “disconnect” from the browser completely. Of course, I could be mistaken and the delay could be in another part of the code! I don’t honestly know.
Final note – I made a quick optimization by removing the call to rss_update(). That function creates the b2rss.xml file. Since we don’t use that file (use b2rss2.php or b2rdf.php instead!), the function call isn’t required!

Leave a Reply

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close