Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
5.0.15
-
None
Description
Since the RequestPageCache does not canonicalize the page name, there is a possibility that same page will be put into page cache twice, one time with canonical name and second time with non-canonical.
For example, I have a "Index" page in the orders package. When I open the "/app/orders" page, the Page instance is put into the RequestPageCache under the "orders" key. So when I get the Page from the cache by requestPageCache.get(resources.getPageName()), I get different Page instance (since resources.getPageName() returns canonicalized page name, which is "/app/orders/index").
This could lead to loss of activation parameter. Example:
Index.java:
...
@Property(write = false)
@PageActivationContext(activate = false)
private Integer orderId;
...
Index.tml:
...
<t:pagelink t:page="orders/index">Broken link</t:pagelink>
<t:pagelink t:page="orders">Correct link<t:pagelink>
...
If you open page /app/orders/123, the first link will be just "/app/orders" and second will be "/orders/123" (correct one).
The following snippet shows how this could be fixed now (the idea is to canonicalize page name before retrieving it from the cache):
public static RequestPageCache decorateRequestPageCache(
Class<RequestPageCache> serviceInterface, final RequestPageCache delegate,
String serviceId, final ComponentClassResolver resolver) {
return new RequestPageCache() {
public Page get(String logicalPageName)
};
}