'

WordPress Move, how to fix the Fatal Error on Activation

In our normal routine, it isn’t uncommon to migrate a WordPress site, most of the times from production to its final domain. The plugin WordPress Move (realized and maintained by Mert Yazicioglu) is an useful tool that serves this very purpose. It allows to migrate the whole pack (database, files, plugins, settings) at ease.

It’s also good for backing up purposes, in case you like to do it manually.

Unfortunately, on some web hosts the plugin does not properly activate, returning a fatal error. No panic, there is an easy fix, and in matter of minutes you’ll be able to benefit of its priceless service.

The error

If you’re reading this page, you might have been returned an error message not dissimilar from the one below.

Plugin could not be activated because it triggered a fatal error.

Warning: set_time_limit(): Cannot set time limit due to system policy in /customers/mandestripalex.dk/mandestripalex.dk/httpd.www/wp-content/plugins/wordpress-move/wordpress-move.php on line 44

First time I saw it, I was clueless. But the solution is quite simple and it comes from the author of the plugin himself. Let’s see.

First step, fixing wordpress-move.php

Without entering in the details (you can find a long discussion about the issue on the plugin official page) let’s go straight to the fix. Open the file wordpress-move.php, which you can find following the path below.

root/wp-content/plugins/wordpress-move/wordpress-move.php

At the line 43 (it might vary slightly, with new releases of the plugin), you should find these few lines of code.

// Some operations may exceed the limit set by max_execution_time
if( ! ini_get('safe_mode') )
  set_time_limit(0);

Comment all the block, as below. In practice this will disable it.

// Some operations may exceed the limit set by max_execution_time
// if( ! ini_get('safe_mode') )
//   set_time_limit(0);

Sometimes, at this point you are already able to activate WordPress Move. Otherwise, you might get still an error on activation. Just, this time usually without any hints of what’s going on under the hood.

Plugin could not be activated because it triggered a fatal error.

In this case, proceed with the second step.

Fixing the WordPress core in class-ftp.php

Be aware that in this case we’re handling a file in the core of WordPress itself. The fix might get overriden along with a future upgrade. On the other hand, this is a necessary modification to be done in order to run the plugin.

My recommendation is to not delete any line of code. Instead, comment it. Once you’ll be done with the migration, come back to class-ftp.php and restore it at its previous state.

So, here we go. The file is located in root/wp-admin/includes/class-ftp.php. Open it and go to the end of the file, line 902.

$mod_sockets=TRUE;
if (!extension_loaded('sockets')) {
  $prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : '';
  if(!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE;
}

Modify as below, commenting the original line and replacing it with a a new one, which operates one more check.

$mod_sockets=TRUE;
if (!extension_loaded('sockets')) {
  $prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : '';
  /* if(!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE; */
  if(!is_callable('dl') || !@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE;
}

This should do the trick.

Done!

And that’s all. Reopen the Plugins page on your WordPress Dashboard, and click on Activate below the WordPress Move plugin in the list. You should finally get a nice feedback.

Plugin activated.

Final consideration and feedbacks

To stay on the safe, I would restore the file class-ftp.php once the migration completes. For obvious reason I couldn’t test the fix on the whole lot of Web Hosts and configuration they might offer. This short guide has the purpose to help you activate the WordPress Move plugin, and it should work smoothly. If not, please notify me. Or submit your experience on the official page of the plugin, maintained by Mert Yazicioglu. He’s an amazing guy and he’s usually able to get back to you in a matter of hours.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>