Home  >  Article  >  Backend Development  >  typecho安装后文章页面报错,Typecho_Json未找到

typecho安装后文章页面报错,Typecho_Json未找到

WBOY
WBOYOriginal
2016-06-06 20:29:061728browse

Warning: arraymap() expects parameter 1 to be a valid callback, class 'TypechoJson' not found in /mnt/sdcard/www/var/Json.php on line 243

Warning: Invalid argument supplied for foreach() in /mnt/sdcard/www/var/Json.php on line 245

Warning: join(): Invalid arguments passed in /mnt/sdcard/www/var/Json.php on line 252

环境是openwrt+uhttpd+php+mysql。
什么地方出了问题?

php代码:
// treat it like a regular array

<code>            $elements = array_map(array('Typecho_Json', '_encode'), $var);

            foreach ($elements as $element) {
                if (self::_is_error($element)) {
                    return $element;
                }
            }

            return '[' . join(',', $elements) . ']';
</code>

回复内容:

Warning: arraymap() expects parameter 1 to be a valid callback, class 'TypechoJson' not found in /mnt/sdcard/www/var/Json.php on line 243

Warning: Invalid argument supplied for foreach() in /mnt/sdcard/www/var/Json.php on line 245

Warning: join(): Invalid arguments passed in /mnt/sdcard/www/var/Json.php on line 252

环境是openwrt+uhttpd+php+mysql。
什么地方出了问题?

php代码:
// treat it like a regular array

<code>            $elements = array_map(array('Typecho_Json', '_encode'), $var);

            foreach ($elements as $element) {
                if (self::_is_error($element)) {
                    return $element;
                }
            }

            return '[' . join(',', $elements) . ']';
</code>

你的环境中没有安装 JSON 库,导致程序退而求其次使用了这个解析库,然后触发了一些遗留 BUG。错误提示很明显是说Typecho_Json这个库找不到,仔细阅读代码就可以发现这句话应该是函数本身的一个递归遍历,应该调用的是自身。解决办法就是把这个库的所有 Typecho_Json 替换成 Json

事实上你搜索一下会发现,这个文件在早前的版本中是叫 Typecho_Json 的,只是在后来的版本中改了名字,但是内部的名字忘了改回来了而已。

根据你这个问题我已经发起了一个 PullRequest 修复这个问题了:https://github.com/typecho/typecho/pull/394

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn