Fix MariaDB LIMIT/OFFSET bound-parameter error in corpus API

MariaDB rejects ? placeholders for LIMIT/OFFSET when emulate_prepares=false.
Interpolate $limit and $offset as ints directly into SQL strings in both
corpus-documents.php and corpus-search.php BM25 paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-15 12:31:20 +02:00
parent 640778454f
commit d5e61d656a
2 changed files with 6 additions and 11 deletions
+2 -4
View File
@@ -59,10 +59,9 @@ try {
AND d.source_url NOT LIKE ?
$catClause
ORDER BY score DESC
LIMIT ?";
LIMIT $limit";
$params = [$query, 1, $query, $excludeLike];
if ($category !== null) $params[] = $category;
$params[] = $limit;
$stmt = $ragDb->prepare($sql);
$stmt->execute($params);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -80,11 +79,10 @@ try {
AND d.source_url NOT LIKE ?
$catClause
ORDER BY (d.title LIKE ?) DESC
LIMIT ?";
LIMIT $limit";
$params = [1, $like, $like, $excludeLike];
if ($category !== null) $params[] = $category;
$params[] = $like;
$params[] = $limit;
$stmt = $ragDb->prepare($sql);
$stmt->execute($params);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);