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 | feedwordpress.php +66 -16 2011.07062011.0721 View file →
@@ -2,9 +2,9 @@
2 2 /*
3 3 Plugin Name: FeedWordPress
4 4 Plugin URI: http://feedwordpress.radgeek.com/
5 5 Description: simple and flexible Atom/RSS syndication for WordPress
6 -Version: 2011.0706
6 +Version: 2011.0721
7 7 Author: Charles Johnson
8 8 Author URI: http://radgeek.com/
9 9 License: GPL
10 10 */
@@ -10,9 +10,9 @@
10 10 */
11 11
12 12 /**
13 13 * @package FeedWordPress
14 - * @version 2011.0706
14 + * @version 2011.0721
15 15 */
16 16
17 17 # This uses code derived from:
18 18 # - wp-rss-aggregate.php by Kellan Elliot-McCrea <kellan@protest.net>
@@ -33,9 +33,9 @@
33 33 # or use a cron job.
34 34
35 35 # -- Don't change these unless you know what you're doing...
36 36
37 -define ('FEEDWORDPRESS_VERSION', '2011.0706');
37 +define ('FEEDWORDPRESS_VERSION', '2011.0721');
38 38 define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
39 39
40 40 if (!defined('FEEDWORDPRESS_BLEG')) :
41 41 define ('FEEDWORDPRESS_BLEG', true);
@@ -982,8 +982,15 @@
982 982
983 983 if (!is_null($uri) and $uri != '*') :
984 984 $uri = trim($uri);
985 985 else : // Update all
986 + if ($this->update_hooked) :
987 + $diag = $this->update_hooked;
988 + else :
989 + $diag = 'Initiating a MANUAL check-in on the update schedule at '.date('r', time());
990 + endif;
991 + $this->diagnostic('update_schedule:check', $diag);
992 +
986 993 update_option('feedwordpress_last_update_all', time());
987 994 endif;
988 995
989 996 do_action('feedwordpress_update', $uri);
@@ -991,8 +998,10 @@
991 998 if (is_null($crash_ts)) :
992 999 $crash_ts = $this->crash_ts();
993 1000 endif;
994 1001
1002 + $max_polls = apply_filters('feedwordpress_polls_per_update', get_option('feedwordpress_polls_per_update', 10), $uri);
1003 +
995 1004 // Randomize order for load balancing purposes
996 1005 $feed_set = $this->feeds;
997 1006 shuffle($feed_set);
998 1007
@@ -998,14 +1007,22 @@
998 1007
999 1008 $feed_set = apply_filters('feedwordpress_update_feeds', $feed_set, $uri);
1000 1009
1001 1010 // Loop through and check for new posts
1002 - $delta = NULL;
1011 + $delta = NULL; $remaining = $max_polls;
1003 1012 foreach ($feed_set as $feed) :
1004 - if (!is_null($crash_ts) and (time() > $crash_ts)) : // Check whether we've exceeded the time limit
1013 +
1014 + // Has this process overstayed its welcome?
1015 + if (
1016 + // Over time limit?
1017 + (!is_null($crash_ts) and (time() > $crash_ts))
1018 +
1019 + // Over feed count?
1020 + or ($remaining == 0)
1021 + ) :
1005 1022 break;
1006 1023 endif;
1007 -
1024 +
1008 1025 $pinged_that = (is_null($uri) or ($uri=='*') or in_array($uri, array($feed->uri(), $feed->homepage())));
1009 1026
1010 1027 if (!is_null($uri)) : // A site-specific ping always updates
1011 1028 $timely = true;
@@ -1017,8 +1034,10 @@
1017 1034 $delta = array('new' => 0, 'updated' => 0); // ... don't return error condition
1018 1035 endif;
1019 1036
1020 1037 if ($pinged_that and $timely) :
1038 + $remaining = $remaining - 1;
1039 +
1021 1040 do_action('feedwordpress_check_feed', $feed->settings);
1022 1041 $start_ts = time();
1023 1042 $added = $feed->poll($crash_ts);
1024 1043 do_action('feedwordpress_check_feed_complete', $feed->settings, $added, time() - $start_ts);
@@ -1054,33 +1073,63 @@
1054 1073 return $secret;
1055 1074 }
1056 1075
1057 1076 function has_secret () {
1058 - return (isset($_REQUEST['feedwordpress_key']) and ($_REQUEST['feedwordpress_key']==$this->secret_key()));
1077 + return ($this->by_request('feedwordpress_key', $this->secret_key()));
1059 1078 }
1060 1079
1061 - function automatic_update_hook () {
1080 + // Utility function so I don't have to repeat myself w/ 1,000,003 isset()'s
1081 + function by_request ($param, $eq = NULL) {
1082 + $match = false;
1083 + if (isset($_REQUEST[$param])) :
1084 + $match = (is_null($eq) ? $_REQUEST[$param] : ($eq==$_REQUEST[$param]));
1085 + endif;
1086 + return $match;
1087 + }
1088 +
1089 + var $update_hooked = NULL;
1090 + function automatic_update_hook ($params = array()) {
1091 + $params = wp_parse_args($params, array( // Defaults
1092 + 'setting only' => false,
1093 + ));
1062 1094 $hook = get_option('feedwordpress_automatic_updates', NULL);
1063 - if ($this->has_secret() and isset($_REQUEST['automatic_update'])) : // For forced behavior in testing.
1095 + $method = 'FeedWordPress option';
1096 +
1097 + // Allow for forced behavior in testing.
1098 + if (
1099 + !$params['setting only']
1100 + and $this->has_secret()
1101 + and $this->by_request('automatic_update')
1102 + ) :
1064 1103 $hook = $_REQUEST['automatic_update'];
1104 + $method = 'URL parameter';
1065 1105 endif;
1066 1106
1067 - if (!is_null($hook)) :
1107 + $exact = $hook; // Before munging
1108 +
1109 + if (!!$hook) :
1068 1110 if ($hook != 'init') : // Constrain values.
1069 1111 $hook = 'shutdown';
1070 1112 endif;
1071 1113 endif;
1114 +
1115 + if ($hook) :
1116 + $this->update_hooked = "Initiating an AUTOMATIC CHECK FOR UPDATES ON PAGE LOAD ".$hook." due to ".$method." = ".trim($this->val($exact));
1117 + endif;
1118 +
1072 1119 return $hook;
1073 1120 }
1074 1121 function last_update_all () {
1075 1122 $last = get_option('feedwordpress_last_update_all');
1076 - if ($this->has_secret() and isset($_REQUEST['automatic_update']) and ((strlen($_REQUEST['automatic_update']) > 0))) :
1123 + if ($this->has_secret() and $this->by_request('automatic_update')) :
1077 1124 $last = 1; // A long, long time ago.
1125 + elseif ($this->has_secret() and $this->by_request('last_update_all')) :
1126 + $last = $_REQUEST['last_update_all'];
1078 1127 endif;
1079 1128 return $last;
1080 1129 }
1081 1130 function force_update_all () {
1082 - return ($this->has_secret() and isset($_REQUEST['force_update_feeds']) and !!$_REQUEST['force_update_feeds']);
1131 + return ($this->has_secret() and $this->by_request('force_update_feeds'));
1083 1132 }
1084 1133
1085 1134 function stale () {
1086 1135 if (!is_null($this->automatic_update_hook())) :
@@ -1183,8 +1232,10 @@
1183 1232 global $wpdb;
1184 1233
1185 1234 // Explicit update request in the HTTP request (e.g. from a cron job)
1186 1235 if ($this->update_requested()) :
1236 + $this->update_hooked = "Initiating a CRON JOB CHECK-IN ON UPDATE SCHEDULE due to URL parameter = ".trim($this->val($_REQUEST['update_feedwordpress']));
1237 +
1187 1238 $this->update($this->update_requested_url());
1188 1239
1189 1240 if (FEEDWORDPRESS_DEBUG and count($wpdb->queries) > 0) :
1190 1241 $mysqlTime = 0.0;
@@ -1226,12 +1277,9 @@
1226 1277 );
1227 1278 } /* FeedWordPress::clear_cache_requested() */
1228 1279
1229 1280 function update_requested () {
1230 - return (
1231 - isset($_REQUEST['update_feedwordpress'])
1232 - and $_REQUEST['update_feedwordpress']
1233 - );
1281 + return FeedWordPress::by_request('update_feedwordpress');
1234 1282 } // FeedWordPress::update_requested()
1235 1283
1236 1284 function update_requested_url () {
1237 1285 $ret = null;
@@ -1739,8 +1787,10 @@
1739 1787 if ($this->ready_to_email_diagnostics($dlog)) :
1740 1788 // No news is good news; only send if
1741 1789 // there are some messages to send.
1742 1790 $body = NULL;
1791 + if (!isset($dlog['mesg'])) : $dlog['mesg'] = array(); endif;
1792 +
1743 1793 foreach ($dlog['mesg'] as $sect => $mesgs) :
1744 1794 if (count($mesgs) > 0) :
1745 1795 if (is_null($body)) : $body = ''; endif;
1746 1796