WordPress, Gentoo and a blank update screen

Getting back into the swing of things, I decided to update my WordPress software on the server.  Having moved the web hosting from an old virtual server to a new Gentoo installation, I had not updated this software this year yet.

When I went to install the software, and clicked on update, the system prompted me for my ftp password, and then the next screen was blank.  It had the WordPress theme on the top and the options on the right side, but the rest of the screen was blank.  No message, no error, nothing.

I took a moment to look through the logs on the Gentoo server but saw nothing posted with regard to an error.  So I decided to start putting debug statements into the WordPress PHP code to deduce what was happening in the software.

First let me say that WordPress really needs to improve their code here.  While the software does check for errors, most of the errors return the functions with NO error messages being posted.  In fact, the code specifically looks like it tries to hide errors occurring.

For example, the system checks to see if some class modules are loaded.  If the class modules are not loaded, it tries to load these modules.  If the files for these class modules don’t exist, the system just returns nothing.  However, these errors were not the key problem.

If the user doesn’t have rights to the directory, the system just exits the function with no error.  Once again, these issues were not the error.

The error came in the wp-admin/include/class-ftp.php code.  The error is NOT in the class itself, but in the loading of the class.  During that process, the code looks to see if the php sockets module is loaded.  If it isn’t loaded, the code tries to load it.  But if the module isn’t available to PHP, the PHP code just dumps and doesn’t return to the code stream.

In my opinion, this is not only an issue for WordPress, but all PHP code.  If you try to do a @dl to load the module, and the module doesn’t exist, PHP will not error, nor does the error code following it get executed.

The solution in my case was to make sure PHP was compiled with the “sockets” module enabled.  In Gentoo, this is a simple task of making sure the USE flag for sockets is set for the dev-lang/php package.

echo ‘dev-lang/php sockets’ >> /etc/portage/package.use

emerge -av dev-lang/php

After this, the updates were able to flow into WordPress.  Hope this helps you.