Do not let caches keep queued or hidden images.
This commit is contained in:
@@ -84,6 +84,13 @@ class FeedAndImageTest extends PageTestCase {
|
||||
$this->assertSame(200, $this->get('/display?id=9&queue=1')['status']);
|
||||
}
|
||||
|
||||
public function testRestrictedImagesAreNotCached(): void {
|
||||
$this->assertNull($this->header($this->get('/display?id=2'), 'Cache-Control'));
|
||||
$this->loginAs();
|
||||
$this->assertSame('private, no-store', $this->header($this->get('/display?id=3'), 'Cache-Control'));
|
||||
$this->assertSame('private, no-store', $this->header($this->get('/display?id=9&queue=1'), 'Cache-Control'));
|
||||
}
|
||||
|
||||
public function testThePendingUploadIsShownToItsSession(): void {
|
||||
$name = bin2hex(random_bytes(16));
|
||||
mkdir(self::$state . '/tmp/uploads', 0700);
|
||||
|
||||
@@ -30,9 +30,10 @@ class SiteData {
|
||||
$dates = array_column(self::$tables['xxx'], 'date');
|
||||
return array(array('MAX(`date`)' => $dates ? max($dates) : NULL));
|
||||
});
|
||||
FakeDb::on("/^SELECT img, mime FROM $stories\\b/i", function ($sql, $params) {
|
||||
FakeDb::on("/^SELECT img, mime(, hidden)? FROM $stories\\b/i", function ($sql, $params) {
|
||||
$rows = self::filterStories($sql, $params);
|
||||
return array_map(function ($row) { return array('img' => $row['img'], 'mime' => $row['mime']); }, array_slice($rows, 0, 1));
|
||||
$columns = str_starts_with($sql, 'SELECT img, mime, hidden') ? array('img', 'mime', 'hidden') : array('img', 'mime');
|
||||
return array_map(function ($row) use ($columns) { return array_intersect_key($row, array_flip($columns)); }, array_slice($rows, 0, 1));
|
||||
});
|
||||
FakeDb::on("/^INSERT INTO $stories SET /", array(self::class, 'insertStory'));
|
||||
FakeDb::on("/^UPDATE $stories SET /", array(self::class, 'updateStory'));
|
||||
|
||||
Reference in New Issue
Block a user