@@ -267,20 +267,19 @@ public static function getList(
267267 /**
268268 * Retrieve a specific bookmark
269269 *
270- * @param string $user Current user
271- * @param DatabaseName $db the current database name
272- * @param int|string $id an identifier of the bookmark to get
273- * @param string $idField which field to look up the identifier
274- * @param bool $actionBookmarkAll true: get all bookmarks regardless
275- * of the owning user
276- * @param bool $exactUserMatch whether to ignore bookmarks with no user
270+ * @param string $user Current user
271+ * @param DatabaseName|null $db the current database name
272+ * @param int|string $id an identifier of the bookmark to get
273+ * @param string $idField which field to look up the identifier
274+ * @param bool $actionBookmarkAll true: get all bookmarks regardless of the owning user
275+ * @param bool $exactUserMatch whether to ignore bookmarks with no user
277276 *
278277 * @return Bookmark|null the bookmark
279278 */
280279 public static function get (
281280 DatabaseInterface $ dbi ,
282281 string $ user ,
283- DatabaseName $ db ,
282+ DatabaseName | null $ db ,
284283 int |string $ id ,
285284 string $ idField = 'id ' ,
286285 bool $ actionBookmarkAll = false ,
@@ -298,7 +297,12 @@ public static function get(
298297
299298 $ query = 'SELECT * FROM ' . Util::backquote ($ bookmarkFeature ->database )
300299 . '. ' . Util::backquote ($ bookmarkFeature ->bookmark )
301- . ' WHERE dbase = ' . $ dbi ->quoteString ($ db ->getName ());
300+ . ' WHERE ' . Util::backquote ($ idField )
301+ . ' = ' . $ dbi ->quoteString ((string ) $ id );
302+ if ($ db !== null ) {
303+ $ query .= ' AND dbase = ' . $ dbi ->quoteString ($ db ->getName ());
304+ }
305+
302306 if (! $ actionBookmarkAll ) {
303307 $ query .= ' AND (user = ' . $ dbi ->quoteString ($ user );
304308 if (! $ exactUserMatch ) {
@@ -308,8 +312,7 @@ public static function get(
308312 $ query .= ') ' ;
309313 }
310314
311- $ query .= ' AND ' . Util::backquote ($ idField )
312- . ' = ' . $ dbi ->quoteString ((string ) $ id ) . ' LIMIT 1 ' ;
315+ $ query .= ' LIMIT 1 ' ;
313316
314317 $ result = $ dbi ->fetchSingleRow ($ query , DatabaseInterface::FETCH_ASSOC , Connection::TYPE_CONTROL );
315318 if ($ result !== null ) {
0 commit comments