top-think / think-orm

Think ORM——the PHP Database&ORM Framework
Apache License 2.0
417 stars 175 forks source link

升级topthink/think-orm v3.0.27后报错 #636

Closed rainbar closed 3 weeks ago

rainbar commented 2 months ago

今天将think-orm从3.0.20升级到3.0.27后,之前运行一切正常的代码,报错:

think\\model\\relation\\BelongsToMany::matchPivot(): Argument #1 ($result) must be of type think\\Model, array given, called in E:\\plarg-web\\vendor\\topthink\\think-orm\\src\\model\\relation\\BelongsToMany.php on line 642

以下是完整错误:

{
    "message": "think\\model\\relation\\BelongsToMany::matchPivot(): Argument #1 ($result) must be of type think\\Model, array given, called in E:\\plarg-web\\vendor\\topthink\\think-orm\\src\\model\\relation\\BelongsToMany.php on line 642",
    "status": 500,
    "data": [],
    "debug": {
        "name": "TypeError",
        "file": "E:\\plarg-web\\vendor\\topthink\\think-orm\\src\\model\\relation\\BelongsToMany.php",
        "line": 159,
        "code": 0,
        "message": "think\\model\\relation\\BelongsToMany::matchPivot(): Argument #1 ($result) must be of type think\\Model, array given, called in E:\\plarg-web\\vendor\\topthink\\think-orm\\src\\model\\relation\\BelongsToMany.php on line 642",
        "trace": [
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\think-orm\\src\\model\\relation\\BelongsToMany.php",
                "line": 642,
                "function": "matchPivot",
                "class": "think\\model\\relation\\BelongsToMany",
                "type": "->",
                "args": [
                    {
                        "role_id": 10013
                    }
                ]
            },
            {
                "function": "think\\model\\relation\\{closure}",
                "class": "think\\model\\relation\\BelongsToMany",
                "type": "->",
                "args": [
                    {
                        "role_id": 10013
                    },
                    {
                        "json": [],
                        "json_assoc": false,
                        "field_type": [],
                        "key": null,
                        "readonly_fields": [],
                        "lazy_fields": [],
                        "filter": [
                            {}
                        ],
                        "join": [
                            [
                                {
                                    "plarg_role_user": "pivot"
                                },
                                "INNER",
                                "pivot.role_id=plarg_role.id"
                            ]
                        ],
                        "where": {
                            "AND": [
                                [
                                    "pivot.user_id",
                                    "=",
                                    10001
                                ]
                            ]
                        },
                        "table": "plarg_role",
                        "data": [],
                        "order": [],
                        "union": [],
                        "with_attr": [],
                        "with_relation_attr": [],
                        "strict": true,
                        "master": false,
                        "lock": false,
                        "fetch_sql": false,
                        "array": false,
                        "distinct": false,
                        "procedure": false,
                        "with_cache": false,
                        "group": "",
                        "having": "",
                        "limit": "",
                        "force": "",
                        "comment": "",
                        "partition": "",
                        "duplicate": "",
                        "extra": "",
                        "field": {
                            "0": "plarg_role.*",
                            "pivot.id": "pivot__id",
                            "pivot.role_id": "pivot__role_id",
                            "pivot.user_id": "pivot__user_id"
                        }
                    }
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\think-orm\\src\\db\\concern\\ResultOperation.php",
                "line": 101,
                "function": "call_user_func_array",
                "args": [
                    {},
                    [
                        {
                            "role_id": 10013
                        },
                        {
                            "json": [],
                            "json_assoc": false,
                            "field_type": [],
                            "key": null,
                            "readonly_fields": [],
                            "lazy_fields": [],
                            "filter": [
                                {}
                            ],
                            "join": [
                                [
                                    {
                                        "plarg_role_user": "pivot"
                                    },
                                    "INNER",
                                    "pivot.role_id=plarg_role.id"
                                ]
                            ],
                            "where": {
                                "AND": [
                                    [
                                        "pivot.user_id",
                                        "=",
                                        10001
                                    ]
                                ]
                            },
                            "table": "plarg_role",
                            "data": [],
                            "order": [],
                            "union": [],
                            "with_attr": [],
                            "with_relation_attr": [],
                            "strict": true,
                            "master": false,
                            "lock": false,
                            "fetch_sql": false,
                            "array": false,
                            "distinct": false,
                            "procedure": false,
                            "with_cache": false,
                            "group": "",
                            "having": "",
                            "limit": "",
                            "force": "",
                            "comment": "",
                            "partition": "",
                            "duplicate": "",
                            "extra": "",
                            "field": {
                                "0": "plarg_role.*",
                                "pivot.id": "pivot__id",
                                "pivot.role_id": "pivot__role_id",
                                "pivot.user_id": "pivot__user_id"
                            }
                        }
                    ]
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\think-orm\\src\\db\\BaseQuery.php",
                "line": 431,
                "function": "result",
                "class": "think\\db\\BaseQuery",
                "type": "->",
                "args": [
                    {
                        "role_id": 10013
                    }
                ]
            },
            {
                "function": "think\\db\\{closure}",
                "class": "think\\db\\BaseQuery",
                "type": "->",
                "args": [
                    10013
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\think-orm\\src\\db\\BaseQuery.php",
                "line": 407,
                "function": "array_map",
                "args": [
                    {},
                    [
                        10013
                    ]
                ]
            },
            {
                "function": "column",
                "class": "think\\db\\BaseQuery",
                "type": "->",
                "args": [
                    "role_id"
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\think-orm\\src\\model\\Relation.php",
                "line": 245,
                "function": "call_user_func_array",
                "args": [
                    [
                        {},
                        "column"
                    ],
                    [
                        "role_id"
                    ]
                ]
            },
            {
                "file": "E:\\plarg-web\\app\\api\\model\\manage\\User.php",
                "line": 253,
                "function": "__call",
                "class": "think\\model\\Relation",
                "type": "->",
                "args": [
                    "column",
                    [
                        "role_id"
                    ]
                ]
            },
            {
                "file": "E:\\plarg-web\\app\\api\\service\\manage\\Role.php",
                "line": 61,
                "function": "getRoleIds",
                "class": "app\\api\\model\\manage\\User",
                "type": "::",
                "args": [
                    10001
                ]
            },
            {
                "file": "E:\\plarg-web\\app\\api\\service\\manage\\Role.php",
                "line": 36,
                "function": "getPermittedMenuList",
                "class": "app\\api\\service\\manage\\Role",
                "type": "::",
                "args": [
                    10001,
                    true
                ]
            },
            {
                "file": "E:\\plarg-web\\app\\api\\model\\manage\\User.php",
                "line": 182,
                "function": "getLoginPermissions",
                "class": "app\\api\\service\\manage\\Role",
                "type": "::",
                "args": [
                    {
                        "id": 10001,
                        "nickname": "系统管理员",
                        "s": true,
                        "events": [
                            {
                                "id": 10013,
                                "event_group": "FINANCE"
                            }
                        ]
                    }
                ]
            },
            {
                "file": "E:\\plarg-web\\app\\api\\controller\\User.php",
                "line": 71,
                "function": "login",
                "class": "app\\api\\model\\manage\\User",
                "type": "->",
                "args": [
                    {
                        "username": "*****",
                        "password": "*****"
                    }
                ]
            },
            {
                "function": "login",
                "class": "app\\api\\controller\\User",
                "type": "->",
                "args": []
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Container.php",
                "line": 345,
                "function": "invokeArgs",
                "class": "ReflectionMethod",
                "type": "->",
                "args": [
                    {},
                    []
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\route\\dispatch\\Controller.php",
                "line": 110,
                "function": "invokeReflectMethod",
                "class": "think\\Container",
                "type": "->",
                "args": [
                    {},
                    {
                        "name": "login",
                        "class": "app\\api\\controller\\User"
                    },
                    {
                        "s": "Ht42A1kTAnqK7VBmOmCIBI~PiLiIeK0Ugr"
                    }
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 59,
                "function": "think\\route\\dispatch\\{closure}",
                "class": "think\\route\\dispatch\\Controller",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 66,
                "function": "think\\{closure}",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\route\\dispatch\\Controller.php",
                "line": 84,
                "function": "then",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\route\\Dispatch.php",
                "line": 52,
                "function": "exec",
                "class": "think\\route\\dispatch\\Controller",
                "type": "->",
                "args": []
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Route.php",
                "line": 755,
                "function": "run",
                "class": "think\\route\\Dispatch",
                "type": "->",
                "args": []
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 59,
                "function": "think\\{closure}",
                "class": "think\\Route",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 66,
                "function": "think\\{closure}",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Route.php",
                "line": 754,
                "function": "then",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Http.php",
                "line": 208,
                "function": "dispatch",
                "class": "think\\Route",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Http.php",
                "line": 198,
                "function": "dispatchToRoute",
                "class": "think\\Http",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 59,
                "function": "think\\{closure}",
                "class": "think\\Http",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\think-multi-app\\src\\MultiApp.php",
                "line": 51,
                "function": "think\\{closure}",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 59,
                "function": "think\\app\\{closure}",
                "class": "think\\app\\MultiApp",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 66,
                "function": "think\\{closure}",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\think-multi-app\\src\\MultiApp.php",
                "line": 50,
                "function": "then",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "function": "handle",
                "class": "think\\app\\MultiApp",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Middleware.php",
                "line": 134,
                "function": "call_user_func",
                "args": [
                    [
                        {},
                        "handle"
                    ],
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 85,
                "function": "think\\{closure}",
                "class": "think\\Middleware",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\cores\\middleware\\AppLog.php",
                "line": 43,
                "function": "think\\{closure}",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "function": "handle",
                "class": "cores\\middleware\\AppLog",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Middleware.php",
                "line": 134,
                "function": "call_user_func",
                "args": [
                    [
                        {},
                        "handle"
                    ],
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 85,
                "function": "think\\{closure}",
                "class": "think\\Middleware",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\cores\\middleware\\AllowCrossDomain.php",
                "line": 101,
                "function": "think\\{closure}",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "function": "handle",
                "class": "cores\\middleware\\AllowCrossDomain",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Middleware.php",
                "line": 134,
                "function": "call_user_func",
                "args": [
                    [
                        {},
                        "handle"
                    ],
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 85,
                "function": "think\\{closure}",
                "class": "think\\Middleware",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\think-trace\\src\\TraceDebug.php",
                "line": 71,
                "function": "think\\{closure}",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "function": "handle",
                "class": "think\\trace\\TraceDebug",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Middleware.php",
                "line": 134,
                "function": "call_user_func",
                "args": [
                    [
                        {},
                        "handle"
                    ],
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 85,
                "function": "think\\{closure}",
                "class": "think\\Middleware",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Pipeline.php",
                "line": 66,
                "function": "think\\{closure}",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Http.php",
                "line": 197,
                "function": "then",
                "class": "think\\Pipeline",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Http.php",
                "line": 162,
                "function": "runWithRequest",
                "class": "think\\Http",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "E:\\plarg-web\\public\\index.php",
                "line": 30,
                "function": "run",
                "class": "think\\Http",
                "type": "->",
                "args": []
            }
        ],
        "source": {
            "first": 150,
            "source": [
                "    }\n",
                "\n",
                "    \/**\n",
                "     * 组装Pivot模型.\n",
                "     *\n",
                "     * @param Model $result 模型对象\n",
                "     *\n",
                "     * @return array\n",
                "     *\/\n",
                "    protected function matchPivot(Model $result): array\n",
                "    {\n",
                "        $pivot = [];\n",
                "        foreach ($result->getData() as $key => $val) {\n",
                "            if (str_contains($key, '__')) {\n",
                "                [$name, $attr] = explode('__', $key, 2);\n",
                "\n",
                "                if ('pivot' == $name) {\n",
                "                    $pivot[$attr] = $val;\n",
                "                    unset($result->$key);\n"
            ]
        }
    }
}{
    "message": "var_export does not handle circular references",
    "status": 500,
    "data": [],
    "debug": {
        "name": "think\\exception\\ErrorException",
        "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\log\\driver\\File.php",
        "line": 81,
        "code": 2,
        "message": "var_export does not handle circular references",
        "trace": [
            {
                "function": "appError",
                "class": "think\\initializer\\Error",
                "type": "->",
                "args": [
                    2,
                    "var_export does not handle circular references",
                    "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\log\\driver\\File.php",
                    81
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\log\\driver\\File.php",
                "line": 81,
                "function": "var_export",
                "args": [
                    {},
                    true
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\log\\Channel.php",
                "line": 137,
                "function": "save",
                "class": "think\\log\\driver\\File",
                "type": "->",
                "args": [
                    {
                        "info": [
                            "[Controller->initialize]",
                            "[Controller->checkPrivilege]: user\/login",
                            "Auth::getInstance(Controller)",
                            "使用新实例",
                            "使用单例",
                            "[Auth->CheckPrivilege]user\/login",
                            "[AllowApi]",
                            {
                                "username": "*****",
                                "password": "*****"
                            },
                            "check belongsToMany",
                            {}
                        ],
                        "sql": [
                            "CONNECT:[ UseTime:0.000771s ] mysql:host=127.0.0.1;port=3306;dbname=plarg_db;charset=utf8",
                            "SELECT `id`,`nickname`,`password`,`s` FROM `plarg_user` WHERE  `username` = 'admin'  AND `is_delete` = 0 LIMIT 1 [ RunTime:0.000394s ]",
                            "SELECT `plarg_role`.*,`pivot`.`id` AS `pivot__id`,`pivot`.`role_id` AS `pivot__role_id`,`pivot`.`user_id` AS `pivot__user_id` FROM `plarg_role` INNER JOIN `plarg_role_user` `pivot` ON `pivot`.`role_id`=`plarg_role`.`id` WHERE  `pivot`.`user_id` = '10001' [ RunTime:0.001970s ]",
                            "SELECT * FROM `plarg_user` WHERE  `id` = 10001 LIMIT 1 [ RunTime:0.000408s ]",
                            "SELECT `role_id` FROM `plarg_role` INNER JOIN `plarg_role_user` `pivot` ON `pivot`.`role_id`=`plarg_role`.`id` WHERE  `pivot`.`user_id` = '10001' [ RunTime:0.000332s ]"
                        ],
                        "error": [
                            "[0]think\\model\\relation\\BelongsToMany::matchPivot(): Argument #1 ($result) must be of type think\\Model, array given, called in E:\\plarg-web\\vendor\\topthink\\think-orm\\src\\model\\relation\\BelongsToMany.php on line 642[E:\\plarg-web\\vendor\\topthink\\think-orm\\src\\model\\relation\\BelongsToMany.php:159]"
                        ]
                    }
                ]
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Log.php",
                "line": 173,
                "function": "save",
                "class": "think\\log\\Channel",
                "type": "->",
                "args": []
            },
            {
                "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Http.php",
                "line": 277,
                "function": "save",
                "class": "think\\Log",
                "type": "->",
                "args": []
            },
            {
                "file": "E:\\plarg-web\\public\\index.php",
                "line": 34,
                "function": "end",
                "class": "think\\Http",
                "type": "->",
                "args": [
                    {}
                ]
            }
        ],
        "source": {
            "first": 72,
            "source": [
                "        $info = [];\n",
                "\n",
                "        \/\/ 日志信息封装\n",
                "        $time = \\DateTime::createFromFormat('0.u00 U', microtime())->setTimezone(new \\DateTimeZone(date_default_timezone_get()))->format($this->config['time_format']);\n",
                "\n",
                "        foreach ($log as $type => $val) {\n",
                "            $message = [];\n",
                "            foreach ($val as $msg) {\n",
                "                if (!is_string($msg)) {\n",
                "                    $msg = var_export($msg, true);\n",
                "                }\n",
                "\n",
                "                $message[] = $this->config['json'] ?\n",
                "                json_encode(['time' => $time, 'type' => $type, 'msg' => $msg], $this->config['json_options']) :\n",
                "                sprintf($this->config['format'], $time, $type, $msg);\n",
                "            }\n",
                "\n",
                "            if (true === $this->config['apart_level'] || in_array($type, $this->config['apart_level'])) {\n",
                "                \/\/ 独立记录的日志级别\n"
            ]
        }
    }
}{
    "message": "Uncaught think\\exception\\ErrorException: var_export does not handle circular references in E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\log\\driver\\File.php:81\nStack trace:\n#0 [internal function]: think\\initializer\\Error->appError(2, 'var_export does...', 'E:\\\\plarg-web\\\\ve...', 81)\n#1 E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\log\\driver\\File.php(81): var_export(Object(think\\model\\relation\\BelongsToMany), true)\n#2 E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\log\\Channel.php(137): think\\log\\driver\\File->save(Array)\n#3 E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Log.php(173): think\\log\\Channel->save()\n#4 E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Http.php(277): think\\Log->save()\n#5 E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\initializer\\Error.php(60): think\\Http->end(Object(think\\response\\Json))\n#6 [internal function]: think\\initializer\\Error->appException(Object(think\\exception\\ErrorException))\n#7 {main}\n  thrown",
    "status": 500,
    "data": [],
    "debug": {
        "name": "think\\exception\\ErrorException",
        "file": "E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\log\\driver\\File.php",
        "line": 81,
        "code": 1,
        "message": "Uncaught think\\exception\\ErrorException: var_export does not handle circular references in E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\log\\driver\\File.php:81\nStack trace:\n#0 [internal function]: think\\initializer\\Error->appError(2, 'var_export does...', 'E:\\\\plarg-web\\\\ve...', 81)\n#1 E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\log\\driver\\File.php(81): var_export(Object(think\\model\\relation\\BelongsToMany), true)\n#2 E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\log\\Channel.php(137): think\\log\\driver\\File->save(Array)\n#3 E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Log.php(173): think\\log\\Channel->save()\n#4 E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\Http.php(277): think\\Log->save()\n#5 E:\\plarg-web\\vendor\\topthink\\framework\\src\\think\\initializer\\Error.php(60): think\\Http->end(Object(think\\response\\Json))\n#6 [internal function]: think\\initializer\\Error->appException(Object(think\\exception\\ErrorException))\n#7 {main}\n  thrown",
        "trace": [
            {
                "function": "appShutdown",
                "class": "think\\initializer\\Error",
                "type": "->",
                "args": []
            }
        ],
        "source": {
            "first": 72,
            "source": [
                "        $info = [];\n",
                "\n",
                "        \/\/ 日志信息封装\n",
                "        $time = \\DateTime::createFromFormat('0.u00 U', microtime())->setTimezone(new \\DateTimeZone(date_default_timezone_get()))->format($this->config['time_format']);\n",
                "\n",
                "        foreach ($log as $type => $val) {\n",
                "            $message = [];\n",
                "            foreach ($val as $msg) {\n",
                "                if (!is_string($msg)) {\n",
                "                    $msg = var_export($msg, true);\n",
                "                }\n",
                "\n",
                "                $message[] = $this->config['json'] ?\n",
                "                json_encode(['time' => $time, 'type' => $type, 'msg' => $msg], $this->config['json_options']) :\n",
                "                sprintf($this->config['format'], $time, $type, $msg);\n",
                "            }\n",
                "\n",
                "            if (true === $this->config['apart_level'] || in_array($type, $this->config['apart_level'])) {\n",
                "                \/\/ 独立记录的日志级别\n"
            ]
        }
    }
}
liu21st commented 2 months ago

方便的话最好是能给出你的相关代码和模型定义