diff --git a/patches.lock.json b/patches.lock.json index 61d134eb..3f4befb3 100644 --- a/patches.lock.json +++ b/patches.lock.json @@ -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" diff --git a/patches/think-orm-php85-null-belongs-to.patch b/patches/think-orm-php85-null-belongs-to.patch index 731b95aa..312ee505 100644 --- a/patches/think-orm-php85-null-belongs-to.patch +++ b/patches/think-orm-php85-null-belongs-to.patch @@ -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]; - } - - // 动态绑定参数