fix: 让 ORM PHP 8.5 补丁可稳定重放
使用 Git 生成的准确上下文重建 BelongsTo 补丁,避免 Composer Patches 在干净依赖安装时匹配失败。
This commit is contained in:
1 parent
9870d34539
commit
83c61525e6
2 files changed
+5
-20
No files matched your search
+2
-2
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"_hash": "b61e9986281bedf2168d1d1fea09b579521a71beb2c2d782bf3829da349ce9df",
|
||||
"_hash": "f7ce0f87349f1edfedc27878922668db20f1ea6c982cff73d23da2d75a5e70c7",
|
||||
"patches": {
|
||||
"topthink/think-captcha": [
|
||||
{
|
||||
@@ -18,7 +18,7 @@
|
||||
"package": "topthink/think-orm",
|
||||
"description": "Handle null belongs-to keys without deprecated offsets",
|
||||
"url": "patches/think-orm-php85-null-belongs-to.patch",
|
||||
"sha256": "8a1e9b05b7ef70666a9d8447a9e608d942a9e042e53969f2fbeb6c8cb9afe468",
|
||||
"sha256": "b1ea4f9ad2eab7ded56d7e5f759f8223f88ab8572b93288fcf7527c2ebc6ddaf",
|
||||
"depth": 1,
|
||||
"extra": {
|
||||
"provenance": "root"
|
||||
|
||||
@@ -1,28 +1,13 @@
|
||||
diff --git a/src/model/relation/BelongsTo.php b/src/model/relation/BelongsTo.php
|
||||
index 02188c9f..a280b5f0 100644
|
||||
index 02188c9f..72755365 100644
|
||||
--- a/src/model/relation/BelongsTo.php
|
||||
+++ b/src/model/relation/BelongsTo.php
|
||||
@@ -272,19 +272,20 @@ class BelongsTo extends OneToOne
|
||||
{
|
||||
$localKey = $this->localKey;
|
||||
$foreignKey = $this->foreignKey;
|
||||
+ $foreignValue = $result->$foreignKey;
|
||||
|
||||
$this->query->removeWhereField($localKey);
|
||||
|
||||
$data = $this->eagerlyWhere([
|
||||
- [$localKey, '=', $result->$foreignKey],
|
||||
+ [$localKey, '=', $foreignValue],
|
||||
@@ -280,7 +280,7 @@ class BelongsTo extends OneToOne
|
||||
], $localKey, $subRelation, $closure, $cache);
|
||||
|
||||
// 关联模型
|
||||
- if (!isset($data[$result->$foreignKey])) {
|
||||
+ if ($foreignValue === null || !isset($data[$foreignValue])) {
|
||||
+ if ($result->$foreignKey === null || !isset($data[$result->$foreignKey])) {
|
||||
$default = $this->query->getOption('default_model');
|
||||
$relationModel = $this->getDefaultModel($default);
|
||||
} else {
|
||||
- $relationModel = $data[$result->$foreignKey];
|
||||
+ $relationModel = $data[$foreignValue];
|
||||
}
|
||||
|
||||
// 动态绑定参数
|
||||
Reference in new issue
Block a user