From 70261dc540feda7bfb8d7e7bcc183ad0769a047f Mon Sep 17 00:00:00 2001 From: Tom Macdonald Date: Thu, 23 Feb 2017 15:56:25 +0100 Subject: [PATCH 1/7] remove cache flushing on error --- lib/duplicate.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/duplicate.php b/lib/duplicate.php index 9a0970c..7475df1 100644 --- a/lib/duplicate.php +++ b/lib/duplicate.php @@ -52,7 +52,6 @@ public static function duplicate_site($data) { $user_id = MUCD_Duplicate::create_admin($email, $domain); if ( is_wp_error( $user_id ) ) { - wp_cache_flush(); $form_message['error'] = $user_id->get_error_message(); return $form_message; } @@ -63,7 +62,6 @@ public static function duplicate_site($data) { $wpdb->show_errors(); if ( is_wp_error( $to_site_id ) ) { - wp_cache_flush(); $form_message['error'] = $to_site_id->get_error_message(); return $form_message; } From a662e02a00cb3d0bb2bba10b8d404b30ab9f9e55 Mon Sep 17 00:00:00 2001 From: David DAUGREILH Date: Fri, 11 May 2018 17:13:09 +0200 Subject: [PATCH 2/7] Bugfix - Dont duplicate usermeta from an other blog when source is main site --- lib/duplicate.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/duplicate.php b/lib/duplicate.php index 9a0970c..2e657f7 100644 --- a/lib/duplicate.php +++ b/lib/duplicate.php @@ -140,6 +140,20 @@ public static function copy_users($from_site_id, $to_site_id) { global $wpdb; + // Bugfix Pierre Dargham : relocating this declaration outside of the loop + // PHP < 5.3 + function user_array_map( $a ){ return $a[0]; } + + if (is_main_site($from_site_id)) { + $is_from_main_site = true; + $all_sites_ids = MUCD_Functions::get_sites(['fields' => 'ids']); + if(!empty($all_sites_ids)) { + $all_sites_ids = array_map( 'user_array_map', $all_sites_ids ); + } + } else { + $is_from_main_site = false; + } + // Source Site information $from_site_prefix = $wpdb->get_blog_prefix( $from_site_id ); // prefix $from_site_prefix_length = strlen($from_site_prefix); // prefix length @@ -154,24 +168,23 @@ public static function copy_users($from_site_id, $to_site_id) { switch_to_blog($to_site_id); - // Bugfix Pierre Dargham : relocating this declaration outside of the loop - // PHP < 5.3 - function user_array_map( $a ){ return $a[0]; } - foreach ($users as $user) { if($user->user_email != $admin_email) { add_user_to_blog( $to_site_id, $user->ID, 'subscriber'); - // PHP >= 5.3 - //$all_meta = array_map( function( $a ){ return $a[0]; }, get_user_meta( $user->ID ) ); - // PHP < 5.3 $all_meta = array_map( 'user_array_map', get_user_meta( $user->ID ) ); foreach ($all_meta as $metakey => $metavalue) { $prefix = substr($metakey, 0, $from_site_prefix_length); if($prefix==$from_site_prefix) { $raw_meta_name = substr($metakey,$from_site_prefix_length); + if($is_from_main_site) { + $parts = explode('_', $raw_meta_name, 2); + if (count($parts) > 1 && in_array($parts[0], $all_sites_ids)) { + continue; + } + } update_user_meta( $user->ID, $to_site_prefix . $raw_meta_name, maybe_unserialize($metavalue) ); } } From 31d4809d33b7a03e7ea0b7affc770bf26898e30d Mon Sep 17 00:00:00 2001 From: David DAUGREILH Date: Fri, 11 May 2018 14:31:25 +0200 Subject: [PATCH 3/7] Bugfix - Allow point in unix path --- lib/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/functions.php b/lib/functions.php index 05f5baf..90426b3 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -27,7 +27,7 @@ public static function valid_windows_dir_path($path) { * @return boolean true | false */ public static function valid_unix_dir_path($path) { - $reg = "/^(\/([a-z0-9+\$_-])+)*\/?$/"; + $reg = "/^(\/([a-z0-9+\$_.-])+)*\/?$/"; $bool = preg_match($reg,$path); return ($bool == 1); } From 67cb75e97b75a850b879584580bd9944ba5258ea Mon Sep 17 00:00:00 2001 From: David DAUGREILH Date: Mon, 14 May 2018 17:42:47 +0200 Subject: [PATCH 4/7] Update Readme & header PHP --- README.md | 9 +++++++-- multisite-clone-duplicator.php | 4 ++-- readme.txt | 9 +++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 91734a5..f9b05b2 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ * Contributors: pdargham, julienog, daviddaug, globalis * Tags: duplicate, clone, copy, duplication, duplicator, factory, multisite, site, blog, network, wpmu, new blog * Requires at least: 4.0.0 -* Tested up to: 4.7.1 -* Stable tag: 1.4.1 +* Tested up to: 4.9.5 +* Stable tag: 1.5.0 * License: GPLv2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -95,6 +95,11 @@ Screenshots on ## Changelog +### 1.5.0 +* Fix duplicating exponentially usermeta +* Fix unix WP path validation and allow points +* Remove cache fushing on error + ### 1.4.1 * Fix wp_cli activation diff --git a/multisite-clone-duplicator.php b/multisite-clone-duplicator.php index 52ec6af..6409a33 100644 --- a/multisite-clone-duplicator.php +++ b/multisite-clone-duplicator.php @@ -6,9 +6,9 @@ * Author: Julien OGER, Pierre DARGHAM, David DAUGREILH, GLOBALIS media systems * Author URI: https://github.com/pierre-dargham/multisite-clone-duplicator * - * Version: 1.4.1 + * Version: 1.5.0 * Requires at least: 4.0.0 - * Tested up to: 4.7.1 + * Tested up to: 4.9.5 * * Network: true */ diff --git a/readme.txt b/readme.txt index e4d4fc2..957af4e 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: pdargham, julienog, daviddaug, globalis Tags: duplicate, clone, copy, duplication, duplicator, factory, multisite, site, blog, network, wpmu, new blog Requires at least: 4.0.0 -Tested up to: 4.7.1 -Stable tag: 1.4.1 +Tested up to: 4.9.5 +Stable tag: 1.5.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -93,6 +93,11 @@ As of now, following languages are supported : English (en_US), French (fr_FR), == Changelog == += 1.5.0 = +* Fix duplicating exponentially usermeta +* Fix unix WP path validation and allow points +* Remove cache fushing on error + = 1.4.1 = * Fix wp_cli activation From f91ec5553e97facce2488cb2a4e328014f4ae0df Mon Sep 17 00:00:00 2001 From: David DAUGREILH Date: Mon, 14 May 2018 17:59:58 +0200 Subject: [PATCH 5/7] Update Readme & header PHP --- README.md | 9 +++++++-- multisite-clone-duplicator.php | 6 +++--- readme.txt | 9 +++++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 91734a5..f9b05b2 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ * Contributors: pdargham, julienog, daviddaug, globalis * Tags: duplicate, clone, copy, duplication, duplicator, factory, multisite, site, blog, network, wpmu, new blog * Requires at least: 4.0.0 -* Tested up to: 4.7.1 -* Stable tag: 1.4.1 +* Tested up to: 4.9.5 +* Stable tag: 1.5.0 * License: GPLv2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -95,6 +95,11 @@ Screenshots on ## Changelog +### 1.5.0 +* Fix duplicating exponentially usermeta +* Fix unix WP path validation and allow points +* Remove cache fushing on error + ### 1.4.1 * Fix wp_cli activation diff --git a/multisite-clone-duplicator.php b/multisite-clone-duplicator.php index 52ec6af..6ee49ae 100644 --- a/multisite-clone-duplicator.php +++ b/multisite-clone-duplicator.php @@ -6,9 +6,9 @@ * Author: Julien OGER, Pierre DARGHAM, David DAUGREILH, GLOBALIS media systems * Author URI: https://github.com/pierre-dargham/multisite-clone-duplicator * - * Version: 1.4.1 + * Version: 1.5.0 * Requires at least: 4.0.0 - * Tested up to: 4.7.1 + * Tested up to: 4.9.5 * * Network: true */ @@ -53,7 +53,7 @@ class MUCD { /** * Plugin's version number */ - const VERSION = '1.4.1'; + const VERSION = '1.5.0'; /** * Register hooks used by the plugin diff --git a/readme.txt b/readme.txt index e4d4fc2..957af4e 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: pdargham, julienog, daviddaug, globalis Tags: duplicate, clone, copy, duplication, duplicator, factory, multisite, site, blog, network, wpmu, new blog Requires at least: 4.0.0 -Tested up to: 4.7.1 -Stable tag: 1.4.1 +Tested up to: 4.9.5 +Stable tag: 1.5.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -93,6 +93,11 @@ As of now, following languages are supported : English (en_US), French (fr_FR), == Changelog == += 1.5.0 = +* Fix duplicating exponentially usermeta +* Fix unix WP path validation and allow points +* Remove cache fushing on error + = 1.4.1 = * Fix wp_cli activation From 58884bbb6b1a5c39765d95ca8cb8d7185376e97f Mon Sep 17 00:00:00 2001 From: David DAUGREILH Date: Tue, 15 May 2018 15:56:19 +0200 Subject: [PATCH 6/7] Fix Readme changelog --- README.md | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f9b05b2..d3222d5 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ Screenshots on ### 1.5.0 * Fix duplicating exponentially usermeta * Fix unix WP path validation and allow points -* Remove cache fushing on error +* Remove cache flushing on error ### 1.4.1 * Fix wp_cli activation diff --git a/readme.txt b/readme.txt index 957af4e..193b53a 100644 --- a/readme.txt +++ b/readme.txt @@ -96,7 +96,7 @@ As of now, following languages are supported : English (en_US), French (fr_FR), = 1.5.0 = * Fix duplicating exponentially usermeta * Fix unix WP path validation and allow points -* Remove cache fushing on error +* Remove cache flushing on error = 1.4.1 = * Fix wp_cli activation From 21d70694c2d705b671e28bccf34d479cf5fdd3c6 Mon Sep 17 00:00:00 2001 From: David DAUGREILH Date: Tue, 15 May 2018 16:00:45 +0200 Subject: [PATCH 7/7] Change github author url from header PHP --- multisite-clone-duplicator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multisite-clone-duplicator.php b/multisite-clone-duplicator.php index 6ee49ae..e94402b 100644 --- a/multisite-clone-duplicator.php +++ b/multisite-clone-duplicator.php @@ -4,7 +4,7 @@ * Plugin URI: http://wordpress.org/plugins/multisite-clone-duplicator/ * Description: Clones an existing site into a new one in a multisite installation : copies all the posts, settings and files * Author: Julien OGER, Pierre DARGHAM, David DAUGREILH, GLOBALIS media systems - * Author URI: https://github.com/pierre-dargham/multisite-clone-duplicator + * Author URI: https://github.com/globalis-ms/multisite-clone-duplicator * * Version: 1.5.0 * Requires at least: 4.0.0