Skip to content

Commit 748d489

Browse files
Merge pull request #18719 from kamil-tekiela/deletebookmark52
Fix bookmark delete
2 parents 6f1a3f4 + 1c6c661 commit 748d489

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

libraries/classes/Bookmark.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,12 @@ public static function get(
305305

306306
$query = 'SELECT * FROM ' . Util::backquote($bookmarkFeature->database)
307307
. '.' . Util::backquote($bookmarkFeature->bookmark)
308-
. " WHERE dbase = '" . $dbi->escapeString($db) . "'";
308+
. ' WHERE ' . Util::backquote($id_field)
309+
. " = '" . $dbi->escapeString((string) $id) . "'";
310+
if ($db !== '') {
311+
$query .= " AND dbase = '" . $dbi->escapeString($db) . "'";
312+
}
313+
309314
if (! $action_bookmark_all) {
310315
$query .= " AND (user = '"
311316
. $dbi->escapeString($user) . "'";
@@ -316,8 +321,7 @@ public static function get(
316321
$query .= ')';
317322
}
318323

319-
$query .= ' AND ' . Util::backquote($id_field)
320-
. " = '" . $dbi->escapeString((string) $id) . "' LIMIT 1";
324+
$query .= ' LIMIT 1';
321325

322326
$result = $dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, DatabaseInterface::CONNECT_CONTROL);
323327
if (! empty($result)) {

test/classes/Stubs/DbiDummy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,8 +2495,8 @@ private function init(): void
24952495
'result' => [],
24962496
],
24972497
[
2498-
'query' => 'SELECT * FROM `information_schema`.`bookmark` WHERE dbase = \'my_db\''
2499-
. ' AND (user = \'user\') AND `label` = \'test_tbl\' LIMIT 1',
2498+
'query' => 'SELECT * FROM `information_schema`.`bookmark` WHERE `label` = \'test_tbl\''
2499+
. ' AND dbase = \'my_db\' AND (user = \'user\') LIMIT 1',
25002500
'result' => [],
25012501
],
25022502
[

0 commit comments

Comments
 (0)