大型ECShop安装搬家升级错误问题最全攻略
【引子】
最近将ECShop框架网站从租用服务器搬家至阿里云,虽然模块及功能上已经被修改的面目全非了,但基础部分还在。
在这个过程中遇到了很多的WARNING与ERROR,解决方案如下。
【环境】
服务器环境由PHP5.3+MySQL5.6更新至PHP5.6+MySQL5.7
【数据库】
利用navicat for mysql工具导入导出,出现异常:Invalid default value for 'create_time',具体可参考上一篇随笔。http://www.cnblogs.com/eDevelop/p/7081061.html
【后台】
打开首页报错,提示:
Strict standards: Non-static method cls_image::gd_version() should not be called statically in includes\lib_base.php on line 355 return cls_image::gd_version();
对象可以访问静态方法,使用的是$p->function(),对象访问静态属性采用p::function()形式。
$cimage=new cls_image();
return $cimage->gd_version();
类似还有:
Strict standards: Non-static method cls_sql_dump::get_random_name() should not be called statically in admin\database.php on line 64
$smarty->assign('sql_name', cls_sql_dump::get_random_name() . '.sql');
修改为:
$csdump=new cls_sql_dump($db,$max_size);
$smarty->assign('sql_name', $csdump->get_random_name() . '.sql');
嫌麻烦直接找到function get_random_name()函数,前面加个static完事。
个人设置:
Strict standards: Only variables should be passed by reference in includes\cls_template.php on line 422 $tag_sel = array_shift(explode(' ', $tag));
调用函数传参错误
$p=explode(' ', $tag);
$tag_sel = array_shift($p);
商品分类:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead inincludes\cls_template.php on line 304
return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);
PHP升级5.5之后,摒弃了preg_replace的/e特性。
return preg_replace_callback("/{([^\}\{\n]*)}/", function($func) { return $this->select($func[1]); }, $source);
问题集中在cls_template中。
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in includes\cls_template.php on line 554
$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
修改为:
$val = preg_replace_callback('/\[([^\[\]]*)\]/is',function ($matches) {return '.'.str_replace('$','\$',$matches[1]);},$val);
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in includes\cls_template.php on line 491
$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
修改为:
$out = "<?php " . '$k = ' . preg_replace_callback("/(\'\\$[^,] )/" , function($match){return stripslashes(trim($match[1],'\''));},
var_export($t, true)) . ";\n";
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in includes\cls_template.php on line 1074
$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace($pattern, $replacement, $source);
修改为:
$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s';
$source = preg_replace_callback($pattern, function ($func){return '{include file='.strtolower($func[1]).'}';},$source);
历史订单:查看->配送方式:编辑
Warning: Illegal string offset 'free_money' in admin\order.php on line 3696
使用$shipping['configure']['free_money']形式,要求$shipping['configure']为数组,可以引入IF判断解决
if(is_array($shipping['configure'])){...}
Warning: number_format() expects parameter 1 to be double, string given in includes\lib_common.php on line 1019
虽然ECShop2.7.3对参数$price进行判断是否为空,但配送插件里面的免费额度为0,ec本身的bug导致了$price的值为空值,直接调用number_format出现了错误。
在PHP5.3上报错,但获取到的应该是一个字符串,所以出错,应该这样改:
$price = 0 + $price;//添加这一行,转换成数值
商店设置:
Strict standards: mktime(): You should be using the time() function instead in admin\sms_url.php on line 31
Strict standards: mktime(): You should be using the time() function instead in admin\shop_config.php on line 32
mktime()方法不带参数被调用时,会被抛出一个报错提示。
$auth=mktime();
修改为:
$autu=time();
管理员权限与角色管理:
Warning: join(): Invalid arguments passed in admin\privilege.php on line 602
Warning: Invalid argument supplied for foreach() in admin\privilege.php on line 604
Warning: join(): Invalid arguments passed in admin\role.php on line 217
Warning: Invalid argument supplied for foreach() in admin\role.php on line 219
这里与上上个错误类似,数组类型取值才不会警告。
使用if(is_array($action_group['priv'])){}将join与foreach代码段包进去。
网上给出方案如下,感觉大同小异。
if(is_array($action_group['priv'])){
$action_group['priv'] = $action_group['priv'];
}else{
$action_group['priv'] = array();
}
自定义导航栏也报错:
Warning: Illegal string offset 'cat_name' in admin\navigator.php on line 383
if(is_array($val)){...}
角色管理与权限管理:只有checkbox选框,没有label文字
锁定privilege_allot.htm与role_info.htm,修改如下:
$lang[$priv.action_code]->$lang.$priv.action_code
$lang[$list.action_code]->$lang.$list.action_code
数据备份:
Strict standards: Redefining already defined constructor for class cls_sql_dump in admin\includes\cls_sql_dump.php on line 90
类似还有支付方式:
Strict Standards: Redefining already defined constructor for class chinabank in includes/modules/payment/chinabank.php on line 85 Strict Standards: Redefining already defined constructor for class paypal_ec in includes/modules/payment/paypal_ec.php on line 96 Strict Standards: Redefining already defined constructor for class shenzhou in includes/modules/payment/shenzhou.php on line 81 Strict Standards: Redefining already defined constructor for class ips in includes/modules/payment/ips.php on line 82 Strict Standards: Redefining already defined constructor for class balance in includes/modules/payment/balance.php on line 79 Strict Standards: Redefining already defined constructor for class alipay in includes/modules/payment/alipay.php on line 85 Strict Standards: Redefining already defined constructor for class tenpay in includes/modules/payment/tenpay.php on line 83 Strict Standards: Redefining already defined constructor for class post in includes/modules/payment/post.php on line 79 Strict Standards: Redefining already defined constructor for class paypal in includes/modules/payment/paypal.php on line 82 Strict Standards: Redefining already defined constructor for class tenpayc2c in includes/modules/payment/tenpayc2c.php on line 83 Strict Standards: Redefining already defined constructor for class cappay in includes/modules/payment/cappay.php on line 81 Strict Standards: Redefining already defined constructor for class bank in includes/modules/payment/bank.php on line 79 Strict Standards: Redefining already defined constructor for class kuaiqian in includes/modules/payment/kuaiqian.php on line 83 Strict Standards: Redefining already defined constructor for class cod in includes/modules/payment/cod.php on line 82
使用和类名相同点函数名作为构造函数是php4时代的写法,php5时代的构造函数是__construct(),ecshop为了兼容老版本的php,所以采用了上面的写法。
但是从php5.4开始,对于这样的两种写法同时出现的情况,要求必须__construct()在前,同名函数在后,所以只需要对调两个函数的位置即可。
如alipay.php,将
function __construct()
{
$this->alipay();
}
放到
function alipay()
{ }
前面。
首页广告管理:
Strict standards: Only variables should be passed by reference in admin\flashplay.php on line 274
传参时赋值,偷懒了。
set_flash_data($_CFG['flash_theme'], $error_msg = '');
修改为:
$error_msg = ''
set_flash_data($_CFG['flash_theme'], $error_msg);
后台翻页功能失效,弹出 transport.js /run() error:undefined。
FF调试报错:Uncaught transport.js/parseResult() error: can't parse to JSON.
ECShop把AJAX事件和JSON解析的模块放在common/transport.js之中,在封装JSON各种方法的同时对object的模型进行了重写,跟jQuery冲突!
ECShop论坛上提出了一些办法,不是很好用。
1、首先复制一份 transport.js 改名为 transport.org.js 提供给后台使用
2、屏蔽掉transport.js里的toJSON功能,注释掉行数大概在497-737行之间的内容,从if ( ! Object.prototype.toJSONString)开始
修改352行为: legalParams = "JSON=" + $.toJSON(params);
修改408行为:result = $.evalJSON(result);
屏蔽掉global.js里的如下代码(第10-13行):
Object.prototype.extend = function(object)
{
return Object.extend.apply(this, [this, object]);
}
3、修改index.js文件44行为:var res = $.evalJSON(result);
4、修改common.js文件34行为:Ajax.call('flow.php?step=add_to_cart', 'goods=' + $.toJSON(goods), addToCartResponse, 'POST', 'JSON');
修改850行为:Ajax.call('flow.php?step=add_package_to_cart', 'package_info=' + $.toJSON(package_info), addPackageToCartResponse, 'POST', 'JSON');
修改1056行为:Ajax.call('flow.php?step=add_to_cart', 'goods=' + $.toJSON(goods), addToCartResponse, 'POST', 'JSON');
5、修改compare.js文件49行为: this.data = $.evalJSON(cookieValue);
修改67行为: var obj = $.evalJSON(cookieValue);
修改133行为: document.setCookie("compareItems", $.toJSON(this.data));
6、修改global.js文件
修改16行函数名 :function $e()
修改114和126行为:var element = $e(element);
7、修改后台头部引入transport.js路径
admin/templates/pageheader.htm 第9行改为: {insert_scripts files="../js/transport.org.js,common.js"}
admin/templates/menu.htm 第151行改为: {insert_scripts files="../js/global.js,../js/utils.js,../js/transport.org.js"}
8、修改themes/default/library/page_header.lbi文件在{insert_scripts files='transport.js,utils.js'}上面加上:
{insert_scripts files='jquery.js,jquery.json.js'}
jquery.json.js下载9、修改library/comment_list.lbi 188行为:
Ajax.call('comment.php', 'cmt=' + $.toJSON(cmt), commentResponse, 'POST', 'JSON');
10、修改compare.dwt 20行为:
var obj = $.evalJSON(document.getCookie("compareItems"));
24行: document.setCookie("compareItems", $.toJSON(obj));
11、修改flow.dwt 138行为:
Ajax.call('flow.php?step=add_to_cart', 'goods=' + $.toJSON(goods),collect_to_flow_response, 'POST', 'JSON');
199行: Ajax.call('flow.php?step=add_to_cart', 'goods=' + $.toJSON(goods),fittings_to_flow_response, 'POST', 'JSON');
12、修改brand.dwt、brand_list.dwt、category.dwt、exchange_list.dwt、search.dwt文件,增加
{insert_scripts files='jquery.js,jquery.json.js'}
{insert_scripts files='common.js,global.js,compare.js'}
注意:包括其他jquery文件需置顶的dwt文件,jquery.js文件需要在compare.js文件加载前加载
大概思路就是屏蔽ECshop扩展的toJSONString方法,用别的函数代替。
大型ECShop安装搬家升级错误问题最全攻略的更多相关文章
- 在net安装程序中部署oracle客户端全攻略
在net安装程序中部署oracle客户端全攻略 主要的是要做三件工作: 打包文件,写注册表,注册环境变量说明:我的oracle版本为9, 在2000 advanced server 上测试通过,可以正 ...
- VSCode插件开发全攻略(十)打包、发布、升级
更多文章请戳VSCode插件开发全攻略系列目录导航. 发布方式 插件开发完了,如何发布出去分享给他人呢?主要有3种方法: 方法一:直接把文件夹发给别人,让别人找到vscode的插件存放目录并放进去,然 ...
- Android-x86虚拟机安装配置全攻略
转自Android-x86虚拟机安装配置全攻略 注:这里安装从简,具体请参考虚拟机Vmware安装运行安卓4.0详细教程 Android-x86虚拟机安装配置网上有很多,但是全部说明白的确不多,希望这 ...
- VS2013全攻略(安装,技巧,快捷键,插件)!
工欲善其事,必先利其器.VS2013全攻略(安装,技巧,快捷键,插件)! 之前一篇<c++的性能, c#的产能?!鱼和熊掌可以兼得,.NET NATIVE初窥>承蒙大家喜爱和编辑推荐,在此 ...
- TestLink安装全攻略
TestLink安装全攻略 此文章转自该链接--http://www.cnblogs.com/Tcorner/archive/2011/07/26/2117296.html 安装前准备 需要下载xam ...
- Linux一键安装web环境全攻略phpstudy版
此教程主要是应对阿里云Linux云服务器ecs的web环境安装,理论上不限于阿里云服务器,此教程对所有Linux云服务器都具有参考价值. 写这篇文章的目的:网上有很多关于Linux一键安装web环境全 ...
- phpMyAdmin 安装教程全攻略
管理MYSQL数据库的最好工具是PHPmyAdmin,现在最新版本是phpMyAdmin 2.9.0.2,这是一个国际上开源的软件,一直在更新版本,你可以从 http://www.phpmyadmin ...
- WordPress搬家全攻略
零.前言 我自己有两个博客,一个是你看到的这个,专门用来写我的技术文章:另一个是我自己的心情记录博客,专门记录和技术无关的东西. 之前我的心情记录博客一直放在openshift上面,这是redhat官 ...
- 工欲善其事,必先利其器 之 VS2013全攻略(安装,技巧,快捷键,插件)!
如有需要WPF工具的朋友可以移步 工欲善其事,必先利其器 之 WPF篇: 随着开发轨迹来看高效WPF开发的工具和技巧 之前一篇<c++的性能, c#的产能?!鱼和熊掌可以兼得,.NET NATI ...
随机推荐
- Android_四大组件之ContentProvider
一.概述 ContentProvider(内容提供者)管理对结构化数据集的访问,它们封装数据,并提供用于定义数据安全性的机制.其他应用,通过Context的ContentResolver对象 作为客户 ...
- 漫谈碎片化学习(Fragmentation learning)
碎片化学习(Fragmentation Learning) 从一个互联网小段子讲起: 某天,美国情报部门FBI应奥巴马的要求,做相关汇报:“报告总统,经FBI分析,中国‘短信’中35%是节日祝福语,2 ...
- MANIFEST.MF是个什么?
MANIFEST.MF是个什么? 写这篇文件主要记录JRA文件里面到底是什么?然后MANIFEST.MF又是什么?Springboot 如何只有Main方法就可以运行的? Springboot项目打包 ...
- AUTOSAR-软件规范文档阅读
https://mp.weixin.qq.com/s/Jzm9oco-MA-U7Mn_6vOzvA 基于AUTOSAR_SWS_CANDriver.pdf,Specification of CAN ...
- 【Hadoop】hdfs的秘密,namenode,datanode,yarn,安全模式,fsimage,edits...
1.bin/hdfs namenode -format ** 注意事项 1.在配置好了配置文件之后,首次启动之前,做初始化操作 2.在后续启动的时候,不需要再初始化 3.初始化的一些影响 一.初始化操 ...
- Java实现 LeetCode 638 大礼包(阅读理解题,DFS)
638. 大礼包 在LeetCode商店中, 有许多在售的物品. 然而,也有一些大礼包,每个大礼包以优惠的价格捆绑销售一组物品. 现给定每个物品的价格,每个大礼包包含物品的清单,以及待购物品清单.请输 ...
- Java实现 蓝桥杯 算法提高 最大乘积
算法提高 最大乘积 时间限制:1.0s 内存限制:512.0MB 提交此题 问题描述 对于n个数,从中取出m个数,如何取使得这m个数的乘积最大呢? 输入格式 第一行一个数表示数据组数 每组输入数据共2 ...
- java实现Synchronized锁的用法
Java线程同步中的一个重要的概念synchronized. synchronized是java的关键字,是一种同步锁,它作用的对象有以下几种: ①作用在代码块上.该代码块称为同步代码块,作用范围是大 ...
- JavaScript使用for循环和splice删除数组指定元素的注意点
在JavaScript里可以结合for循环和splice来删除数组指定的元素.但是要注意删除元素后,数组索引会发生改变 示例 var arr = ["a","b" ...
- Go 语言入门教程:变量
基础使用 // base.go 注释package main // 包名import "fmt" // 导入 func main() { fmt.Println(" ...