Drupal Code Missing after FTP?

This article was featured in Paper.li, .

Did you upload, to a remote server, a complete Drupal-based website, or update one with the latest Drupal core, and now the site is waving the white flag — that is, the White Screen of Death (WSoD)? It might be coughing up only a single error message, informing you that a critical Drupal function is missing. If so, here is one way to begin your troubleshooting efforts and possibly find an easy fix.

Whenever you are using FTP to upload Drupal files to a remote web server, or to download some to a local server, there is a chance it will result in a Drupal near-death experience — or at least a close approximation. Recently I was upgrading a remote client website to the latest Drupal security release. It worked perfectly on a local mirror of the site. But after the file transfer completed, the client's home page was replaced by a white screen listing only an error message that a commonly-used core module function could not be found.

In such a situation, one's first thought — aside from finding a less stressful career — might be that a core or contrib module version is now out of sync with the rest of the site, or that the author of a contrib module is using an outdated function name, or that some contrib code is trying to access a function that simply does not exist. In my experience, the problem and solution are, frequently and thankfully, rather straightforward: During the file transfer, it is possible that the FTP client program inadvertently emptied a target file by freeing the space allocated to its old contents, but failed to write the new contents and close the file. Sadly, most if not all FTP programs do not verify that the contents were written to and saved in the file (which admittedly would slow FTP transfers considerably), or even that the file sizes on the source and target machines are identical. In other words, FTP can fail silently but continue transferring files as fast as it can, without any warnings or error messages.

Below is a simple PHP script that searches for and reports, in alphabetical order, any zero-byte files in the current directory and all its subdirectories, recursively. The code is offered as is, with no warranty, implied or otherwise. It is intended to be run in a web browser, but works fine on the command line, although in that case you may want to remove the break tag on line 13. Obviously it would make no sense to try to package this modest utility as a Drupal module, because as long as Drupal is choking with a fatal PHP function-loading error, then it is not bootstrapping and certainly would not see any contrib module code.

So if a Drupal site stops working immediately after an FTP operation, consider first looking for empty files created by one or more faulty file transfers. If the remote server is running Linux, and you have shell access, then you can use a shell command, such as find . -type f -size 0. Otherwise, you can use this PHP script:


list_empty_files( '.' );

function list_empty_files( $dir_path ) {
foreach ( scandir( $dir_path ) as $file_name ) {
if ( ! in_array( $file_name, array( '.', '..' ) ) ) {
$file_path = ( ( $dir_path == '.' ) https://www.ross.ws/? null : "$dir_path/" ) . $file_name;
if ( is_dir( $file_path ) ) {
list_empty_files( $file_path );
elseif ( filesize( $file_path ) == 0 ) {
echo $file_path . "<br />\n";
Copyright © 2013 Michael J. Ross. All rights reserved.
bad bots block