Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

插入mongo抛出了异常:invalid document for insert: keys cannot contain "." #19

Closed
seaperson opened this issue May 11, 2018 · 2 comments

Comments

@seaperson
Copy link

BUG描述
搭建完后可以访问,但一直是初始页面,什么数据都没有,去查错误日志后才发现,在插入mongo的时候抛出了这个异常:
xhgui - invalid document for insert: keys cannot contain ".": "main()==>load::web/index.php"
xhgui - invalid document for insert: keys cannot contain ".": "main()==>load::webroot/index.php"

系统:ubuntu14.04
php版本:5.6.35
mongo:2.6.12
tidesway:4.1.5

请问这个是什么导致的?大佬有遇到过吗?求教!

@laynefyc
Copy link
Owner

laynefyc commented May 14, 2018

MongoDB 2.6存储数据时key不能有 . 符号,所以会报错。解决办法如下两种:

  1. 使用MongoDB 2.4

  2. 修改代码
    打开 xhgui/external/header.php 文件,搜索 ignore_user_abort(true); 函数,在该函数前添加如下代码:

       $profile = [];
        foreach($data['profile'] as $key => $value) {
            $profile[strtr($key, ['.' => '_'])] = $value;
        }
        $data['profile'] = $profile;

@seaperson
Copy link
Author

好的 谢谢 我用了类似第二种方法确实解决了,有时间再试试MongoDB2.4,感谢大佬的解答^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants