Files
mayi-grade/patches/think-orm-php85-null-belongs-to.patch
biss 83c61525e6 fix: 让 ORM PHP 8.5 补丁可稳定重放
使用 Git 生成的准确上下文重建 BelongsTo 补丁,避免 Composer Patches 在干净依赖安装时匹配失败。
2026-10-04 14:28:22 +08:00

14 lines
618 B
Diff

diff --git a/src/model/relation/BelongsTo.php b/src/model/relation/BelongsTo.php
index 02188c9f..72755365 100644
--- a/src/model/relation/BelongsTo.php
+++ b/src/model/relation/BelongsTo.php
@@ -280,7 +280,7 @@ class BelongsTo extends OneToOne
], $localKey, $subRelation, $closure, $cache);
// 关联模型
- if (!isset($data[$result->$foreignKey])) {
+ if ($result->$foreignKey === null || !isset($data[$result->$foreignKey])) {
$default = $this->query->getOption('default_model');
$relationModel = $this->getDefaultModel($default);
} else {