首页 话题 小组 问答 好文 用户 我的社区 域名交易 唠叨

[分享]Discuz! remote_service mod_index has a deprecated constructor 报错与解决办法

发布于 2025-03-29 13:58:29
0
24

Discuz 系统中出现如下报错:

PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; remote_service has a deprecated constructor in ...\api\remote\index.php on line 111

PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; mod_index has a deprecated constructor in ...\api\remote\mod\mod_index.php on line 14

PHP Notice:  Undefined index: mod in ...\connect.php on line 10

前面两个报错

都是由一个原因引起的:使用了和类名相同的方法作为构造方法。(目前官方已经不建议使用该方法构建),目前该问题还是会出现一些老版本的DZ程序中。

解决办法:

按照系统报错提示,打开该类的所在文件,然后将类名相同的方法名改为__construct。细节问题可以参考PHP手册中的魔术方法一节。

PHP Notice:  Undefined index: mod in ...\connect.php on line 10 报错

这个问题的出现是因为Discuz! connect.php中使用了可能不存在的超全局变量$_GET的索引值

解决办法:

打开connect.php 搜索

if($_GET['mod'] == 'register')

修改为

if(filter_has_var(INPUT_GET, 'mod') && $_GET['mod'] == 'register') 

Discuz!有大量的BUG和代码错误,一旦发现就要纠正,否则很容易被黑客利用。

评论
一个月内的热帖推荐
九秘
Lv.1种子选手

209

帖子

18

小组

362

积分

站长交流