Wordpress 打开媒体库500问题

原文地址:https://blog.qjm253.cn/?p=426

问题描述

这两天刚用wordpress搭好博客,发现后台管理界面的媒体库打开失败,服务器返回500错误。wordpress中最让人摸不着头脑的便是这个错误了,就告诉你服务器出错了,具体错在哪无从下手。

幸亏wordpress可以通过在wp-config.php中通过开启debug模式来获得更多的输出。具体操作是编辑根目录下的wp-config.php文件,加上下面这一行(如果原来有就将false改为true即可)

define('WP_DEBUG', true);

这样一来再次访问媒体库:https://xxx.xxx.xxx/wp-admin/upload.php
得到下面的错误输出:

Fatal error: Uncaught Error: Cannot access empty property in /home/blog/wordpress/wp-includes/functions.php:3071 Stack trace: #0 /home/blog/wordpress/wp-includes/functions.php(3054): _wp_json_sanity_check(Object(stdClass), 511) #1 /home/blog/wordpress/wp-includes/functions.php(3016): _wp_json_sanity_check(Array, 512) #2 /home/blog/wordpress/wp-includes/class.wp-scripts.php(429): wp_json_encode(Array) #3 /home/blog/wordpress/wp-includes/functions.wp-scripts.php(192): WP_Scripts->localize(‘media-grid’, ‘_wpMediaGridSet…’, Array) #4 /home/blog/wordpress/wp-admin/upload.php(43): wp_localize_script(‘media-grid’, ‘_wpMediaGridSet…’, Array) #5 {main} thrown in /home/blog/wordpress/wp-includes/functions.php on line 3071

解决办法

错误指出在执行到/wp-includes/functions.php 文件下的第3071行的时候出错了,我们打开源文件看一下:
出错代码源文件
可以知道在访问$output的属性的时候出错了,应该是$output->clean_id,只需将3091、3073、3075这三行的代码改正,接着再打开媒体库就没问题了。
image

发布了55 篇原创文章 · 获赞 29 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qq_33215972/article/details/81588664