WordPress Move, fix the Fatal Error on Activation

It is not uncommon to migrate a WordPress site, for example from development to production. The plugin WordPress Move (realized and maintained by Mert Yazicioglu) comes in handy for this very purpose. Its strong point being the ability to migrate the whole lot, database, files, plugins, and finally settings, at ease.

And it serves as manual backup as well, might you need that too.

On some web hosts the plugin does not properly activate, and instead it returns a fatal error. Luckily there is a fix for (almost) everything.

The error

If you’re reading this page chances are you've encountered an error like 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 ../wp-content/plugins/wordpress-move/wordpress-move.php on line 44

The solution is simple but it requires a bit of craft from your part.

First step, fixing wordpress-move.php

Open the file wordpress-move.php at the path below.

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

Around the line 43 (it might vary slightly with different releases of the plugin) you should find the few lines of code below.

// 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 shown below. This will disable it.

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

At this point you may be able to activate WordPress Move. If you still get an error on activation, it may be like the one here below.

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

To fix this we need to open a file in the core of WordPress itself.

The file is located in wp-admin/includes/class-ftp.php. Open it and scroll until the end of the file, around 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 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;  
}  

That should suffice.

Note. Once you’ll be done with the migration, come back to class-ftp.php and restore it at its previous state.

Done!

You should finally be able to activate the plugin.

To stay on the safe side, do not forget to restore the file class-ftp.php once the migration is complete.

For more details head to the official page for the plugin.