ネット接続できない時にupdate_entities を呼び出すと、Warning がでる

メッセージ

テストしたのは、index.php でerror_reporting(E_ALL) としていて、物理的にネットワークと接続していない時だけですが、
W3C_XHTML_DTD_LOCATION で設定したサイトに、アクセスできないことがエラーの原因なので、
ネットワーク障害などの理由でもWarning が出そうです。

cvs:plugin/update_entities.inc.php (v 1.15)

function plugin_update_entities_create($do = FALSE)
{
	$files = array('xhtml-lat1.ent', 'xhtml-special.ent', 'xhtml-symbol.ent');
	
	$entities = array_map('plugin_update_entities_strtr',
		array_values(get_html_translation_table(HTML_ENTITIES)));
	$items   = array('php:html_translation_table');
	$matches = array();
	foreach ($files as $file) {
		// FIXME: 'allow_url_fopen = Off' will stop this
-		$source = file(W3C_XHTML_DTD_LOCATION . $file);
+		$source = @file(W3C_XHTML_DTD_LOCATION . $file);
//			or die_message('cannot receive ' . W3C_XHTML_DTD_LOCATION . $file . '.');
		if (! is_array($source)) {
			$items[] = 'w3c:' . $file . ' COLOR(red):not found.';
			continue;
		}

file() で収得に失敗した時は、直後のif (! is_array($source)) のところでフォローしているので、
この修正で十分だと思うのですがどうでしょうか。


update_entities の結果生成されるデータがおかしい

http://xoops.hypweb.net/modules/forum/index.php?topic_id=2754 での指摘ですが、"(?=[a-zA-Z0-9]\{$min,$max})" によって作られる文字列が'(?=[a-zA-Z0-9]\{2,8})' のようになってしまい、繰り返し指定が無効化され正しくマッチしなくなるそうです。

cvs:plugin/update_entities.inc.php (r1.15) 110行目

-	$pattern = "(?=[a-zA-Z0-9]\{$min,$max})" . generate_trie_regex($entities);
+	$pattern = '(?=[a-zA-Z0-9]{' . $min . ',' . $max . '})' . generate_trie_regex($entities);

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2010-01-04 (月) 05:42:15
Site admin: PukiWiki Development Team

PukiWiki 1.5.4+ © 2001-2022 PukiWiki Development Team. Powered by PHP 8.2.12. HTML convert time: 0.238 sec.

SourceForge