Uploaded image for project: 'eZ Platform Enterprise Edition'
  1. eZ Platform Enterprise Edition
  2. EZEE-2955

Page Builder not working with Fastly CDN on platform.sh



    • Type: Bug
    • Status: QA Done
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: 2.5.7
    • Component/s: Page Builder
    • Labels:
    • Environment:

      eZ Platform EE with Fastly


      Using ESI in the pagebuilder layouts template sometime breaks. You'll get message 'Previewed page is not based on a content item. Page Builder is working with limited set of features.' and the page is broken when for instance preview/editing (/admin/page/preview/257) the landing page.

      I am not able to reproduce the actual problem on a vanilla ezplatform-ee (where I just add a render_esi() in layouts template. I have tested that both with varnish (locally) and with Fastly on Platform.sh. However, I have one other site on platform.sh with Fastly in front where the problem is 100% reproducible.

      Fastly seems to behave slightly different on the site which have the problem. I don't know why that is, but I have now a understanding of what's going on.

      Cause of problem
      The page will contain such js:

              window.eZ.addConfig('pageBuilder.callbacks', {});
              window.eZ.addConfig('pageBuilder.timeline', {
                  events: [],
              window.eZ.addConfig('pageBuilder.data', {
                  contentId: 255,
                  locationId: 257,
                  versionNo: 2,
                  languageCode: 'eng-GB',
                  siteaccess: 'site',
                  publishedVersionNo: 2,
                  referrerVersionNo: 2
              window.eZ.addConfig('pageBuilder.config', {
                  fieldValue: {"layout":"vl_test_layout","zones":[{"id":"21","name":"First zone","blocks":[]}]},
                  blocksConfig: JSON.parse("[{\"type\":\"form\",\"name\":\"Form\",\"category\":\"default\"(...[REMOVED_A_LOT_OF_STUFF]....) "template\":\"\\n<!-- START app\\\/Resources\\\/views\\\/themes\\\/tastefulplanet\\\/layouts\\\/vl_test_layout.html.twig (@admin\\\/layouts\\\/vl_test_layout.html.twig) -->\\n<div class=\\\"container\\\">\\n    VL test layout2<br\\\/>\\n            <esi:include src=\\\"\\\/_fragment?_hash=HlJqOE5pvdA(....)

      The issue here is the esi :

      <esi:include src=\\\"\\\/_fragment?_hash=HlJqOE5pvdA(....)

      Since the src starts with \\\", the syntax is invalid, varnish will discard the whole thing, fastly will too on one of my installations, but not on the other. And when fastly instead tries to load that esi, then everything breaks. The ESI tag will be replaced with a html fragment and that renders this JSON invalid....

      So I think the fix is to make sure that ESIs are removed when generating this blocksConfig JSON.

      In order to inspect the output of the pagelayout controller on a site with varnish:
      1st, Login using a browser in order to get a session. Use browser debugger to get session cookies
      Next, get user context hash:

      curl -v --header "Surrogate-Capability: abc=ESI/1.0" --cookie "eZSESSID[....]=[...];eZSESSID[...]=[...]" --header "accept: application/vnd.fos.user-context-hash" --header "x-fos-original-url: /" http://localhost:8080/_fos_user_context_hash

      Get the pagebuilder page:

      curl -v --header "Surrogate-Capability: abc=ESI/1.0" --cookie "eZSESSID[....]=[...];eZSESSID[...]=[...]" --header "x-user-hash: [..._HASH_RECEIVED_IN_PREV_CURL...]" 'http://localhost:8080/admin/page/preview/257/eng-GB




            vidar.langseid@ez.no Vidar Langseid
            0 Vote for this issue
            4 Start watching this issue