2

I recently transferred a site that was created on PHP 5.6.2 to a new hosting with PHP 7.0.29. The site transferred fine and the front end looked like it should but when I tried to access the Dashboard, I got the White Screen of Death.

The Wordpress installation is up to date at version 4.9.5 and all plugins were up to date when the site was copied for transfer.

In order to resolve the issue, I tried the following then tried the following:

  1. Checked and Increased Memory Limits on PHP
  2. Disabled all plugins

I tested between each change but the outcome remained the same.

Next I enabled DEBUG mode in wp-config.php - but no errors were reported.

define( 'WP_DEBUG', true );

I then installed the Site on a different server with PHP 5.6 and it worked fine as-is.

Is there something about PHP 7 that potentially breaks Wordpress? Any ideas on what to try next or advice from anyone who has suffered similar installation issues will be appreciated.

2
  • 1
    good that you've tried disabling the plugins, but it may just as well be a theme problem, you could try it with a default theme... also if the problem is only in admin check for a php error log in /wp-admin/ ... also you can reinstall core just in case it was a simple failed file transfer
    – majick
    Apr 28, 2018 at 1:20
  • Thanks @majick, I found an answer and your suggestion would have worked (but I would not have understood why). I will post the solution below because I think that others may benefit from it.
    – Clinton
    Apr 28, 2018 at 15:27

1 Answer 1

4

After a lot of testing and considerable frustration, I discovered the problem. I am including this solution in the hope that it saves someone else a lot of frustration if they encounter a similar problem.

The problem to be the presence of a PHP closing tag '?> ' in the functions.php file of the child-theme. It is not the closing tag itself that is the problem, but a blank line or even a space after the closing tag. This is sent to the browser as HTML and breaks Wordpress because the header() function fails if anything is sent to the browser before this function is run. The redirect to the login page will not work and there is nothing to display (apart from the blank line or space) and hence the WSOD (White Screen of Death).

I guess I should have picked this up sooner, but as closing a php script using '?>' is fairly standard practice, I am sure that may others may inadvertently also have a similar problem. It also is very curious that the closing tag on functions.php worked on a server with PHP 5.6 but not on a server with PHP 7. I accept that it may be some other setting on the server, but the best practice is simply not to use a closing tag in the functions.php file.

My advice is, check your functions.php and if you have a closing php tag then remove it (even if it works right now) as the tag it is not needed and can lead to problems that will be very difficult to identify later.

Finally, below is my list of checks (in order) if you ever get a WSOD after moving or changing a Wordpress installation:

  1. Check your functions.php file in your child theme and if there is a closing tag then delete is (it is not needed).
  2. Switch off all your plugins by renaming the plugins directory to something like pluginsX - check if this fixes the problem if this does then the error is in one of the plugins. Rename the directory back to what it was and then identify which plugin is the problem.
  3. Check memory limits allocated to PHP and increase these if necessary.
  4. If none of this works, rename the theme file - Wordpress then will revert to the default theme twentysixteen.

After that, it should work because you are back to base Wordpress functionality. However, if there still are problems then debug.

I hope that this helps and saves someone else a lot of time and a lot of frustration.

1
  • 1
    yes I've had that one, it is certainly is curious that there was no error with PHP 5.6, as you say probably just some server config that allows it. it is not just a problem for functions.php but any PHP file in a plugin or project can cause this. there is even an article about it... hardcorewp.com/2013/…
    – majick
    Apr 30, 2018 at 4:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.