Simplify Search\Delete
This commit is contained in:
parent
8ade529ff8
commit
a2410a371a
1 changed files with 19 additions and 15 deletions
|
@ -31,9 +31,9 @@ class Delete extends Method
|
||||||
}
|
}
|
||||||
|
|
||||||
$uids = [];
|
$uids = [];
|
||||||
$forums = [];
|
$fids = [];
|
||||||
$topics = [];
|
$tids = [];
|
||||||
$posts = [];
|
$pids = [];
|
||||||
$isUser = 0;
|
$isUser = 0;
|
||||||
$isForum = 0;
|
$isForum = 0;
|
||||||
$isTopic = 0;
|
$isTopic = 0;
|
||||||
|
@ -55,15 +55,15 @@ class Delete extends Method
|
||||||
throw new RuntimeException('Forum unavailable');
|
throw new RuntimeException('Forum unavailable');
|
||||||
}
|
}
|
||||||
|
|
||||||
$forums[$arg->id] = $arg;
|
$fids[$arg->id] = $arg->id;
|
||||||
$isForum = 1;
|
$isForum = 1;
|
||||||
} elseif ($arg instanceof Topic) {
|
} elseif ($arg instanceof Topic) {
|
||||||
if (! $arg->parent instanceof Forum) {
|
if (! $arg->parent instanceof Forum) {
|
||||||
throw new RuntimeException('Parent unavailable');
|
throw new RuntimeException('Parent unavailable');
|
||||||
}
|
}
|
||||||
|
|
||||||
$topics[$arg->id] = $arg;
|
$tids[$arg->id] = $arg->id;
|
||||||
$isTopic = 1;
|
$isTopic = 1;
|
||||||
} elseif ($arg instanceof Post) {
|
} elseif ($arg instanceof Post) {
|
||||||
if (
|
if (
|
||||||
! $arg->parent instanceof Topic
|
! $arg->parent instanceof Topic
|
||||||
|
@ -72,8 +72,8 @@ class Delete extends Method
|
||||||
throw new RuntimeException('Parents unavailable');
|
throw new RuntimeException('Parents unavailable');
|
||||||
}
|
}
|
||||||
|
|
||||||
$posts[$arg->id] = $arg;
|
$pids[$arg->id] = $arg->id;
|
||||||
$isPost = 1;
|
$isPost = 1;
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidArgumentException('Expected User(s), Forum(s), Topic(s) or Post(s)');
|
throw new InvalidArgumentException('Expected User(s), Forum(s), Topic(s) or Post(s)');
|
||||||
}
|
}
|
||||||
|
@ -108,9 +108,9 @@ class Delete extends Method
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($forums) {
|
if ($fids) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':forums' => \array_keys($forums),
|
':forums' => $fids,
|
||||||
];
|
];
|
||||||
|
|
||||||
switch ($this->c->DB->getType()) {
|
switch ($this->c->DB->getType()) {
|
||||||
|
@ -134,9 +134,9 @@ class Delete extends Method
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($topics) {
|
if ($tids) {
|
||||||
$vars = [
|
$vars = [
|
||||||
':topics' => \array_keys($topics),
|
':topics' => $tids,
|
||||||
];
|
];
|
||||||
|
|
||||||
switch ($this->c->DB->getType()) {
|
switch ($this->c->DB->getType()) {
|
||||||
|
@ -159,9 +159,13 @@ class Delete extends Method
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($posts) {
|
if ($pids) {
|
||||||
|
if (\count($pids) > 1) {
|
||||||
|
\sort($pids, \SORT_NUMERIC);
|
||||||
|
}
|
||||||
|
|
||||||
$vars = [
|
$vars = [
|
||||||
':posts' => \array_keys($posts),
|
':posts' => $pids,
|
||||||
];
|
];
|
||||||
$query = 'DELETE
|
$query = 'DELETE
|
||||||
FROM ::search_matches
|
FROM ::search_matches
|
||||||
|
|
Loading…
Reference in a new issue