PluginProbe
FeedWordPress / 2011.0721
FeedWordPress v2011.0721
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | syndicatedlink.class.php +34 -12 2011.07062011.0721 View file →
@@ -167,19 +167,22 @@
167 167 function stale () {
168 168 global $feedwordpress;
169 169
170 170 $stale = true;
171 - if (isset($this->settings['update/hold']) and ($this->settings['update/hold']=='ping')) :
171 + if ($this->setting('update/hold')=='ping') :
172 172 $stale = false; // don't update on any timed updates; pings only
173 - elseif (isset($this->settings['update/hold']) and ($this->settings['update/hold']=='next')) :
173 + elseif ($this->setting('update/hold')=='next') :
174 174 $stale = true; // update on the next timed update
175 - elseif (!isset($this->settings['update/ttl']) or !isset($this->settings['update/last'])) :
175 + elseif ( !$this->setting('update/last') ) :
176 176 $stale = true; // initial update
177 177 elseif ($feedwordpress->force_update_all()) :
178 178 $stale = true; // forced general updating
179 179 else :
180 - $after = ((int) $this->settings['update/last'])
181 - +((int) $this->settings['update/ttl'] * 60);
180 + $after = (
181 + (int) $this->setting('update/last')
182 + + (int) $this->setting('update/fudge')
183 + + ((int) $this->setting('update/ttl') * 60)
184 + );
182 185 $stale = (time() >= $after);
183 186 endif;
184 187 return $stale;
185 188 } /* SyndicatedLink::stale () */
@@ -281,19 +284,25 @@
281 284 endif;
282 285
283 286 $this->settings = array_merge($this->settings, $this->flatten_array($channel));
284 287
285 - $this->settings['update/last'] = time(); $ttl = $this->ttl();
288 + $this->settings['update/last'] = time();
289 + list($ttl, $xml) = $this->ttl(/*return element=*/ true);
290 +
286 291 if (!is_null($ttl)) :
287 292 $this->settings['update/ttl'] = $ttl;
293 + $this->settings['update/xml'] = $xml;
288 294 $this->settings['update/timed'] = 'feed';
289 295 else :
290 - $this->settings['update/ttl'] = $this->automatic_ttl();
296 + $ttl = $this->automatic_ttl();
297 + $this->settings['update/ttl'] = $ttl;
298 + $this->settings['update/xml'] = NULL;
291 299 $this->settings['update/timed'] = 'automatically';
292 300 endif;
293 - $this->settings['update/ttl'] = apply_filters('syndicated_feed_ttl', $this->settings['update/ttl'], $this);
301 + $this->settings['update/fudge'] = rand(0, ($ttl/3))*60;
302 + $this->settings['update/ttl'] = apply_filters('syndicated_feed_ttl', $this->setting('update/ttl'), $this);
294 303
295 - if (!isset($this->settings['update/hold']) or $this->settings['update/hold']!='ping') :
304 + if (!$this->setting('update/hold') != 'ping') :
296 305 $this->settings['update/hold'] = 'scheduled';
297 306 endif;
298 307
299 308 $this->settings['update/unfinished'] = 'yes';
@@ -669,9 +678,9 @@
669 678 endif;
670 679 return $ret;
671 680 }
672 681
673 - function ttl () {
682 + function ttl ($return_element = false) {
674 683 if (is_object($this->magpie)) :
675 684 $channel = $this->magpie->channel;
676 685 else :
677 686 $channel = array();
@@ -681,8 +690,9 @@
681 690 // "ttl stands for time to live. It's a number of
682 691 // minutes that indicates how long a channel can be
683 692 // cached before refreshing from the source."
684 693 // <http://blogs.law.harvard.edu/tech/rss#ltttlgtSubelementOfLtchannelgt>
694 + $xml = 'rss:ttl';
685 695 $ret = $channel['ttl'];
686 696 elseif (isset($channel['sy']['updatefrequency']) or isset($channel['sy']['updateperiod'])) :
687 697 $period_minutes = array (
688 698 'hourly' => 60, /* minutes in an hour */
@@ -708,13 +718,23 @@
708 718 if (isset($channel['sy']['updatefrequency'])) : $freq = (int) $channel['sy']['updatefrequency'];
709 719 else : $freq = 1;
710 720 endif;
711 721
722 + $xml = 'sy:updateFrequency';
712 723 $ret = (int) ($period_minutes[$period] / $freq);
713 724 else :
725 + $xml = NULL;
714 726 $ret = NULL;
715 727 endif;
716 - return $ret;
728 +
729 + if ('yes'==$this->setting('update/minimum', 'update_minimum', 'no')) :
730 + $min = (int) $this->setting('update/window', 'update_window', DEFAULT_UPDATE_PERIOD);
731 +
732 + if ($min > $ret) :
733 + $ret = NULL;
734 + endif;
735 + endif;
736 + return ($return_element ? array($ret, $xml) : $ret);
717 737 } /* SyndicatedLink::ttl() */
718 738
719 739 function automatic_ttl () {
720 740 // spread out over a time interval for staggered updates
@@ -722,9 +742,11 @@
722 742 if (!is_numeric($updateWindow) or ($updateWindow < 1)) :
723 743 $updateWindow = DEFAULT_UPDATE_PERIOD;
724 744 endif;
725 745
726 - $fudgedInterval = $updateWindow+rand(0, 2*($updateWindow/3));
746 + // We get a fudge of 1/3 of window from elsewhere. We'll do some more
747 + // fudging here.
748 + $fudgedInterval = $updateWindow+rand(-($updateWindow/6), 5*($updateWindow/12));
727 749 return apply_filters('syndicated_feed_automatic_ttl', $fudgedInterval, $this);
728 750 } /* SyndicatedLink::automatic_ttl () */
729 751
730 752 // SyndicatedLink::flatten_array (): flatten an array. Useful for