From 481cd708acfd3291eed7eba6af596c541651963c Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 30 Jun 2011 21:56:07 -0700 Subject: allow polling to mostly survive minor memory shortages. --- addon/facebook/facebook.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'addon/facebook') diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php index 49f193804..c54d5b5f0 100644 --- a/addon/facebook/facebook.php +++ b/addon/facebook/facebook.php @@ -376,9 +376,12 @@ function facebook_cron($a,$b) { logger('facebook_cron'); - set_config('facebook','last_poll', time()); - $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'facebook' AND `k` = 'post' AND `v` = '1' "); + // Find the FB users on this site and randomize in case one of them + // uses an obscene amount of memory. It may kill this queue run + // but hopefully we'll get a few others through on each run. + + $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'facebook' AND `k` = 'post' AND `v` = '1' ORDER BY RAND() "); if(count($r)) { foreach($r as $rr) { // check for new friends once a day @@ -392,6 +395,9 @@ function facebook_cron($a,$b) { fb_consume_all($rr['uid']); } } + + set_config('facebook','last_poll', time()); + } -- cgit v1.2.3