Skip Navigation

[Resolved] Split: Shortcodes with parameters upgrade after error php 8 (pt. 2) – filer view by shortcode attribute

This support ticket is created 2 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 17 replies, has 3 voices.

Last updated by Shane 2 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#2371485

Hi Minesh, thanks for reply, error gone.

The ID's of View this filter should work are 5698, 7081
I've also change it in code. No errors from php standpoint.

 if ( in_array( $view_id, array( 5698, 7081) ) ){

As for now, my two views have the following (former) shortcode inserted on site page, showing no results (see attached)):
-- View ID 5698

<div>[wpv-view name="mysht-list-all-orders" email="[wpv-user field="user_email"]"]</div>

-- View ID 7081

<div>[wpv-view name="mysht-list-all-orders-others" email="[wpv-user field="user_email"]"]</div>

Should I remove 'email' parameter from the shortcodes above and make them like this after adding code to functions.php ?
View ID 5698 (with 'prefix_for_specific_email' code in functions.php):

<div>[wpv-view name="mysht-list-all-orders"]</div>

View ID 7081 (with 'prefix_for_specific_email' code in functions.php):

<div>[wpv-view name="mysht-list-all-orders-others" ]</div>
#2371509

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

It seems you are mixing two things here. You are using the view's hook "wpv_filter_query" to filter the query by "_billing_email".

What way you want to filter your view using "wpv_filter_query" or using the view's shortcode attribute?

#2371523
2022-05-26_09-36-21.png

Hm, that was my question to Jamal and you actually. What will work in PHP8?

As far as I understand from your answers:
1. "using the view's shortcode attribute?" is not working in php8
2. Jamal proposed code "wpv_filter_query" https://toolset.com/forums/topic/shortcodes-with-parameters-upgrade-after-error-php/
3. we fixed php code error with you in previous ticket
4. the solution is not working. You created new topic here. OK, let's continue here.

The FINAL question is:
What changes should I make in shortcodes for Views ID to work with "wpv_filter_query" way?

As for now, my two views have the following (former) shortcode inserted on site page, showing no results (see attached)):
-- View ID 5698

<div>[wpv-view name="mysht-list-all-orders" email="[wpv-user field="user_email"]"]</div>

-- View ID 7081

<div>[wpv-view name="mysht-list-all-orders-others" email="[wpv-user field="user_email"]"]</div>

Should I remove 'email' parameter from the shortcodes above and make them like this after adding code to functions.php ?

View ID 5698 (with 'prefix_for_specific_email' code in functions.php):

<div>[wpv-view name="mysht-list-all-orders"]</div>

View ID 7081 (with 'prefix_for_specific_email' code in functions.php):

<div>[wpv-view name="mysht-list-all-orders-others" ]</div>

I think it is also important, Jamal mentioned:
"The views are expecting a shortcode argument to match against a custom field, with a post status filter, and a text search filter. You can replace the shortcode attribute by a custom code that hooks into the views' query filters. "

Please have a look at Query Filter setting , I have in a View ID 5698 (same in View ID 7081), should it remains the same or need to be changed ?

#2371609

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Based on the information you shared settings looks OK to me.

I'm not sure yet why its not working with PHP 8.x.x as now Toolset plugins are compatible with PHP 8.

If you can share problem URL where you added your view and share access details I'm happy to look at the issue and review what could be the solution we should go for.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2371671

Dear Minesh,
Thank you so much for trying to fix this. Please pass this ticket to Jamal ( as an initiator of this code ), I'd like to try him to help me to solve this.
Many thanks for your support!

#2371721

Please let me know, when Jamal will be available to pass this ticket.

BTW, after:
- switching to php8
- I've putted shortcodes in content template with the [ ] brackets . Then included the content template inside Divi.
- and try to go to page , where CPT and View inside (id 5698) is located

I get the following PHP8 Fatal Error (I don't have it in PHP 7.3, 7.4).. Does it possible to fix it somehow:

[26-May-2022 11:43:49 UTC] PHP Fatal error:  Uncaught ArgumentCountError: array_merge() does not accept unknown named parameters in /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/embedded/inc/classes/wpv-cache.class.php:358
Stack trace:
#0 /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/embedded/inc/classes/wpv-cache.class.php(358): array_merge(post_author: Array, post_type: Array)
#1 /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/embedded/inc/classes/wpv-cache.class.php(580): WPV_Cache::generate_post_data_cache(Array, Array, Array)
#2 /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/embedded/inc/wpv-filter-query.php(220): WPV_Cache::generate_native_cache(Array, Array)
#3 /var/www/u5170108/data/www/tao-online.net/wp-includes/class-wp-hook.php(303): WPV_View_Post_Query->wpv_filter_extend_query_for_parametric_and_counters(Object(WP_Query), Array, '5698')
#4 /var/www/u5170108/data/www/tao-online.net/wp-includes/plugin.php(189): WP_Hook->apply_filters(Object(WP_Query), Array)
#5 /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/embedded/inc/wpv-filter-query.php(848): apply_filters('wpv_filter_quer...', Object(WP_Query), Array, '5698')
#6 /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/embedded/inc/wpv.class.php(2497): wpv_filter_get_posts('5698')
#7 /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/embedded/inc/wpv.class.php(2124): WP_Views->render_view('5698', '9cb7e4f71c8b12c...')
#8 /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/embedded/inc/wpv.class.php(639): WP_Views->render_view_ex('5698', '9cb7e4f71c8b12c...')
#9 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(356): WP_Views->short_tag_wpv_view(Array, '', 'wpv-view')
#10 [internal function]: do_shortcode_tag(Array)
#11 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(228): preg_replace_callback('/\\[(\\[?)(wpv\\-v...', 'do_shortcode_ta...', '<div class="et-...')
#12 /var/www/u5170108/data/www/tao-online.net/wp-includes/class-wp-hook.php(303): do_shortcode('<div class="et-...')
#13 /var/www/u5170108/data/www/tao-online.net/wp-includes/plugin.php(189): WP_Hook->apply_filters('<div class="et-...', Array)
#14 /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/application/models/shortcode/post/body.php(245): apply_filters('the_content', '<div>[wpv-view ...')
#15 /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/application/models/shortcode/post/body.php(147): WPV_Shortcode_Post_Body->get_content_template_value()
#16 /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/application/models/shortcode/base_view.php(32): WPV_Shortcode_Post_Body->get_value(Array, '')
#17 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(356): WPV_Shortcode_Base_View->render(Array, '', 'wpv-post-body')
#18 [internal function]: do_shortcode_tag(Array)
#19 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(228): preg_replace_callback('/\\[(\\[?)(wpv\\-p...', 'do_shortcode_ta...', '[wpv-post-body ...')
#20 /var/www/u5170108/data/www/tao-online.net/wp-content/themes/Divi/includes/builder/class-et-builder-element.php(2888): do_shortcode('[wpv-post-body ...')
#21 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(356): ET_Builder_Element->_render(Array, '[wpv-post-body ...', 'et_pb_tab')
#22 [internal function]: do_shortcode_tag(Array)
#23 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(228): preg_replace_callback('/\\[(\\[?)(s2If|c...', 'do_shortcode_ta...', '[et_pb_tab titl...')
#24 /var/www/u5170108/data/www/tao-online.net/wp-content/themes/Divi/includes/builder/class-et-builder-element.php(2888): do_shortcode('[et_pb_tab titl...')
#25 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(356): ET_Builder_Element->_render(Array, '[et_pb_tab titl...', 'et_pb_tabs')
#26 [internal function]: do_shortcode_tag(Array)
#27 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(228): preg_replace_callback('/\\[(\\[?)(s2If|c...', 'do_shortcode_ta...', '[et_pb_tabs adm...')
#28 /var/www/u5170108/data/www/tao-online.net/wp-content/themes/Divi/includes/builder/main-structure-elements.php(3092): do_shortcode('[et_pb_tabs adm...')
#29 /var/www/u5170108/data/www/tao-online.net/wp-content/themes/Divi/includes/builder/class-et-builder-element.php(3205): ET_Builder_Column->render(Array, '[et_pb_tabs adm...', 'et_pb_column', '', '', '', '')
#30 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(356): ET_Builder_Element->_render(Array, '[et_pb_tabs adm...', 'et_pb_column')
#31 [internal function]: do_shortcode_tag(Array)
#32 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(228): preg_replace_callback('/\\[(\\[?)(s2If|c...', 'do_shortcode_ta...', '[et_pb_column t...')
#33 /var/www/u5170108/data/www/tao-online.net/wp-content/themes/Divi/includes/builder/main-structure-elements.php(1915): do_shortcode('[et_pb_column t...')
#34 /var/www/u5170108/data/www/tao-online.net/wp-content/themes/Divi/includes/builder/class-et-builder-element.php(3205): ET_Builder_Row->render(Array, '[et_pb_column t...', 'et_pb_row', '', '', '', '')
#35 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(356): ET_Builder_Element->_render(Array, '[et_pb_column t...', 'et_pb_row')
#36 [internal function]: do_shortcode_tag(Array)
#37 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(228): preg_replace_callback('/\\[(\\[?)(s2If|c...', 'do_shortcode_ta...', '[et_pb_row _bui...')
#38 /var/www/u5170108/data/www/tao-online.net/wp-content/themes/Divi/includes/builder/main-structure-elements.php(1283): do_shortcode('[et_pb_row _bui...')
#39 /var/www/u5170108/data/www/tao-online.net/wp-content/themes/Divi/includes/builder/class-et-builder-element.php(3205): ET_Builder_Section->render(Array, '[et_pb_row _bui...', 'et_pb_section', '', '', '', '')
#40 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(356): ET_Builder_Element->_render(Array, '[et_pb_row _bui...', 'et_pb_section')
#41 [internal function]: do_shortcode_tag(Array)
#42 /var/www/u5170108/data/www/tao-online.net/wp-includes/shortcodes.php(228): preg_replace_callback('/\\[(\\[?)(s2If|c...', 'do_shortcode_ta...', '<div class="et-...')
#43 /var/www/u5170108/data/www/tao-online.net/wp-includes/class-wp-hook.php(303): do_shortcode('<div class="et-...')
#44 /var/www/u5170108/data/www/tao-online.net/wp-includes/plugin.php(189): WP_Hook->apply_filters('<div class="et-...', Array)
#45 /var/www/u5170108/data/www/tao-online.net/wp-includes/post-template.php(253): apply_filters('the_content', '[et_pb_section ...')
#46 /var/www/u5170108/data/www/tao-online.net/wp-content/themes/Divi/page.php(46): the_content()
#47 /var/www/u5170108/data/www/tao-online.net/wp-includes/template-loader.php(106): include('/var/www/u51701...')
#48 /var/www/u5170108/data/www/tao-online.net/wp-blog-header.php(19): require_once('/var/www/u51701...')
#49 /var/www/u5170108/data/www/tao-online.net/index.php(17): require('/var/www/u51701...')
#50 {main}
  thrown in /var/www/u5170108/data/www/tao-online.net/wp-content/plugins/wp-views/embedded/inc/classes/wpv-cache.class.php on line 358
#2371735

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Jamal no longer works with support so you have to help me with the admin access details or if you prefer anyone else from the support team, let me know.

#2371795

Sure Minesh, please have a look to a WordPress debug Fatal Error. Is it possible to fix it?

I've updated all Toolset to latest release, which supports PHP8 as mentioned here - https://toolset.com/2022/05/toolset-1-6-3-full-compatibility-with-php-8/

#2372489

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What if you remove the shortcode attribute "email" you added to your view and save it and then check, do you see it working?

Either I will require access to your site or your site copy that I will try to deploy on my local machine that will help me to review your settings and once I check that I will be able to guide you in the right direction.

Can you please tell me what option you would like to go with (access details / duplicator)?

#2373177

Yes, I'll send you the login details.
Please make next reply private for me.

#2373961

Hello, Minesh,
are you there still to help with this?

#2374229

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dmitry,

Minesh is on off today and tomorrow so I will be stepping in to assist where I can.

Would you mind allowing me to have admin access to the website so that I can have a more detailed look at this for you ?

Please where applicable please provide me with a link to an example page where I can see the issue.

I've enabled the private fields for your next response.

Thanks,
Shane

#2375499

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dmitry,

You're getting the fatal error on array_merge() because you're still running older versions of our toolset plugins when switched to php 8.

In order for our plugins to work on PHP 8 you need to update them to their latest versions.

I'm assuming here that this is the main purpose of this thread.

The latest versions can be downloaded from the link below.
https://toolset.com/account/downloads/#legacy-plugins

Thanks,
Shane

#2376047

Ok, return to you shortly after upgrading everything in upg.tao-... instance

Thanks

#2376591

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dmitry,

Any updates on this one ?

Please let me know.
Thanks,
Shane