top-think / think-orm

Think ORM——the PHP Database&ORM Framework
Apache License 2.0
413 stars 171 forks source link

修正 $this->options['scope'] 储存了模型对象,导致无法被 var_export() #604

Closed big-dream closed 1 month ago

big-dream commented 1 month ago

测试代码:

City::scope('default')->cache(true, null, 'city')->select();

错误信息:var_export does not handle circular references 错误文件:vendor/topthink/think-orm/src/db/Query.php:520

https://github.com/top-think/think-orm/blob/312d1b1360ec8fd43dd9e843b16154cba1ae41d0/src/db/Query.php#L511-L521

Traces:

[
        {
            "function": "appError",
            "class": "think\\initializer\\Error",
            "type": "->"
        },
        {
            "file": "vendor/topthink/think-orm/src/db/Query.php",
            "line": 520,
            "function": "var_export"
        },
        {
            "file": "vendor/topthink/think-orm/src/db/Connection.php",
            "line": 325,
            "function": "getQueryGuid",
            "class": "think\\db\\Query",
            "type": "->"
        },
        {
            "file": "vendor/topthink/think-orm/src/db/Connection.php",
            "line": 348,
            "function": "getCacheKey",
            "class": "think\\db\\Connection",
            "type": "->"
        },
        {
            "file": "vendor/topthink/think-orm/src/db/PDOConnection.php",
            "line": 728,
            "function": "parseCache",
            "class": "think\\db\\Connection",
            "type": "->"
        },
        {
            "file": "vendor/topthink/think-orm/src/db/PDOConnection.php",
            "line": 973,
            "function": "pdoQuery",
            "class": "think\\db\\PDOConnection",
            "type": "->"
        },
        {
            "file": "vendor/topthink/think-orm/src/db/BaseQuery.php",
            "line": 1320,
            "function": "select",
            "class": "think\\db\\PDOConnection",
            "type": "->"
        },
        {
            "file": "app/base/controller/City.php",
            "line": 24,
            "function": "select",
            "class": "think\\db\\BaseQuery",
            "type": "->"
        }
]
codecov-commenter commented 1 month ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 12.32%. Comparing base (e35f497) to head (fcc04a3). Report is 57 commits behind head on 3.0.

Files Patch % Lines
src/db/Query.php 0.00% 4 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## 3.0 #604 +/- ## ============================================ + Coverage 12.24% 12.32% +0.07% - Complexity 2965 2999 +34 ============================================ Files 64 64 Lines 7129 7181 +52 ============================================ + Hits 873 885 +12 - Misses 6256 6296 +40 ``` | [Flag](https://app.codecov.io/gh/top-think/think-orm/pull/604/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=top-think) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/top-think/think-orm/pull/604/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=top-think) | `12.32% <0.00%> (+0.07%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=top-think#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.