Updating the Aurora starter store for key splitting
The key splitting feature might potentially expose some JavaScript coding issues in the store JSP pages. JSP pages that passed or initialized JSTL variables of object's primary keys (or identifiers) into JavaScript variables as integers might be subject to unexpected behavior in the storefront.
<script>
var catentryId = <c:out value="${WCParam.productId}"/>;
</script>
Where the issue with the above code snippet is that the JavaScript variable being initialized is
treated as an integer. In JavaScript, the highest integer value is 9 007 199 254 740
992
. When key splitting, the range becomes much higher than that and thus causes problems
in the JavaScript. The symptoms are that higher numbers are likely ignored and the threshold cap
causes unexpected behavior in the storefront. For example, adding an item to the cart might add an
unintended product to the cart instead.
Procedure
- Using a string in JavaScript solves this issue. Therefore,
the preceding code sample above updates to:
Where encapsulating the value in quotes (") ensures that the value is a string.<script> var catentryId = "<c:out value="${WCParam.productId}"/>"; </script>
- If you are using key splitting and the Aurora starter store, you must update the JavaScript accordingly.
The following files must be updated: