Skip to content

Commit cc3aa58

Browse files
committed
Prevent SQL errors when given empty arrays
1 parent 2a18506 commit cc3aa58

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Snippets/Snippets.API.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ public static function load_by_id($id, $user_id) {
205205

206206
if (is_array($id)) {
207207
$ids = array_filter($id, "is_int");
208+
209+
if (count($ids) < 1) {
210+
return array();
211+
}
212+
208213
$ids = implode(",", $ids);
209214

210215
$query = "SELECT * FROM {$snippet_table} WHERE id IN ({$ids}) AND user_id=".db_param();
@@ -269,6 +274,11 @@ public static function delete_by_id($id, $user_id) {
269274

270275
if (is_array($id)) {
271276
$ids = array_filter($id, "is_int");
277+
278+
if (count($ids) < 1) {
279+
return;
280+
}
281+
272282
$ids = implode(",", $ids);
273283

274284
$query = "DELETE FROM {$snippet_table} WHERE id IN ({$ids}) AND user_id=".db_param();

0 commit comments

Comments
 (0)