プロジェクト

全般

プロフィール

Backport(バックポート) #2273

Minoru Takai12年以上前に更新

h3. 現象

(http://sns.openpne.jp/communityTopic/6318 より転記)

> サイドバナーへRSSリーダーを登録しているのですが、
> 読み込み先によって、
> 画面の表示が「サーバーが混雑しています~」のような表示になってしまいます。

h3. 再現環境

サーバー:

* CentOS Linux 5.5
* MySQL version 5.0.91
* php 5.2.13

OpenPNEのバージョン:

* OpenPNE3.4.6.2

h3. 再現手順

こちらのRSSを登録する(8月28日23時ごろ)
http://video.baidu.jp/api/search?word=%E3%83%90%E3%82%A4%...

最初はずっと表示されていましたので、時間がたつと内容が変わりますので、表示されるようになるかもしれません。

サーバーのエラーログ: サーバーのエラーログ:<pre>
<pre>
PHP Fatal error: Uncaught exception 'sfException' with message 'Impossible to parse date "" with format "yyyy-MM-dd HH:mm:ss".'
in /www/lib/vendor/symfony/lib/i18n/sfDateFormat.class.php:186\n
Stack trace:\n
#0
/www/lib/vendor/symfony/lib/i18n/sfDateFormat.class.php:186\nStack trace:\n#0 /www/lib/vendor/symfony/lib/i18n/sfDateFormat.class.php(219): sfDateFormat->getDate('', NULL)\n
#1
NULL)\n#1 /www/lib/vendor/symfony/lib/helper/DateHelper.php(60): sfDateFormat->format('', 'MM???dd???', NULL, 'utf-8')\n
#2
'utf-8')\n#2 /www/lib/helper/opUtilHelper.php(333): format_date('', 'MM???dd???', 'ja_JP', NULL)\n
#3
NULL)\n#3 /www/apps/pc_frontend/modules/default/templates/_rssBox.php(7): op_format_date('', 'XShortDateJa')\n
#4
'XShortDateJa')\n#4 /www/cache/apache/pc_frontend/prod/config/config_core_compile.yml.php(3810): require('...')\n
#5
require('...')\n#5 /www/lib/vendor/symfony/lib/view/sfPartialView.class.php(110): sfPHPView->renderFile('...')\n
#6
sfPHPView->renderFile('...')\n#6 /www/lib/vendor/symfony/lib/helper/PartialHelper.php(155): sfPartialView->render()\n
#7
sfPartialView->render()\n#7 /var/www/r in /www/lib/vendor/symfony/lib/i18n/sfDateFormat.class.php on line 186
</pre>
186</pre>

h3. 原因

規定外のRSSを受信した場合などに、パースに失敗し例外により処理が中断されるため。

h3. 修正内容

ガジェット側ですべての例外を catch して、適切な表示になるように修正するべきです。

具体的には、http://redmine.openpne.jp/issues/1684#note-3 にあるように<pre>
diff --git a/apps/pc_frontend/modules/default/actions/components.class.php b/apps/pc_frontend/modules/def
index 097703c..ad79046 100644
--- a/apps/pc_frontend/modules/default/actions/components.class.php
+++ b/apps/pc_frontend/modules/default/actions/components.class.php
@@ -95,11 +95,17 @@ class defaultComponents extends sfComponents

public function executeRssBox()
{
- $fetcher = new opRssFetcher('UTF-8');
- $this->result = @$fetcher->fetch($this->gadget->getConfig('url'), true);
- if ($this->result)
+ try
+ {
+ $fetcher = new opRssFetcher('UTF-8');
+ $this->result = @$fetcher->fetch($this->gadget->getConfig('url'), true);
+ if ($this->result)
+ {
+ $this->result[1] = array_slice($this->result[1], 0, 5);
+ }
+ }
+ catch (Exception $e)
{
- $this->result[1] = array_slice($this->result[1], 0, 5);
}
}
</pre> のような変更で十分かと思われます。

戻る