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
- This topic was modified 1 year, 2 months ago by the_lar.
The page I need help with: [log in to see the link]
-
Can you try latest v5.7-a17? There is a bugfix for ESI block which may show whole page html
@hailite could you tell me how to require this package via composer please?
you can get the dev version by , go to toolbox -> beta test -> click “dev” and upgrade
@qtwrk – I installed v5.7-a17 yesterday on the staging site – https://staging.4x4tyres.co.uk and it ran ok, but this morning when I’ve looked at it it’s broken again, so sorry to report but the bugfix does not seem to be working.
In order to try and help you resolve this, I buried deep into the repeated HTML and where the ESI block should be in the repeated page I found this:
As you can see, where the field should be it says
[an error occured while processing this directive]
– I’ve checked for PHP errors though and I’m not seeing anything.Appreciate you looking into this for me.
- This reply was modified 1 year, 2 months ago by the_lar.
By the way, I haven’t cleared the cache so that you can see the issue, it’s present on https://staging.4x4tyres.co.uk/ and https://staging.4x4tyres.co.uk/tyre-search/ but it isn’t present on https://staging.4x4tyres.co.uk/wheel-search/ or https://staging.4x4tyres.co.uk/accessory-search/ which both use a similar ESI block
@hailite – please see above, this issue is still present with v5.7-a17, is there anything I can do in terms of capturing logs that will help you resolve this?
Change https://github.com/litespeedtech/lscache_wp/blob/master/src/esi.cls.php#L478
<esi
to<xesi
to break ESI parser, then see what the output is.Also, you can check debug log, what did it tell in the ESI include part?
@hailite – that code is on line 501 in the dev version of the plugin, is that correct?
Just to note, in order to get the code change to show up, I had to purge the litespeed cache, so obviously that fixes the issue anyway.
So now the html is showing up as:
I’ve looked in the log and all I can see is POST request to `/wp/wp-admin/admin-ajax.php:
09/14/23 15:39:49.133 [213.246.156.82:56053 1 ohB] ?? ------POST HTTP/1.1 (HTTPS) /wp/wp-admin/admin-ajax.php
09/14/23 15:39:49.133 [213.246.156.82:56053 1 ohB] Query String:
09/14/23 15:39:49.133 [213.246.156.82:56053 1 ohB] HTTP_REFERER: https://staging.4x4tyres.co.uk/tyre-search/
09/14/23 15:39:49.133 [213.246.156.82:56053 1 ohB] User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/116.0
09/14/23 15:39:49.133 [213.246.156.82:56053 1 ohB] Accept: application/json, text/javascript, */*; q=0.01
09/14/23 15:39:49.133 [213.246.156.82:56053 1 ohB] Accept Encoding: gzip, deflate, br
09/14/23 15:39:49.133 [213.246.156.82:56053 1 ohB] Cookie _lscache_vary: guest_mode:1
09/14/23 15:39:49.133 [213.246.156.82:56053 1 ohB] X-LSCACHE: true
09/14/23 15:39:49.134 [213.246.156.82:56053 1 ohB] [ESI] Overwrite wp_create_nonce()
09/14/23 15:39:49.137 [213.246.156.82:56053 1 6rk] ?? ------POST HTTP/1.1 (HTTPS) /wp/wp-admin/admin-ajax.php
09/14/23 15:39:49.137 [213.246.156.82:56053 1 6rk] Query String:
09/14/23 15:39:49.137 [213.246.156.82:56053 1 6rk] HTTP_REFERER: https://staging.4x4tyres.co.uk/tyre-search/
09/14/23 15:39:49.137 [213.246.156.82:56053 1 6rk] User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/116.0
09/14/23 15:39:49.137 [213.246.156.82:56053 1 6rk] Accept: application/json, text/javascript, */*; q=0.01
09/14/23 15:39:49.137 [213.246.156.82:56053 1 6rk] Accept Encoding: gzip, deflate, br
09/14/23 15:39:49.137 [213.246.156.82:56053 1 6rk] Cookie _lscache_vary: guest_mode:1
09/14/23 15:39:49.137 [213.246.156.82:56053 1 6rk] X-LSCACHE: true
09/14/23 15:39:49.138 [213.246.156.82:56053 1 6rk] [ESI] Overwrite wp_create_nonce()
09/14/23 15:39:49.278 [213.246.156.82:56053 1 6rk] ?? No cache due to Admin page
09/14/23 15:39:49.278 [213.246.156.82:56053 1 ohB] ?? No cache due to Admin page
09/14/23 15:39:49.318 [213.246.156.82:56053 1 6rk] [Media] init
09/14/23 15:39:49.318 [213.246.156.82:56053 1 6rk] [LQIP] init
09/14/23 15:39:49.318 [213.246.156.82:56053 1 6rk] [CDN] init
09/14/23 15:39:49.318 [213.246.156.82:56053 1 6rk] ? Init
09/14/23 15:39:49.319 [213.246.156.82:56053 1 6rk] [Router] LSCWP_CTRL bypassed empty
09/14/23 15:39:49.320 [213.246.156.82:56053 1 ohB] [Media] init
09/14/23 15:39:49.321 [213.246.156.82:56053 1 ohB] [LQIP] init
09/14/23 15:39:49.321 [213.246.156.82:56053 1 ohB] [CDN] init
09/14/23 15:39:49.321 [213.246.156.82:56053 1 ohB] ? Init
09/14/23 15:39:49.321 [213.246.156.82:56053 1 ohB] [Router] LSCWP_CTRL bypassed empty
09/14/23 15:39:49.427 [213.246.156.82:56053 1 6rk] [Core] CHK html bypass: miss footer const
09/14/23 15:39:49.427 [213.246.156.82:56053 1 6rk] [Ctrl] not cacheable before ctrl finalize
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] [Router] get_role:
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] [Vary] role id: failed, guest
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] [Router] get_role:
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] [Vary] no custimzed vary
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] [Ctrl] ? forced no cache [reason] DONOTCACHEPAGE const
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] ?? X-LiteSpeed-Cache-Control: no-cache
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] [Router] get_role:
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] [Vary] role id: failed, guest
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] [Router] get_role:
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] [Core] CHK html bypass: miss footer const
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] [Core] run hook litespeed_buffer_finalize
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] [Core] Silence Comment due to REST/AJAX
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] Response headers --- array (
0 => 'Access-Control-Allow-Origin: https://staging.4x4tyres.co.uk',
1 => 'Access-Control-Allow-Credentials: true',
2 => 'Content-Type: text/html; charset=UTF-8',
3 => 'X-Robots-Tag: noindex',
4 => 'X-Content-Type-Options: nosniff',
5 => 'Expires: Wed, 11 Jan 1984 05:00:00 GMT',
6 => 'Cache-Control: no-cache, must-revalidate, max-age=0',
7 => 'Referrer-Policy: strict-origin-when-cross-origin',
8 => 'X-Frame-Options: SAMEORIGIN',
9 => 'X-LiteSpeed-Cache-Control: no-cache',
)
09/14/23 15:39:49.428 [213.246.156.82:56053 1 6rk] End response
--------------------------------------------------Duration: 292.80 ms------------------------------Not sure if that’s any use? I can set you up with Admin access as this is on our staging site if that would help?
Without the code change, and after purging the cache, when I look at the logs, the bit relating to the postcode ESI block is:
09/14/23 16:03:42.624 [213.246.156.82:56476 1 ovo] ?? ------GET HTTP/1.1 (HTTPS) / 09/14/23 16:03:42.624 [213.246.156.82:56476 1 ovo] Query String: lsesi=esi_postcode_form_block&_control=private%2Cno-vary&esi=eyJpZCI6InNjLWZiZi1yZWctdHlyZS1zZWFyY2gtLXNpemUtcG9zdGNvZGVfIiwidHlwZSI6InNpemUiLCJjbGFzc2VzIjoic2MtZmJmLXJlZy10eXJlLXNlYXJjaF9fZm9ybS1maWVsZCJ9&_hash=4a42890678f96addcbbb029192abaeca 09/14/23 16:03:42.624 [213.246.156.82:56476 1 ovo] HTTP_REFERER: https://staging.4x4tyres.co.uk/ 09/14/23 16:03:42.624 [213.246.156.82:56476 1 ovo] User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/116.0 09/14/23 16:03:42.624 [213.246.156.82:56476 1 ovo] Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 09/14/23 16:03:42.624 [213.246.156.82:56476 1 ovo] Accept Encoding: gzip, deflate, br 09/14/23 16:03:42.624 [213.246.156.82:56476 1 ovo] Cookie _lscache_vary: guest_mode:1 09/14/23 16:03:42.624 [213.246.156.82:56476 1 ovo] X-LSCACHE: true 09/14/23 16:03:42.624 [213.246.156.82:56476 1 ovo] ESI_CONTENT_TYPE: text/html; charset=UTF-8 09/14/23 16:03:42.625 [213.246.156.82:56476 1 ovo] [ESI] Overwrite wp_create_nonce() 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] ? not ESI req 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] ESI_REFERER: / 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] stats_nonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] subscribe_nonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] 4x4_nonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] wp_rest 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] cmreg_registration_nonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] role_nonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] wdap-call-nonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] seopress_cookies_user_consent_nonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] swpmtxnonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] wdt.* 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] _vcnonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] data-vc-public-nonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] rating_nonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] timeline_nonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] blog_feed_nonce 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] wsf_post 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] edd\-.* 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] edd_.* 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [ESI] Appended nonce action to nonce list [action] wpmenucart 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [Router] get_role: 09/14/23 16:03:42.718 [213.246.156.82:56476 1 ovo] [Media] init 09/14/23 16:03:42.719 [213.246.156.82:56476 1 ovo] [LQIP] init 09/14/23 16:03:42.719 [213.246.156.82:56476 1 ovo] [Optm] init 09/14/23 16:03:42.719 [213.246.156.82:56476 1 ovo] [CDN] init 09/14/23 16:03:42.719 [213.246.156.82:56476 1 ovo] ? Init 09/14/23 16:03:42.719 [213.246.156.82:56476 1 ovo] [Router] LSCWP_CTRL bypassed empty 09/14/23 16:03:42.719 [213.246.156.82:56476 1 ovo] [GUI] init 09/14/23 16:03:42.777 [213.246.156.82:56476 1 ovo] ?? [Tag] Add --- HTTP.200 09/14/23 16:03:42.778 [213.246.156.82:56476 1 ovo] [Ctrl] X Cache_control init on 09/14/23 16:03:42.795 [213.246.156.82:56476 1 ovo] ? calling ESI template 09/14/23 16:03:42.804 [213.246.156.82:56476 1 ovo] [ESI] param --- array ( 'action' => '4x4_nonce', '_ls_silence' => true, ) 09/14/23 16:03:42.804 [213.246.156.82:56476 1 ovo] [ESI] md5_string=nonceeyJhY3Rpb24iOiI0eDRfbm9uY2UiLCJfbHNfc2lsZW5jZSI6dHJ1ZX0= 09/14/23 16:03:42.804 [213.246.156.82:56476 1 ovo] ? ?? [BLock_ID] nonce [wrapper] wp_create_nonce 4x4_nonce [Control] 09/14/23 16:03:42.804 [213.246.156.82:56476 1 ovo] ? <esi:include src='/?lsesi=nonce&esi=eyJhY3Rpb24iOiI0eDRfbm9uY2UiLCJfbHNfc2lsZW5jZSI6dHJ1ZX0%3D&_hash=6b53e5ecbf4ec5dfc47674ada75c8e25' as-var='1' /> 09/14/23 16:03:42.804 [213.246.156.82:56476 1 ovo] ? Preserved to 399f9a3ac9bde5326847e29bb81a5c57 09/14/23 16:03:42.840 [213.246.156.82:56476 1 ovo] [ESI] md5_string=esi_postcode_form_blockprivate,no-varyeyJpZCI6InNjLWZiZi1yZWctdHlyZS1zZWFyY2gtLXNpemUtcG9zdGNvZGVfIiwidHlwZSI6InNpemUiLCJjbGFzc2VzIjoic2MtZmJmLXJlZy10eXJlLXNlYXJjaF9fZm9ybS1maWVsZCJ9 09/14/23 16:03:42.840 [213.246.156.82:56476 1 ovo] [ESI] parms --- '{"id":"sc-fbf-reg-tyre-search--size-postcode_","type":"size","classes":"sc-fbf-reg-tyre-search__form-field"}' 09/14/23 16:03:42.840 [213.246.156.82:56476 1 ovo] [ESI] ? [ID] esi_postcode_form_block 09/14/23 16:03:42.840 [213.246.156.82:56476 1 ovo] ?? [Tag] Add --- ESI 09/14/23 16:03:42.840 [213.246.156.82:56476 1 ovo] ?? [Tag] Add --- ESI.esi_postcode_form_block 09/14/23 16:03:42.840 [213.246.156.82:56476 1 ovo] [Ctrl] X Cache_control -> private 09/14/23 16:03:42.840 [213.246.156.82:56476 1 ovo] [Ctrl] X Cache_control -> no-vary => LiteSpeed\Control::set_no_vary()@177 => LiteSpeed\ESI->load_esi_block()@652 => /home/staging4x4tyresc/public_html/app/themes/4x4tyres/vendor/illuminate/view/Engines/PhpEngine.php@4 => Illuminate\View\Engines\PhpEngine->evaluatePath(/home/staging4x4tyresc/public_html/app/plugins/litespeed-cache/tpl/esi.tpl.php,ARRAY)@43 09/14/23 16:03:42.840 [213.246.156.82:56476 1 ovo] [Ctrl] X Cache_control -> no Cache => LiteSpeed\Control::set_nocache()@372 => WP_Hook->apply_filters(,ARRAY)@310 => WP_Hook->do_action(ARRAY)@334 => /home/staging4x4tyresc/public_html/app/themes/4x4tyres/app/filters.php@517 => /home/staging4x4tyresc/public_html/wp/wp-includes/class-wp-hook.php@3493 => WP_Hook->apply_filters(,ARRAY)@310 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Core] CHK html bypass: miss footer const 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Ctrl] not cacheable before ctrl finalize 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Router] get_role: 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Vary] role id: failed, guest 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Router] get_role: 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Router] get_role: 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Vary] no custimzed vary 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] ?? X-LiteSpeed-Cache-Control: no-cache,esi=on 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Router] get_role: 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Vary] role id: failed, guest 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Router] get_role: 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Router] get_role: 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Core] CHK html bypass: miss footer const 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Core] run hook litespeed_buffer_finalize 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Media] bypass: Not frontend HTML type 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] GUI bypassed by no counter 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Optm] bypass: Not frontend HTML type 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [ESI] replacing preserved blocks --- 399f9a3ac9bde5326847e29bb81a5c57 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Core] ESI Start ?? 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] <input id="sc-fbf-reg-tyre-search--size-postcode_" type="text" class="sc-fbf-reg-tyre-search__form-field tyre-size postcode" data-search_postcode="WR111HA" disabled /> <!-- Block uncached by LiteSpeed Cache 5.7-a17 on 2023-09-14 16:03:42 --> <!-- X-LiteSpeed-Cache-Control: no-cache,esi=on --> <!-- Full varies: guest_mode:1 --> <!-- Object Cache [total] 7790 [hit_incall] 7439 [hit] 0 [miss_incall] 38 [miss] 313 [set] 366 --> 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] [Core] ESI End ?? 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] <input id="sc-fbf-reg-tyre-search--size-postcode_" type="text" class="sc-fbf-reg-tyre-search__form-field tyre-size postcode" data-search_postcode="WR111HA" disabled /> <!-- Block uncached by LiteSpeed Cache 5.7-a17 on 2023-09-14 16:03:42 --> <!-- X-LiteSpeed-Cache-Control: no-cache,esi=on --> <!-- Full varies: guest_mode:1 --> <!-- Object Cache [total] 7790 [hit_incall] 7439 [hit] 0 [miss_incall] 38 [miss] 313 [set] 366 --> 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] Response headers --- array ( 0 => 'Content-Type: text/html; charset=UTF-8', 1 => 'Link: <https://staging.4x4tyres.co.uk/wp-json/>; rel="https://api.w.org/"', 2 => 'Link: <https://staging.4x4tyres.co.uk/wp-json/wp/v2/pages/25>; rel="alternate"; type="application/json"', 3 => 'Link: <https://staging.4x4tyres.co.uk/>; rel=shortlink', 4 => 'X-LiteSpeed-Tag: f41_HTTP.200,f41_ESI,f41_ESI.esi_postcode_form_block', 5 => 'X-LiteSpeed-Cache-Control: no-cache,esi=on', ) 09/14/23 16:03:42.841 [213.246.156.82:56476 1 ovo] End response --------------------------------------------------Duration: 218.13 ms------------------------------
Does that help?
Your 2nd log without the code change seems fine? It doesn’t have the whole HTML output but
<input
part only. I assume that is as expected?For your 1st log, what if you visit that link directly? Will it show the ESI content as expected?
@hailite yes the 2nd log above is for normal execution when the ESI block is working as expected.
The first log is when I changed the code from
<esi
to<xesi
in order to break it, so in that case when I purge Litespeed cache and visit the link directly, I don’t see the html input field, I just see this:And in the HTML:
<div class="fbf-form-group sc-fbf-reg-tyre-search__form--row"> <xesi:include src="/?lsesi=esi_postcode_form_block&_control=private%2Cno-vary&esi=eyJpZCI6InNjLWZiZi1yZWctdHlyZS1zZWFyY2gtLXNpemUtcG9zdGNvZGVfIiwidHlwZSI6InNpemUiLCJjbGFzc2VzIjoic2MtZmJmLXJlZy10eXJlLXNlYXJjaF9fZm9ybS1maWVsZCJ9&_hash=4a42890678f96addcbbb029192abaeca" cache-control="private,no-vary"> <label for="sc-fbf-reg-tyre-search--size-postcode_" class="control-label"> <span class="floating-label">Postcode</span> </label></xesi:include></div>
As I say, I’m happy to give you Admin access to our staging site if you want me to?
Thanks for helping!
In
<xesi:include src="/?lsesi=esi_postcode_form_block&_control=private%2Cno-vary&esi=eyJpZCI6InNjLWZiZi1yZWctdHlyZS1zZWFyY2gtLXNpemUtcG9zdGNvZGVfIiwidHlwZSI6InNpemUiLCJjbGFzc2VzIjoic2MtZmJmLXJlZy10eXJlLXNlYXJjaF9fZm9ybS1maWVsZCJ9&_hash=4a42890678f96addcbbb029192abaeca" cache-control="private,no-vary"> <label for="sc-fbf-reg-tyre-search--size-postcode_" class="control-label"> <span class="floating-label">Postcode</span> </label></xesi:include>
I think you can see something is wrong.
<esi:include />
is a self closed tag. How can it has alabel
content output inside?@hailite yeah I see what you’re saying, but I don’t know.
Here is my code in
filters.php
: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' );
So I’m only putting the
<input />
into the ESI.And when I output the ESI in my shortcode I am doing 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{ $size_postcode_field = sprintf('<input id="sc-fbf-reg-tyre-search--%s-postcode_%s" type="text" class="sc-fbf-reg-tyre-search__form-field %s postcode" data-search_postcode="%s" disabled />', 'size', $id, 'tyre-size', WC()->session->get('search_postcode')); } $html = <<<HTML <div class="fbf-form-group sc-fbf-reg-tyre-search__form--row"> {$size_postcode_field} <label for="sc-fbf-reg-tyre-search--size-postcode_{$id}" class="control-label"> <span class="floating-label">Postcode</span> </label> </div> HTML; return $html;
As you can see, I’m not adding the
<label>
into the ESI at all, so I don’t know why it’s getting included in the ‘broken’ xesi markup at all.- This reply was modified 1 year, 2 months ago by the_lar.
@hailite – note I’ve removed the ESI block for now on https://staging.4x4tyres.co.uk to test a different solution which doesn’t use ESI as need to go live with this on Monday – I can put it back though if you need me to?
If you can create a test server, please create a tix so we can debug on it. Thanks.
- The topic ‘Bug with ESI block’ is closed to new replies.