浏览代码

Fix load guest in Users->loadByIds()

for #5
Visman 3 年之前
父节点
当前提交
488982bb1f
共有 2 个文件被更改,包括 3 次插入2 次删除
  1. 0 1
      app/Models/Post/View.php
  2. 3 1
      app/Models/User/Users.php

+ 0 - 1
app/Models/Post/View.php

@@ -62,7 +62,6 @@ class View extends Action
             }
             }
         }
         }
 
 
-        unset($userIds[0]); // гостя загружать не надо
         $this->c->users->loadByIds($userIds);
         $this->c->users->loadByIds($userIds);
 
 
         $offset    = ($arg->page - 1) * $this->c->user->disp_posts;
         $offset    = ($arg->page - 1) * $this->c->user->disp_posts;

+ 3 - 1
app/Models/User/Users.php

@@ -56,7 +56,9 @@ class Users extends Manager
         $data   = [];
         $data   = [];
 
 
         foreach ($ids as $id) {
         foreach ($ids as $id) {
-            if ($this->isset($id)) {
+            if (0 === $id) { // это гость, его грузим через guest()
+                continue;
+            } elseif ($this->isset($id)) {
                 $result[$id] = $this->get($id);
                 $result[$id] = $this->get($id);
             } else {
             } else {
                 $result[$id] = null;
                 $result[$id] = null;