diff options
author | Maurice Svay <maurice@svay.com> | 2014-03-26 22:52:45 +0100 |
---|---|---|
committer | Maurice Svay <maurice@svay.com> | 2014-03-26 22:52:45 +0100 |
commit | 07aa4f5484dfefe4d9d5870b31d2e2269583fdd2 (patch) | |
tree | 64796700ff4f5ccbdfbbfed22249940839259e89 | |
parent | b37de7f1afab72e266a1d25b6635f20e8b025f88 (diff) | |
parent | 1b25767e3584844b0ebb295e4cc3b85ff59c72cf (diff) | |
download | planet-07aa4f5484dfefe4d9d5870b31d2e2269583fdd2.tar planet-07aa4f5484dfefe4d9d5870b31d2e2269583fdd2.tar.gz planet-07aa4f5484dfefe4d9d5870b31d2e2269583fdd2.tar.bz2 planet-07aa4f5484dfefe4d9d5870b31d2e2269583fdd2.tar.xz planet-07aa4f5484dfefe4d9d5870b31d2e2269583fdd2.zip |
Merge pull request #65 from mozillahispano/fix-feed-lock
Avoid timeouts when any feed is down. Fix #64
-rwxr-xr-x | admin/index.php | 3 | ||||
-rwxr-xr-x | admin/subscriptions.php | 1 | ||||
-rw-r--r-- | app/classes/Planet.class.php | 25 | ||||
-rw-r--r-- | app/classes/PlanetFeed.php | 9 | ||||
-rw-r--r-- | app/l10n/en.lang | 4 | ||||
-rwxr-xr-x | app/l10n/fr.lang | 4 | ||||
-rw-r--r-- | app/lib/lib.opml.php | 5 |
7 files changed, 43 insertions, 8 deletions
diff --git a/admin/index.php b/admin/index.php index 28f7198..76ddc98 100755 --- a/admin/index.php +++ b/admin/index.php @@ -99,6 +99,7 @@ ob_start(); <th><?=_g('Last entry')?></th> <th><?=_g('Website link')?></th> <th><?=_g('Feed link')?></th> + <th><?=_g('Unavailable')?></th> </tr> </thead> <tbody> @@ -118,10 +119,12 @@ ob_start(); } else { echo _g('Not in cache'); } + $check_is_down = $opml_person->getIsDown() === '1' ? 'checked="cheched"' : ''; ?> </td> <td><input type="text" size="30" class="text" name="opml[<?=$i; ?>][website]" value="<?=$opml_person->getWebsite(); ?>" /></td> <td><input type="text" size="30" class="text" name="opml[<?=$i; ?>][feed]" value="<?=$opml_person->getFeed(); ?>" /></td> + <td><input type="checkbox" readonly="readonly" name="opml[<?=$i; ?>][isDown]" <?=$check_is_down?> value="1" /></td> </tr> <?php } ?> </tbody> diff --git a/admin/subscriptions.php b/admin/subscriptions.php index ea2f113..3612666 100755 --- a/admin/subscriptions.php +++ b/admin/subscriptions.php @@ -48,6 +48,7 @@ if (isset($_POST['opml']) || isset($_POST['add'])) { $person['name'] = $feed->get_title(); $person['website'] = $feed->get_permalink(); $person['feed'] = $feed->feed_url; + $person['isDown'] = '0'; $oldOpml->entries[] = $person; } diff --git a/app/classes/Planet.class.php b/app/classes/Planet.class.php index c5823e1..3c76378 100644 --- a/app/classes/Planet.class.php +++ b/app/classes/Planet.class.php @@ -97,7 +97,8 @@ class Planet new PlanetFeed( $opml_person['name'], $opml_person['feed'], - $opml_person['website'] + $opml_person['website'], + $opml_person['isDown'] ) ); } @@ -110,10 +111,14 @@ class Planet public function loadFeeds() { foreach ($this->people as $feed) { - $feed->init(); - $this->items = array_merge($this->items, $feed->get_items()); - } + //Is down it's filled by cron.php, $Planet->download(1.0) proccess + if (!$feed->isDown) { + $feed->set_timeout(-1); + $feed->init(); + $this->items = array_merge($this->items, $feed->get_items()); + } + } $this->sort(); } @@ -123,8 +128,8 @@ class Planet */ public function download($max_load=0.1) { - $max_load_feeds = ceil(count($this->people) * $max_load); + $opml = OpmlManager::load(dirname(__FILE__).'/../../custom/people.opml'); foreach ($this->people as $feed) { //Avoid mass loading with variable cache duration @@ -139,6 +144,7 @@ class Planet //Load feed $feed->init(); + $isDown = ''; // http://simplepie.org/wiki/reference/simplepie/merge_items ? //Add items to index @@ -147,8 +153,17 @@ class Planet $this->items = array_merge($this->items, $items); } else { $this->errors[] = new PlanetError(1, 'No items : '.$feed->getFeed()); + $isDown = '1'; + } + + //Mark if the feed is temporary unavailable + foreach ($opml->entries as $key => $entrie) { + if ($feed->getFeed() === $entrie['feed']) { + $opml->entries[$key]['isDown'] = $isDown; + } } } + OpmlManager::save($opml, dirname(__FILE__).'/../../custom/people.opml'); } public function sort() diff --git a/app/classes/PlanetFeed.php b/app/classes/PlanetFeed.php index a6c7aab..7c79471 100644 --- a/app/classes/PlanetFeed.php +++ b/app/classes/PlanetFeed.php @@ -9,12 +9,14 @@ class PlanetFeed extends SimplePie public $name; public $feed; public $website; + public $isDown; - public function __construct($name, $feed, $website) + public function __construct($name, $feed, $website, $isDown) { $this->name = $name; $this->feed = $feed; $this->website = $website; + $this->isDown = $isDown; parent::__construct(); $this->set_item_class('PlanetItem'); $this->set_cache_location(dirname(__FILE__).'/../../cache'); @@ -39,6 +41,11 @@ class PlanetFeed extends SimplePie return $this->website; } + public function getIsDown() + { + return $this->isDown; + } + public function compare($person1, $person2) { return strcasecmp($person1->name, $person2->name); diff --git a/app/l10n/en.lang b/app/l10n/en.lang index 64d5a82..ff49307 100644 --- a/app/l10n/en.lang +++ b/app/l10n/en.lang @@ -114,6 +114,10 @@ Feed link # Translation note: ** String needs translation ** +;Unavailable +Unavailable + +# Translation note: ** String needs translation ** ;Not in cache Not in cache diff --git a/app/l10n/fr.lang b/app/l10n/fr.lang index 6247652..4e2a568 100755 --- a/app/l10n/fr.lang +++ b/app/l10n/fr.lang @@ -90,6 +90,10 @@ Lien du site Lien du Flux +;Unavailable +Indisponible + + ;Not in cache Pas en cache diff --git a/app/lib/lib.opml.php b/app/lib/lib.opml.php index 7767979..b777f15 100644 --- a/app/lib/lib.opml.php +++ b/app/lib/lib.opml.php @@ -13,7 +13,8 @@ class opml 'TEXT' => 'name', 'TITLE' => 'name', 'XMLURL' => 'feed', - 'DESCRIPTION' => 'description' + 'DESCRIPTION' => 'description', + 'ISDOWN' => 'isDown' ); @@ -95,7 +96,7 @@ class OpmlManager $out.= '</head>'."\n"; $out.= '<body>'."\n"; foreach ($opml->entries as $person){ - $out.= '<outline text="' . htmlspecialchars($person['name']) . '" htmlUrl="' . htmlspecialchars($person['website']) . '" xmlUrl="' . htmlspecialchars($person['feed']) . '"/>'."\n"; + $out.= '<outline text="' . htmlspecialchars($person['name']) . '" htmlUrl="' . htmlspecialchars($person['website']) . '" xmlUrl="' . htmlspecialchars($person['feed']) . '" isDown="' . htmlspecialchars($person['isDown']) . '"/>'."\n"; } $out.= '</body>'."\n"; $out.= '</opml>'; |