升级框架及稳定依赖,修复路由、鉴权、种子、动态属性和 PHP 8.5 弃用问题。 固化 ThinkCaptcha 和 ORM 的 PHP 8.5 兼容补丁;Composer 安装会自动应用并由 patches.lock.json 锁定。 验证:45 条迁移、依赖校验与安全审计、验证码 PNG 响应及关键页面/API 回归通过。
29 lines
1.1 KiB
Diff
29 lines
1.1 KiB
Diff
diff --git a/src/model/relation/BelongsTo.php b/src/model/relation/BelongsTo.php
|
|
index 02188c9f..a280b5f0 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],
|
|
], $localKey, $subRelation, $closure, $cache);
|
|
|
|
// 关联模型
|
|
- if (!isset($data[$result->$foreignKey])) {
|
|
+ if ($foreignValue === null || !isset($data[$foreignValue])) {
|
|
$default = $this->query->getOption('default_model');
|
|
$relationModel = $this->getDefaultModel($default);
|
|
} else {
|
|
- $relationModel = $data[$result->$foreignKey];
|
|
+ $relationModel = $data[$foreignValue];
|
|
}
|
|
|
|
// 动态绑定参数
|