Templates and templateparts empty

Fist of all thank you very much for all new improvements and features - you are doing such a fantastic job! The new themer now loads all the templates everytime without the whitescreen issue, that sometimes happend before.

There is just a little new issue:
I have a simular problem with the new template previews like @sunny Template previews don't show in Firefox but also in chrome (tested with the latest chrome and firefox developer browser).
Furthermore, on my side there is an empty template message on all templates (all of them are cwicly made templates with content):



I’m using the latest cwicly & WP version on php 8.0

Thanks for your help! :slight_smile:
Greetings
Marc

Hi @msteinlein,

Sorry to hear you’re experiencing trouble with this.

Rest assured, the error with the templates not displaying properly in Firefox will be addressed in the next update, so please bear with us.

As for your templates displaying empty on chrome, this is unusual as I cannot reproduce this issue on my end.

Could you possibly let me know what plugins you have actvivated on your installation?
Thank you in advance.

Hello @msteinlein,

Just checking this out.
Is this still happening on your side?

Thanks in advance.

@Louis, with the latest Cwicly version, this is happening for us on a site with WPML installed.

We have an almost identical site without WPML installed that seems to work fine, so that combined with the error itself will hopefully give you a starting point:

api-fetch.min.js?ver…4dabf8bf2c7adf21a:2 
 GET https://xyz.com/wp-json/cwicly/v1/render?_locale=user 500
j	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
h	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
(anonymous)	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
P	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
(anonymous)	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
a	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
(anonymous)	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
P.method.r	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
(anonymous)	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
(anonymous)	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
a	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
(anonymous)	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
(anonymous)	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
t	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
(anonymous)	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
g	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
(anonymous)	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
A	@	api-fetch.min.js?ver…4dabf8bf2c7adf21a:2
(anonymous)	@	index.js?ver=1.2.9.9.5:171
Ur	@	react-dom.min.js?ver=18.2.0:10
El	@	react-dom.min.js?ver=18.2.0:10
(anonymous)	@	react-dom.min.js?ver=18.2.0:10
v	@	react.min.js?ver=18.2.0:10
ce	@	react.min.js?ver=18.2.0:10

Let me know if you need any more information.

@Louis & @Araminta, just confirming this issue is still present with 1.3.0.1.

Just confirming this issue is still present with 1.3.0.3. We have replicated this on a second website and it may possibly be to do with using the latest WooCommerce plugin. It seemed to be fine before upgrading to this although their may be other factors involved.

Hi,

Would you be so kind as to let me know if the same error as above appears in your browser console?

Best regards,
Johnny

Hi @JohnD,

Although we can’t say for certain, the WPML plugin definitely seems to be the deciding factor.

Yes, this error is present.

1 Like

Hi,

Would you be so kind as to send me a copy of your debug log after you access the Themer. By PM or to support@cwicly.com.

This will give us more info as to why the error is happening.

Best regards,
Johnny

Absolutely. We will do this as soon as we have time.

I am facing the same issue for months now. I don’t have WPML plugin installed. Debug log below.
The SQL erros do not look good at all :smiley: . Maybe in my case we are hitting the DB too hard.

[11-Oct-2023 08:14:46 UTC] Error: Call to a member function format() on bool
[11-Oct-2023 08:14:46 UTC] Error: Call to a member function format() on bool
[11-Oct-2023 08:14:46 UTC] Error: Call to a member function format() on bool
[11-Oct-2023 08:14:46 UTC] Error: Call to a member function format() on bool
[11-Oct-2023 08:14:46 UTC] Exception: SQLSTATE[HY000] [1226] User 'xxx' has exceeded the 'max_user_connections' resource (current value: 25)
[11-Oct-2023 08:14:46 UTC] Exception: SQLSTATE[HY000] [1226] User 'xxx' has exceeded the 'max_user_connections' resource (current value: 25)
[11-Oct-2023 08:14:46 UTC] Exception: SQLSTATE[HY000] [1226] User 'xxx' has exceeded the 'max_user_connections' resource (current value: 25)
[11-Oct-2023 08:14:46 UTC] Exception: SQLSTATE[HY000] [1226] User 'xxx' has exceeded the 'max_user_connections' resource (current value: 25)
[11-Oct-2023 08:14:47 UTC] PHP Fatal error:  Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, string given in /wp-includes/class-wp-query.php:2202
Stack trace:
#0  wp-includes/class-wp-query.php(2202): array_map()
#1  wp-includes/class-wp-query.php(3800): WP_Query->get_posts()
#2  wp-includes/class-wp-query.php(3932): WP_Query->query()
#3  wp-content/plugins/cwicly/core/includes/classes/class-query.php(372): WP_Query->__construct()
#4  wp-content/plugins/cwicly/core/includes/dynamic/render.php(178): Cwicly\Query::front_prep()
#5  wp-content/plugins/cwicly/core/includes/blocks/query/query.php(155): cc_render()
#6  wp-includes/class-wp-block.php(258): cc_query_render_callback()
#7  wp-includes/class-wp-block.php(244): WP_Block->render()
#8  wp-includes/class-wp-block.php(244): WP_Block->render()
#9  wp-includes/class-wp-block.php(244): WP_Block->render()
#10 /wp-includes/blocks.php(1133): WP_Block->render()
#11 /wp-content/plugins/cwicly/core/includes/api/class-themer-api.php(119): render_block()
#12 /wp-includes/rest-api/class-wp-rest-server.php(1188): Cwicly\Themer_API->theme_render()
#13 /wp-includes/rest-api/class-wp-rest-server.php(1035): WP_REST_Server->respond_to_request()
#14 /wp-includes/rest-api/class-wp-rest-server.php(447): WP_REST_Server->dispatch()
#15 /wp-includes/rest-api.php(418): WP_REST_Server->serve_request()
#16 /wp-includes/class-wp-hook.php(310): rest_api_loaded()
#17 /wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters()
#18 /wp-includes/plugin.php(565): WP_Hook->do_action()
#19 /wp-includes/class-wp.php(398): do_action_ref_array()
#20 /wp-includes/class-wp.php(779): WP->parse_request()
#21 /wp-includes/functions.php(1335): WP->main()
#22 /wp-blog-header.php(16): wp()
#23 /index.php(17): require('/...')
#24 {main}
  thrown in /wp-includes/class-wp-query.php on line 2202

Suggest to have a category in Themer template page, when i creat a big site with many templates, plus the woo commerce default ones, it’s hard to find them, and the preview all need download data, and it’s easy to get problems. too many template on one page really need improved, i think.

maybe give a preview, no preview on template page button will also be helpful :
for me , i donot think there are too much value for the preview here.

by the way, i am not sure this is in right way or not. just a kindly hint


once you have a big site, each time regeneration whole site will take much time and use much cpu sources, after put the templates on different category , i do not know whether it is a better idea, to add one more regeneration button on difference template category page only regeneration for couple of templates will good a solution.

Hi @nadim,

Thank you for sharing your debug log, it’s very helpful!

We’ll be taking a closer look at this in the next few days, and will get back to you as soon as we have more information.

Thank you for your patience and understanding.

FYI, this is the call that’s constantly failing with HTTP 500 error when browsing to the Themer page:
/wp-json/cwicly/v1/render?_locale=user

I have about 14 templates and 24 template parts.

Hi,

Can you access/use the Cwicly Themer? This isn’t normal.

If possible, would you be so kind as to send temporary access to support@cwicly.com?

Best regards,
Johnny

@JohnD , @Araminta

I was able to narrow this down and (at least in my case) this is happening due to an exception being thrown when rendering a specific Query Block.

This Query Block is part of a template part and I was using a shortcode dynamic argument for the “Include Posts” filter.

Shortcodes always return a string, but the “Include Posts” filter expects an array. This causes the below exception to be thrown and prevents templates and template-parts from being rendered in the Themer.

PHP Fatal error:  Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, string given in /wp-includes/class-wp-query.php:2202
Stack trace:
#0  wp-includes/class-wp-query.php(2202): array_map()
#1  wp-includes/class-wp-query.php(3800): WP_Query->get_posts()
#2  wp-includes/class-wp-query.php(3932): WP_Query->query()
#3  wp-content/plugins/cwicly/core/includes/classes/class-query.php(372): WP_Query->__construct()
#4  wp-content/plugins/cwicly/core/includes/dynamic/render.php(178): Cwicly\Query::front_prep()
#5  wp-content/plugins/cwicly/core/includes/blocks/query/query.php(155): cc_render()
#6  wp-includes/class-wp-block.php(258): cc_query_render_callback()
#7  wp-includes/class-wp-block.php(244): WP_Block->render()

Please note that the exception prevents all template and template parts from rendering, even thought the exception is thrown while rendering a specific template.

After removing the shortcode dynamic argument, template and template parts are now rendered correctly in the Themer.

@msteinlein , you might want to check the logs for an exception thrown when loading the Themer. If you find one, it’s a matter of narrowing down the offending block.

@Araminta , maybe we can consider not allowing shortcodes as dynamic arguments for “Include Posts” filter?

On another note, I need to dynamically fetch the posts to be included in a query, and since using shortcodes isn’t possible as explained above, it would be great to be able to use a return Function in Query Dynamic Args.

@Araminta, Just confirming that as of 1.3.4.6 this bug is no longer occurring for us. The template previews are all displaying now.