0%

WordPress 老版本遇到 PHP7.0

最近服务器更新了之后,PHP的版本自动升级到了。php7.0,
由于使用的插件等原因不支持高级版本的Wordpress,所以一直还在使用Wordpress 4.8.2的版本,
这回终于出问题了。
输入后台地址,一片白屏どうしよう

没办法,去wordpress根目录下, 修改wp-config.php

1
define('WP_DEBUG', true);

看看出了什么问题。

果不其然,一大堆的错误,主要是wp-include/user.php和 根目录下wp-login.php的问题。

1
2
3
4
5
6
7
Warning: Illegal string offset 'remember' in /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-includes/user.php on line 41

Warning: Cannot assign an empty string to a string offset in /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-includes/user.php on line 41

Warning: Illegal string offset 'user_login' in /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-includes/user.php on line 56

Fatal error: Uncaught Error: Cannot create references to/from string offsets in /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-includes/user.php:56 Stack trace: #0 /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-login.php(784): wp_signon('', '') #1 {main} thrown in /Users/USERNAME/Documents/Websites/PROJECTNAME/web/wp/wp-includes/user.php on line 56

在G上面一顿寻找,终于找到了一个最简单的解决方法。

打开wp-login.php
找到795行左右,找到

1
2
$reauth = empty($_REQUEST['reauth']) ? false : true;
$user = wp_signon( '', $secure_cookie );

替换

1
$user = wp_signon( '', $secure_cookie );

1
$user = wp_signon( array(), $secure_cookie );

即可解决问题。