WHMCS技巧:报错处理

2019年5月28日 | 分类: 【源码】

【报错:DataTables warning: table id=tableLinkedAccounts – Invalid JSON response.】

在调试WHMCS时,遇见报错:

DataTables warning: table id=tableLinkedAccounts - Invalid JSON response. 

设置Full Friendly URL之后就OK了。

参考:https://whmcs.community/topic/290579-creating-api-credentials-generete-and-error/

【报错:TCPDF ERROR: Could not include font definition file】

1. 报错问题

当使用一个使用TCPDF模块的程序时,页面报错:

TCPDF ERROR: Could not include font definition file

参考:https://www.jianshu.com/p/3c0ad038cee7
参考:https://blog.csdn.net/jijun7885417/article/details/5578160
参考:http://www.vpsbj.com/768.html#button_file

方法:下载TCPDF程序包,解压后把 fonts 文件夹,上传到程序的TCPDF目录下,即可解决。

下载:https://github.com/tecnickcom/tcpdf

wget https://github.com/tecnickcom/TCPDF/archive/master.zip && unzip master.zip

移动 fonts 文件夹到 vendor/tecnickcom/tcpdf/ 之下即可。

2. 乱码问题

前面一步能够解决PDF生成问题,但是涉及中文时,发现PDF里都是乱码。需要额外操作。

参考:http://www.zrblog.net/9205.html
参考:https://www.quyu.net/info/258.html

wget http://w.vpsaa.net/droidsansfallback.zip && unzip droidsansfallback.zip

压缩包里有3个文件:

droidsansfallback.ctg.z
droidsansfallback.php
droidsansfallback.z

移动到 vendor/tecnickcom/tcpdf/fonts/ 之下。

然后管理员账户登录WHMCS后台,依次进入Setup,General Settings,Inovices,在下面找到TCPDF Font Family,选择Custom,并填入droidsansfallback保存。

【报错:Invalid CSRF Protection Token】

参考:https://alpha-computer-services.acshostings.com/invalid-csrf-protection-token-fix-whmcs-error-centos/

编辑 php.ini

; http://php.net/session.save-path
session.save_path = "/tmp"

然后系统监控页面显示:

PHP Session 支持

PHP session 支持已启用。
Session 自动启动已禁用。
PHP session 保存路径 /tmp 为可写。

参考:https://whmcs.community/topic/279921-invalid-csrf-protection-token/

You can disable CSRF Checks under Setup > General Settings > Security.

【报错:ERROR: TypeError: Argument 2 passed to WHMCS\\Domains::saveContactDetails() must be of the type array】

当客户在后台选择一个域名进行联系人信息更新时,如果选择已存在联系人,然后保存时,报错:

[php7:notice][WHMCS Application] ERROR: TypeError: Argument 2 passed to WHMCS\\Domains::saveContactDetails() must be of the type array, string given, called in WHMCS/clientarea.php on line 0 and defined in WHMCS/vendor/whmcs/whmcs-foundation/lib/Domains.php:0 Stack trace: #0 WHMCS/clientarea.php(0): WHMCS\\Domains->saveContactDetails(Object(WHMCS\\Client), '', Array, Array) #1 {main} {"exception":"[object] (TypeError(code: 0): Argument 2 passed to WHMCS\\\\Domains::saveContactDetails() must be of the type array, string given, called in WHMCS/clientarea.php on line 0 at WHMCS/vendor/whmcs/whmcs-foundation/lib/Domains.php:0)"} [], referer: https://doomain.name/clientarea.php?action=domaincontacts&domainid=9999

参考:https://whmcs.community/topic/291864-issue-in-registrar-module-after-php-update-from-56-to-72/

i faced same problem and found out there’s a bug while updating whois info if you select “use existing contact” for every contact. For a temporary fix till offical fix:

编辑:WHMCS/templates/six/clientareadomaincontactinfo.tpl

找到:

{foreach from=$contactdetails name=contactdetails key=contactdetail item=values}

在其后添加1行:

<input type="hidden" name="contactdetails[{$contactdetail}][dummykey]" value="1" />

实证成功。

页面返回:

Changes Saved Successfully!

【报错:[WHMCS Application] ERROR: Error: Call to a member function translateTimestampToFormat() on null】

环境:Ubuntu 18.04 + PHP 7.3.13 + WHMCS 7.4.1

当进入后台时报错。