RC1-1.0(日本語)でhtmlインポートに動作不具合がありました。
複数ファイルをインポートした際、二つ目以降のファイルがインポートされないというものです。
調査したところ、TransAliasプラグインと関係があるようです。
環境
CentOS 5.2
PHP 5.1.6
mysql 5.0.45
ソース
http://code.google.com/p/modx-ja/downloads/detail?name=evolution1.0J-rc1.zip
manager/includes/document.parser.class.inc.php
function evalplugin
で実行されている $pluginCode の中身なんですが、
プラグインをインスタンス化&実行するコードとなっていまして、
今回の場合の取得元であるsiteCache.idx.phpの中のコードを見ると(キャッシュが生成される過程は追ってないです。すいません・・)
当該部分のコードは以下のようになっています。
assets/cache/siteCache.idx.php
$p['TransAlias'] = '/**
* @name TransAlias
* @desc Handle the task of loading transliteration tables and applying them
* to a string for the purpose of creating a friendly URL alias.
* @package modx
* @subpackage modx.plugins.transalias
* @author Olivier B. Deland, TV override by Mike Schell
* @license GNU General Public License
*/
/*
* Initialize parameters
*/
if (!isset ($alias)) { return ; }
if (!isset ($plugin_dir) ) { $plugin_dir = \'transalias\'; }
if (!isset ($plugin_path) ) { $plugin_path = $modx->config[\'base_path\'].\'assets/plugins/\'.$plugin_dir; }
if (!isset ($table_name)) { $table_name = \'common\'; }
if (!isset ($override_tv)) { $override_tv = \'\'; }
if (!class_exists(\'TransAlias\')) {
require_once $plugin_path.\'/transalias.class.php\';
$trans = new TransAlias($modx);
}
/*
* see if TV overrides the table name
*/
if(!empty($override_tv)) {
$tvval = $trans->getTVValue($override_tv);
if(!empty($tvval)) {
$table_name = $tvval;
}
}
/*
* Handle events
*/
$e =& $modx->event;
switch ($e->name ) {
case \'OnStripAlias\':
if ($trans->loadTable($table_name)) {
$output = $trans->stripAlias($alias);
$e->output($output);
$e->stopPropagation();
}
break ;
default:
return ;
}';
問題と思われるコードは、以下のtransaliasクラスをインスタンス化する箇所です。
if (!class_exists(\'TransAlias\')) {
require_once $plugin_path.\'/transalias.class.php\';
$trans = new TransAlias($modx);
}
判定の混乱だと思うんですが、
・class_existsの判定によって
・$trans にインスタンスを代入している
ため、一度 require された以降(インポートされるファイルの二つ目以降)は $trans が定義されないまま以降のコードが実行され、
$trans->loadTable($table_name)
などのコードがエラーとなり、インポートがストップするようです。
強引ですが、以下のようにインスタンス化のコードを判定の外に出したところ、インポートが成功するようになりました。
if (!class_exists(\'TransAlias\')) {
require_once $plugin_path.\'/transalias.class.php\';
}
$trans = new TransAlias($modx);
不具合報告と言いましたが、こちらの設定に問題があった場合は申し訳ないです。
もしそうであれば、現状はcacheの中を直接書き換えて動作させていますが、正しい修正方法などもご教示いただければ幸いです。