diff --git a/tests/php/test_log_delete_ids_failure.php b/tests/php/test_log_delete_ids_failure.php new file mode 100644 index 0000000000..99ff963684 --- /dev/null +++ b/tests/php/test_log_delete_ids_failure.php @@ -0,0 +1,22 @@ +"ERR", 0=>"INF", 1=>"DBG"); } + function Error($m) {} function Warning($m) {} function Debug($m) {}'); +$_REQUEST = array('task' => 'delete', 'ids' => array('1', '2')); +require($root.'/web/ajax/log.php'); +if ($GLOBALS['err'] !== null && !$GLOBALS['ok']) { + echo "[PASS] failed delete by ids is reported: {$GLOBALS['err']}\n"; + exit(0); +} +echo "[FAIL] failed delete by ids was answered as success\n"; +exit(1); diff --git a/web/ajax/log.php b/web/ajax/log.php index bf82d6f972..0a881a547d 100644 --- a/web/ajax/log.php +++ b/web/ajax/log.php @@ -30,7 +30,9 @@ if (!isset($_REQUEST['task'])) { if (!empty($_REQUEST['ids'])) { $ids = array_map('intval', (array)$_REQUEST['ids']); $placeholders = implode(',', array_fill(0, count($ids), '?')); - dbQuery('DELETE FROM Logs WHERE Id IN (' . $placeholders . ')', $ids); + if (dbQuery('DELETE FROM Logs WHERE Id IN (' . $placeholders . ')', $ids) === null) { + $message = 'Failed to delete the selected log entries'; + } } else if (!empty($_REQUEST['all'])) { // Deleting by id needs one request per 100 rows, which is unusable at the // hundreds of thousands of rows people accumulate, and the table's