We got a Wordpress site, designed by an external contractor a couple years ago. https://playbacktheatre.com.au
We recently (Dec 2019) changed hosting providers in search of a better service. After the migration the site was working smoothly and it was much faster, as we hoped it would be.
Recently though we got a problem with the home page throwing an HTTP 500 error. I believe this was triggered by the update of one of the pages (https://playbacktheatre.com.au/performances/) using the Wordpress admin panel. Only the home page throws this error, all other pages seem to be working ok.
I asked for a restoration of a previous state from our provider and they did it. (I later found that they restored only a single folder [httpdocs] that contains just the static files and the code. They did not restore the database, nor the plugins, nor Wordpress itself.) The problem was gone! I then I did the update on the page I wanted again (performances/). The problem with the home page reappeared.
I started digging in, using the tools our hosting provider has (Plesk). I found the 500 error in the logs. Here's the error:
.953468 [NOTICE]  [220.127.116.11:38726-1#APVH_playbacktheatre.com.au:lsapi] [STDERR] PHP Parse error: syntax error, unexpected 'endif' (T_ENDIF) in /var/www/vhosts/playbacktheatre.com.au/httpdocs/site/wp-content/themes/playback/front-page.php on line 186
I browsed the front-page.php file trying to find something obviously wrong with line 186 (I am not familiar with php, but I am comfortable with programming and other languages). I could not see anything wrong. Then I restored again the website to a prior working state (I found how to do it on my own, I restored only the httpdocs folder) and checked that the home page was working. I browsed again the front-page.php in the hope of finding something different. The file was exactly the same as before (compared with diff). I am puzzled with this. How come the error appears in one case and not the other? Is it a matter of different portions of the php script running? I would expect a syntax error like this to throw an error regardless.
I am happy to post the full php file here (191 lines) but just to give you a taste, the offending endif statement is the second to last.
<?php if( have_rows('page_previews') ): while ( have_rows('page_previews') ) : the_row(); ?> <? $post_object = get_sub_field('page'); $useCustom = get_sub_field('custom_content'); $cTitle = get_sub_field('custom_title'); $cSubtitle = get_sub_field('custom_subtitle'); $cText = get_sub_field('custom_excerpt'); $linkType = get_sub_field('link'); $align = get_sub_field('text_align'); if($post_object) : $post = $post_object; setup_postdata( $post ); ?> <section id="<?php echo $post->post_name; ?>" class="preview"> (... more code ...) <?php endif;?> (<- This is line 186) <?php endwhile; endif; ?>
Other things that I tried to fix the problem:
- Updates Wordpress from 4.8.x to 5.3.x, and updated plugins using Plesk
- Deactivated plugins using the Wordpress admin panel
I can try doing a more full restoration (database and everything) but I am a bit uncertain on how to do this right. My folder structure is the following:
Name Modified Size .cagefs Dec 20, 2019 03:23 AM .cl.selector Feb 5, 2020 03:23 AM .pki Dec 19, 2019 06:43 PM .revisium_antivirus_cache Dec 20, 2019 07:37 PM .ssh Dec 21, 2019 01:00 AM .wp-cli Dec 20, 2019 03:24 AM error_docs Dec 19, 2019 06:42 PM httpdocs Dec 20, 2019 06:00 PM httpdocs.bak Dec 20, 2019 05:36 PM logs Feb 19, 2020 03:28 AM lscache Dec 20, 2019 02:48 PM migration Dec 20, 2019 12:42 PM site.bak Dec 20, 2019 05:36 PM snapshots Feb 17, 2020 04:19 PM wp_h8yyl_2019-12-20_17-33-19.sql.zip Dec 20, 2019 05:33 PM 1.4 MB
Any advice is very welcome.