Leave the image data out of the story lists.

A page of 50 stories read 50 images from the database only to see which stories had one.
This commit is contained in:
tim
2026-09-26 15:27:51 +02:00
parent ed8918e7fd
commit c8030b759d
4 changed files with 41 additions and 12 deletions
+7 -1
View File
@@ -22,7 +22,13 @@ class SiteData {
self::$lastInsertId = 0;
$stories = '(xxx|queue)';
FakeDb::on("/^SELECT \\* FROM $stories\\b/", array(self::class, 'selectStories'));
FakeDb::on("/^SELECT id, title, author, email, date, story, hidden, mime, comments, editor, IF\\(LENGTH\\(img\\) > 0, 1, NULL\\) AS img FROM $stories\\b/",
function ($sql, $params) {
return array_map(function ($row) {
$row['img'] = strlen((string)$row['img']) > 0 ? 1 : NULL;
return $row;
}, self::selectStories($sql, $params));
});
FakeDb::on("/^SELECT COUNT\\(\\*\\) FROM $stories\\b/", function ($sql, $params) {
return array(array('COUNT(*)' => (string)count(self::filterStories($sql, $params))));
});