Echshop的二次开发,当安装好Ecshop V2.7.3发现出现了很多Bugs,首页几乎不能显示了。
仔细观察这些错误后,发现错误类型大多就那么几种,例如:
第一种:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in 【意思是:致命错误,preg_replace()函数中的/e模式被遗弃了,请使用preg_replace_callback()函数来替用】
第二种:
Strict standards: Only variables should be passed by reference in【严格标准:变量应该通过引用来使用】
第三种:
Strict standards: Non-static method cls_image::gd_version() should not be called statically in【严格标准:不属于静态方法cls_image::gd_version()不能静态的调用】
其余问题都是一些小毛病,根据提示就可以改掉,不再说明(这里的修改在php5.5.12下测试完美通过)
下面我们来一一解决:
对于第一种问题,解决方法如下(错误行数可能因编辑器不同而有所偏差10行以内):
\includes\cls_template.php on line 300
原有内容:
return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
修改后内容:
return preg_replace_callback("/{([^\}\{\n]*)}/", function($matches) { return $this->select($matches[1]); }, $source);
\includes\cls_template.php on line 493
原有内容:
$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
修改后内容:
$out = "<?php \n".'$k = '.preg_replace_callback("/(\'\\$[^,]+)/", function($matches){return stripslashes(trim($matches[1],'\''));}, var_export($t, true)) . ";\n";
\includes\cls_template.php on line 551
原有内容:
//$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
修改后内容:
$val = preg_replace_callback('/\[([^\[\]]*)\]/is',function ($matches) {return '.'.str_replace('$','\$',$matches[1]);},$val);
\includes\cls_template.php on line 1070
原有内容:
/* 将模板中所有library替换为链接 */
$pattern ='/.*?/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";//zuimoban.com
$source= preg_replace($pattern, $replacement, $source);
修改后内容:
$pattern= '/.*?/s';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace_callback($pattern, function ($matches) { return '{include file='.strtolower($matches[1]). '}';},$source);
对于第二种问题:
例如\includes\cls_template.php on line 422
简单把表达式拿出来即可(类似不再列举):
原有内容:
$tag_sel = array_shift(explode(' ', $tag));
修改后内容:
$arr = explode(' ', $tag);
$tag_sel = array_shift($arr);
对于第三种问题:
例如:\includes\lib_base.php on line 346
我们可以通过实例化对象的方式来调用:
原有内容:
return cls_image::gd_version();
修改后内容://zuimoban.com
$jeeinn = new cls_image();
$jeeinn->gd_version();
覆盖文件打包下载 https://yunpan.cn/crjML8Jt6LUFS (提取码:5df7)(责任编辑:最模板)