Skip Navigation

[Resolved] Toolset with PHP7 and conditional shortcodes

This thread is resolved. Here is a description of the problem and solution.

Problem:
Some posts are not displaying correctly when using PHP 7.x, many of the shortcodes on the page are printed instead of parsed.

Solution:
PHP7 introduced limits that affect the regular expressions used to parse what's inside the conditional shortcode (i.e. between the opening and closing wpv-conditional shortcode).

It could be that for some posts with slightly more content (once all interior shortcodes have been expanded) it pushes you over the limit, whereas for other posts it does not. In which case the only solution is to break up the content to be conditionally displayed into smaller blocks, repeating the conditional shortcode if required.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

This support ticket is created 5 years, 11 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by christopheV-2 5 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#1167518

Hello,

I spent my site on a server with php7.0.33. With Views no problem.
But with the content models of times it does not work sometimes.

Example: hidden link
hidden link

Thanks

#1167716

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

I looked at the two links and can see one that works and one that does not.

On the one that does not, it is not only the Toolset shortcodes which are not working, I can see that shortcodes from other plugins are being printed rather than parsed as well.

I suspect that if you look in your debug logs you might find the cause (such as server memory issues).

If you haven't already, turn on the debug.log by editing your wp-config.php file and change the line with WP_DEBUG like so:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

That will create a debug.log file in your /wp-content/ directory which you can examine in any text editor. Try visiting the problem link again and then inspect the log. If you don't find the debug.log file it means it didn't generate any warnings or errors.

Let me know what you find, and please also provide the debug info in your next reply: hidden link

#1168852

The problem with php7 is here :
[wpv-conditional if="( has_term('Rugby', 'sport-stage-detection', null) eq '1' )" ]

Thanks for help

#1169582

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

There is nothing that looks wrong with the conditional shortcode.

What may be happening is that PHP7 introduced limits that affect the regular expressions used to parse what's inside the conditional shortcode (i.e. between the opening and closing wpv-conditional shortcode).

It could be that for some posts with slightly more content (once all interior shortcodes have been expanded) it pushes you over the limit, whereas for other posts it does not. In which case the only solution is to break up the content to be conditionally displayed into smaller blocks, repeating the conditional shortcode if required.

Did you find anything reported in the debug log?

#1169674

Thank you very much that was exactly the problem 😉