Bug with ESI block
-
Hi,
I’m getting an intermittent issue with an ESI block that I’ve implemented on my staging site where instead of inserting the defined HTML tag, Litespeed instead inserts the whole page HTML again which is obviously causing the page to break apart completely. The issue is only resolved by Purging my LS cache.
This is my ESI block defined in my filters.php file:
function esi_postcode_form_block_esi_load($params) { #do_action( 'litespeed_control_set_ttl', 300 ); do_action( 'litespeed_control_set_nocache' ); echo sprintf('<input id="%s" type="text" class="%s %s postcode" data-search_postcode="%s" disabled />', $params['id'], $params['classes'], $params['type']==='size'?'tyre-size':'reg', WC()->session->get('search_postcode')); } add_action( 'litespeed_esi_load-esi_postcode_form_block', '\App\esi_postcode_form_block_esi_load' );
As you can see, I’m just setting it to not be cached.
Then in my shortcode I’m inserting this ESI like this:
if(is_plugin_active('litespeed-cache/litespeed-cache.php')){ $size_postcode_field = apply_filters('litespeed_esi_url', 'esi_postcode_form_block', 'Postcode form block', ['id' => sprintf('sc-fbf-reg-tyre-search--%s-postcode_%s', 'size', $id), 'type' => 'size', 'classes' => 'sc-fbf-reg-tyre-search__form-field']); }else{ ... } $html = <<<HTML <div class="fbf-form-group sc-fbf-reg-tyre-search__form--row"> {$size_postcode_field} </div> HTML; return $html;
When it goes wrong the page looks like this:
And looking at the Inspector in Firefox developer console, the HTML looks like this:
As you can see above, where the
Postcode form block
begins, instead of just inserting the HTML for the input, it’s inserting the full HTML of the page – again.Could someone have a look at this for me please as obviously I can’t put this live with this issue present.
Many thanks
Kevin
The page I need help with: [log in to see the link]
- The topic ‘Bug with ESI block’ is closed to new replies.