修正Habari检查PHP文件语法的一个BUG
2011 八月 20
此BUG主要是Utils类中的php_check_file_syntax函数引起的。
PHP并没有规定说一定要有结束标记,而且,很多时候,结束标记会带来不必要的麻烦。
如CodeIgniter框架的code标准就规定不使用结束标志:PHP Closing Tag
不过,我目前在PHP5.3下测试,发现PHP貌似修复了该BUG
。
但是一直以来养成了不带结束标记的习惯了,因此,修正Habari这一BUG。因为用与不用结束标记应该是插件作者的自由。
修正后的函数如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * Check the PHP syntax of (and execute) the specified file. * * @see Utils::php_check_syntax() */ public static function php_check_file_syntax($file, &$error = null) { // Prepend and append PHP opening tags to prevent eval() failures. $content = file_get_contents($file); if (preg_match("/.*\?>$/i", $content)) { $code = ' ?>' . $content . '<?php '; } else { $code = ' ?>' . $content . '?><?php '; } return self::php_check_syntax($code, $error); } |
from → Habari








Trackbacks & Pingbacks