(Pull Request) Error while copying a dir while cloning
-
Hello guys!
I was creating some subsites using your plugin and while copying from a site with multiples posts, files and pages everything went fine.
Therefore when copying from a template site only with a few configuration, appearance and plugin options occurs a error trying to copy dirs and files that don’t exist.
The full log:
[Wed Sep 17 10:35:49 2014] [error] [client 10.10.2.27] PHP Warning: copy(/var/www/html/wordpress/wp-content/uploads/sites/13/) [<a href='function.copy'>function.copy</a>]: failed to open stream: No such file or directory in /var/www/html/wordpress/wp-content/plugins/multisite-cloner/multisite-cloner.php on line 423, referer: http://mycompany.com/wp-admin/network/site-new.php [Wed Sep 17 10:35:49 2014] [error] [client 10.10.2.27] PHP Warning: readdir() expects parameter 1 to be resource, boolean given in /var/www/html/wordpress/wp-content/plugins/multisite-cloner/multisite-cloner.php on line 417, referer: http://mycompany.com/wp-admin/network/site-new.php [Wed Sep 17 10:35:49 2014] [error] [client 10.10.2.27] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/html/wordpress/wp-content/plugins/multisite-cloner/multisite-cloner.php on line 423, referer: http://mycompany.com/wp-admin/network/site-new.phpThe problem was at the line 423 on a function called cloner_recurse_copy. The function tries to open a dir and then some recursive copy should be made. The problem is: there isn´t a validation code after tried to open the source dir. After a simple guard code everything worked like a charm. It is possible to add this little correction on a new plugin version?
function cloner_recurse_copy($src, $dst) { $dir = opendir($src); // maybe I am not a dir after all. if(!$dir || !is_dir($dir)) { return; } if (!file_exists($dst)) { mkdir($dst); } while(false !== ( $file = readdir($dir)) ) { if (( $file != '.' ) && ( $file != '..' )) { if ( is_dir($src . '/' . $file) ) { cloner_recurse_copy($src . '/' . $file,$dst . '/' . $file); } else { copy($src . '/' . $file,$dst . '/' . $file); } } } closedir($dir); }Thanks!!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘(Pull Request) Error while copying a dir while cloning’ is closed to new replies.