2016-05-24 41 views
0

私は既存の機能が充実したPHPアプリケーションを持っています。私はPHP5からPHP7への移行を含むサーバーのアップグレードを検討しています。私の知る限り、Smarty3はPHP7と互換性があるはずです。ただし、これをテストすると、Smartyがアップグレード後にテンプレートをコンパイルすることを拒否することが判明しました。PHP7へのSmarty3のアップグレードとレジスタプラグインの奇妙な問題

問題の原因は、この行のようだ:

PHPアプリケーションは、次のようにクラッシュし
$this->smarty->registerPlugin('compiler', 'asset_url', array(&$this, 'asset_url')); 

Notice: Array to string conversion in /usr/share/php/smarty3/sysplugins/smarty_internal_templatecompilerbase.php on line 415 

Notice: Undefined property: template::$Array in /usr/share/php/smarty3/sysplugins/smarty_internal_templatecompilerbase.php on line 415 

Fatal error: Uncaught Error: Function name must be a string in /usr/share/php/smarty3/sysplugins/smarty_internal_templatecompilerbase.php:415 
Stack trace: 
#0 /usr/share/php/smarty3/sysplugins/smarty_internal_templateparser.php(3585): Smarty_Internal_TemplateCompilerBase->compileTag('asset_url', Array) 
#1 /usr/share/php/smarty3/sysplugins/smarty_internal_templateparser.php(4413): Smarty_Internal_Templateparser->yy_r32() 
#2 /usr/share/php/smarty3/sysplugins/smarty_internal_templateparser.php(4515): Smarty_Internal_Templateparser->yy_reduce(32) 
#3 /usr/share/php/smarty3/sysplugins/smarty_internal_smartytemplatecompiler.php(118): Smarty_Internal_Templateparser->doParse(3, '}') 
#4 /usr/share/php/smarty3/sysplugins/smarty_internal_templatecompilerbase.php(283): Smarty_Internal_SmartyTemplateCompiler->doCompile('<!DOCTYPE html>...') 
#5 /usr/share/php/smarty3/sysplugins/smarty_internal_template.php(197): Smarty_Internal_TemplateCompilerBase->compileTemplate(Object(Smarty_Internal_Template)) 
#6 /usr/share/php/smarty3/sysplugins/sm in /usr/share/php/smarty3/sysplugins/smarty_internal_templatecompilerbase.php on line 415 

不審なライン415は次のようになります。

$function = $this->smarty->registered_plugins[$plugin_type][$tag][0]; 
if (!is_array($function)) { 
    return $function($new_args, $this); 
} elseif (is_object($function[0])) { 
    return $this->smarty->registered_plugins[$plugin_type][$tag][0][0]->$function[1]($new_args, $this); <- Crash here! 
} else { 
    return call_user_func_array($function, array($new_args, $this)); 
} 

私はこれがPHP5とPHP7の基本的な違いですそれが何であるか把握していないようです。誰かが私にこれを整理する方法のいくつかの指針を教えてもらえますか?

+1

使用しているSmartyの正確なバージョンを知っていますか? 3.1.28リリースでPHP 7の修正がいくつかありました。 – iainn

+0

私は3.1.21-1ubuntu1を使用しています。それは確かに調べる価値がある! – pehrs

+0

@iainnそれが問題だったようですね!あなたは私が受け入れる答えを作ることができますか? – pehrs

答えて