Просмотр исходного кода

💡 (api-v13): FIXME:ArticleResource 作者没有译文 channel 时 500

->get() 返回的集合永远为真,作者名下没有译文 channel 时 $studioChannel[0] 报错,
系统 channel 的回退分支永远走不到。v2 代码,迁 article 到 v3 时修。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda 11 часов назад
Родитель
Сommit
4dde65ba63
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      api-v13/app/Http/Resources/ArticleResource.php

+ 3 - 0
api-v13/app/Http/Resources/ArticleResource.php

@@ -143,6 +143,9 @@ class ArticleResource extends JsonResource
                 }
             }
             if (count($channels) === 0) {
+                // FIXME: ->get() 返回的集合永远为真,作者名下没有译文 channel 时 $studioChannel[0] 直接报错
+                // (Undefined array key 0 → 500,文集阅读页与 v2 文章接口都会中);下面的系统 channel 回退分支
+                // 永远走不到。迁 article 到 v3 时修:用 ->value('uid') 判空,取不到再回退系统 channel。
                 // 查找用户默认channel
                 $studioChannel = Channel::where('owner_uid', $this->owner)
                     ->where('type', 'translation')