Closed (fixed)
Project:
Advanced Varnish
Version:
4.0.1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
14 Apr 2021 at 17:52 UTC
Updated:
5 May 2021 at 06:04 UTC
Jump to comment: Most recent
On ESI Block requests, there is an error in ESIBlockController.php
The two conditions for select cache context are never true because $type is a string but RequestHandler::CACHE_PER_ROLE and RequestHandler::CACHE_PER_USER are integer.
// Depends on type set the cache context.
$type = $settings['cache']['cachemode'];
if ($type === RequestHandler::CACHE_PER_ROLE) { // FALSE
$response->getCacheableMetadata()->addCacheContexts(['user.roles']);
}
elseif ($type === RequestHandler::CACHE_PER_USER) { // FALSE
$response->getCacheableMetadata()->addCacheContexts(['user']);
}
You should cast $type to int
// Depends on type set the cache context.
$type = $settings['cache']['cachemode'];
if ((int)$type === RequestHandler::CACHE_PER_ROLE) {
$response->getCacheableMetadata()->addCacheContexts(['user.roles']);
}
elseif ((int)$type === RequestHandler::CACHE_PER_USER) {
$response->getCacheableMetadata()->addCacheContexts(['user']);
}
| Comment | File | Size | Author |
|---|---|---|---|
| failEsiBlockCacheContext.png | 51.98 KB | mounir_abid |
Comments
Comment #2
mounir_abid commentedComment #3
mounir_abid commentedComment #4
shumer commentedComment #7
shumer commented