Saltar navegación

[Resuelto] Conditional statements breaking pages on a different server

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
Moving a site to another server the page design broke, in particular content which would normally be hidden/exposed based upon wpv-conditional shortcodes didn't behave as expected.

Solution:
The new server was running PHP 7.2, and PHP 7.x introduced a new error which affects long sections of conditional (where there is a lot of content to parse between the opening and closing wpv-conditional shortcodes).

We are working to improve this but in the meantime you can

- continue to use PHP 5.6, or
- simplify your conditional content.

One way of doing that is to move the content which you want to conditionally display inside an unassigned Content Template, and then insert that template within the conditional shortcodes.

This support ticket is created hace 6 años, 10 meses. 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)

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por joshM-4 hace 6 años, 10 meses.

Asistido por: Nigel.

Autor
Mensajes
#621107
what it should like like.jpg
what it looks like on the new server.jpg

I am trying to: Have my site display the same on a new server

Link to a page where the issue can be seen: enlace oculto

I expected to see: the same layout as this page where I cloned the site from: enlace oculto

Instead, I got: The broken layout you see at enlace oculto

I just need some help troubleshooting this. The new site is an exact clone of the previous site but the template for the individual business listings is causing the page layout to break for some reason...

#621282

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

Hi Josh

I see two possibilities here.

We have had some reports of complex conditionals not working in PHP7, which I note you appear to be using. Normally, though you would see some unparsed shortcodes on the screen, which doesn't appear to be the case from your screenshots.

If it is possible to switch your server to, say, PHP 5.6, and re-test you should be able to confirm/deny whether that is the issue.

Also check your logs for PHP warnings or errors.

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 same page where you observe the problem and then inspect the log. If you don't find the debug.log file it means it didn't generate any warnings or errors.

If that doesn't reveal anything an alternative explanation may be an incomplete copy of your site.

You have cloned the site, but, depending on the tool, your clone may be a 99.9% copy rather than a 100% copy, and the missing 0.1% could be the problem.

So you could try using a different tool, e.g. All in One WP Migration, to copy the source site to the destination.

Let me know what you find.

#621420

Thank you Nigel,

Looks like it was PHP7 causing that. I downgraded to 5.6 and all is better.

Curious if you guys have a fix in store? I would sure like to run all my sites on PHP7.

Thanks,
Josh

#621489

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

Hi Josh

PHP 7 introduced an error for overly-long regular expressions which didn't occur previously.

It has created a gnarly problem that we don't currently have a solution for (the regular expressions have been optimised within an inch of their lives according to the devs), although we haven't given up on it. I'll raise it with the devs again on Monday morning.

In the meantime the only solution is to simplify your conditions. Not the conditions themselves, but the amount of content that occurs between the opening and closing wpv-conditional shortcodes, which is the root cause of the problem.

Note that you might be able to shift some content into an unassigned content template and then insert that content template in place to help reduce the 'complexity' of your conditional shortcodes.

If that doesn't sound like your conditional shortcodes at all (i.e. they are very simple) then let me know because there could be something specific triggering the problem that my colleagues would need to investigate.

#621718

Nigel,

Thank you for taking the time to further explain this. I can definitely work on simplifying the conditions as you described because I do have conditions with extensive content inside. The unassigned content templates idea is also brilliant.

Again, I really appreciate it.
Josh