Browse Source

Fix delete user with posts

Visman 1 year ago
parent
commit
c7980386c3
2 changed files with 14 additions and 11 deletions
  1. 6 6
      app/Models/Post/Delete.php
  2. 8 5
      app/Models/Topic/Delete.php

+ 6 - 6
app/Models/Post/Delete.php

@@ -136,17 +136,17 @@ class Delete extends Action
 
 
             $parents = $this->c->topics->loadByIds($tids, false);
             $parents = $this->c->topics->loadByIds($tids, false);
 
 
-            $query = 'UPDATE ::posts
-                SET editor_id=0
-                WHERE editor_id IN (?ai:users)';
-
-            $this->c->DB->exec($query, $vars);
-
             $query = 'DELETE
             $query = 'DELETE
                 FROM ::posts
                 FROM ::posts
                 WHERE poster_id IN (?ai:users)';
                 WHERE poster_id IN (?ai:users)';
 
 
             $this->c->DB->exec($query, $vars);
             $this->c->DB->exec($query, $vars);
+
+            $query = 'UPDATE ::posts
+                SET editor_id=0
+                WHERE editor_id IN (?ai:users)';
+
+            $this->c->DB->exec($query, $vars);
         }
         }
 
 
         if ($forums) {
         if ($forums) {

+ 8 - 5
app/Models/Topic/Delete.php

@@ -106,12 +106,15 @@ class Delete extends Action
                 FROM ::topics AS t
                 FROM ::topics AS t
                 WHERE t.poster_id IN (?ai:users)';
                 WHERE t.poster_id IN (?ai:users)';
 
 
-            $tids   = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
-            $topics = $this->manager->loadByIds($tids, false);
+            $tids = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
 
 
-            foreach ($topics as $topic) {
-                $parents[$topic->parent->id] = $topic->parent;
-            }
+#            $topics = $this->manager->loadByIds($tids, false);
+#
+#            foreach ($topics as $topic) {
+#                $parents[$topic->parent->id] = $topic->parent;
+#            }
+
+            $this->delete(...($this->manager->loadByIds($tids, false)));
         }
         }
 
 
         $this->c->posts->delete(...$args);
         $this->c->posts->delete(...$args);