Version Description
- HotFix: Prefix hotfix failed
Download this release
Release Info
Developer | ReneHermi |
Plugin | WP Staging – DB & File Duplicator & Migration |
Version | 2.7.1 |
Comparing to | |
See all releases |
Code changes from version 2.7.0 to 2.7.1
- Backend/Modules/Jobs/Data.php +24 -18
- Backend/Modules/Jobs/Multisite/Data.php +47 -37
- readme.txt +4 -1
- wp-staging.php +2 -2
Backend/Modules/Jobs/Data.php
CHANGED
@@ -542,7 +542,7 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
542 |
}
|
543 |
|
544 |
/**
|
545 |
-
* Reset index.php to
|
546 |
* This is needed if live site is located in subfolder
|
547 |
* Check first if main wordpress is used in subfolder and index.php in parent directory
|
548 |
* @see: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
|
@@ -551,42 +551,48 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
551 |
protected function step6()
|
552 |
{
|
553 |
|
|
|
|
|
554 |
if (!$this->isSubDir()) {
|
555 |
-
$this->
|
556 |
return true;
|
557 |
}
|
558 |
|
|
|
|
|
559 |
$path = $this->options->destinationDir . "index.php";
|
560 |
|
561 |
if (false === ($content = file_get_contents($path))) {
|
562 |
-
$this->log(
|
563 |
return false;
|
564 |
}
|
565 |
|
|
|
|
|
|
|
|
|
|
|
566 |
|
567 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
$this->log(
|
569 |
-
|
570 |
);
|
571 |
return false;
|
572 |
}
|
573 |
-
$this->log("Preparing Data: WP installation is in a subdirectory. Progressing...");
|
574 |
-
|
575 |
-
$pattern = "/require(.*) dirname(.*) __FILE__ (.*) \. '(.*)wp-blog-header.php'(.*);.*/";
|
576 |
-
|
577 |
-
$replace = "require( dirname( __FILE__ ) . '/wp-blog-header.php' ); // " . $matches[0] . " Changed by WP-Staging";
|
578 |
-
|
579 |
-
|
580 |
-
if (null === ($content = preg_replace(array($pattern), $replace, $content))) {
|
581 |
-
$this->log("Preparing Data: Failed to reset index.php for sub directory; replacement failed", Logger::TYPE_ERROR);
|
582 |
-
return false;
|
583 |
-
}
|
584 |
|
585 |
if (false === @wpstg_put_contents($path, $content)) {
|
586 |
-
$this->log(
|
587 |
return false;
|
588 |
}
|
589 |
-
|
|
|
590 |
return true;
|
591 |
}
|
592 |
|
542 |
}
|
543 |
|
544 |
/**
|
545 |
+
* Reset index.php to WordPress default
|
546 |
* This is needed if live site is located in subfolder
|
547 |
* Check first if main wordpress is used in subfolder and index.php in parent directory
|
548 |
* @see: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
|
551 |
protected function step6()
|
552 |
{
|
553 |
|
554 |
+
$step = "Preparing Data Step6: ";
|
555 |
+
|
556 |
if (!$this->isSubDir()) {
|
557 |
+
$this->log($step . "WP installation is not in a subdirectory! Skipping this step");
|
558 |
return true;
|
559 |
}
|
560 |
|
561 |
+
$this->log($step . "WP installation is in a subdirectory");
|
562 |
+
|
563 |
$path = $this->options->destinationDir . "index.php";
|
564 |
|
565 |
if (false === ($content = file_get_contents($path))) {
|
566 |
+
$this->log($step . ": Failed to reset {$path}. Error: Can't read contents", Logger::TYPE_ERROR);
|
567 |
return false;
|
568 |
}
|
569 |
|
570 |
+
/*
|
571 |
+
* Before WordPress 5.4: require( dirname( __FILE__ ) . '/wp-blog-header.php' );
|
572 |
+
* Since WordPress 5.4: require __DIR__ . '/wp-blog-header.php';
|
573 |
+
*/
|
574 |
+
$pattern = "/require(.*)wp-blog-header.php(.*)/";
|
575 |
|
576 |
+
if (preg_match($pattern, $content, $matches)) {
|
577 |
+
$replace = "require __DIR__ . '/wp-blog-header.php'; // " . $matches[0] . " Changed by WP-Staging";
|
578 |
+
|
579 |
+
if (null === ($content = preg_replace(array($pattern), $replace, $content))) {
|
580 |
+
$this->log($step . "Failed to reset index.php for sub directory; replacement failed", Logger::TYPE_ERROR);
|
581 |
+
return false;
|
582 |
+
}
|
583 |
+
} else {
|
584 |
$this->log(
|
585 |
+
$step . "Failed to reset index.php for sub directory. Can not find code 'require(.*)wp-blog-header.php' or require __DIR__ . '/wp-blog-header.php'; in index.php", Logger::TYPE_ERROR
|
586 |
);
|
587 |
return false;
|
588 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
|
590 |
if (false === @wpstg_put_contents($path, $content)) {
|
591 |
+
$this->log($step . "Failed to reset index.php for sub directory; can't save contents", Logger::TYPE_ERROR);
|
592 |
return false;
|
593 |
}
|
594 |
+
|
595 |
+
$this->Log($step . "Finished successfully");
|
596 |
return true;
|
597 |
}
|
598 |
|
Backend/Modules/Jobs/Multisite/Data.php
CHANGED
@@ -9,8 +9,6 @@ if (!defined("WPINC")) {
|
|
9 |
|
10 |
use WPStaging\Utils\Logger;
|
11 |
use WPStaging\WPStaging;
|
12 |
-
use WPStaging\Utils\Helper;
|
13 |
-
use WPStaging\Utils\Multisite;
|
14 |
use WPStaging\Utils\Strings;
|
15 |
use WPStaging\Backend\Modules\Jobs\JobExecutable;
|
16 |
|
@@ -558,7 +556,7 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
558 |
}
|
559 |
|
560 |
/**
|
561 |
-
* Reset index.php to
|
562 |
* This is needed if live site is located in subfolder
|
563 |
* Check first if main wordpress is used in subfolder and index.php in parent directory
|
564 |
* @see: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
|
@@ -567,43 +565,48 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
567 |
protected function step6()
|
568 |
{
|
569 |
|
|
|
|
|
570 |
if (!$this->isSubDir()) {
|
571 |
-
$this->debugLog(
|
572 |
return true;
|
573 |
}
|
574 |
|
|
|
|
|
575 |
$path = $this->options->destinationDir . "index.php";
|
576 |
|
577 |
if (false === ($content = file_get_contents($path))) {
|
578 |
-
$this->log(
|
579 |
return false;
|
580 |
}
|
581 |
|
|
|
|
|
|
|
|
|
|
|
582 |
|
583 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
584 |
$this->log(
|
585 |
-
|
586 |
);
|
587 |
return false;
|
588 |
}
|
589 |
-
$this->log("Preparing Data: WP installation is in a subdirectory. Progressing...");
|
590 |
-
|
591 |
-
$pattern = "/require(.*) dirname(.*) __FILE__ (.*) \. '(.*)wp-blog-header.php'(.*);.*/";
|
592 |
-
|
593 |
-
$replace = "require( dirname( __FILE__ ) . '/wp-blog-header.php' ); // " . $matches[0];
|
594 |
-
//$replace .= " // Changed by WP-Staging";
|
595 |
-
|
596 |
-
|
597 |
-
if (null === ($content = preg_replace(array($pattern), $replace, $content))) {
|
598 |
-
$this->log("Preparing Data: Failed to reset index.php for sub directory; replacement failed", Logger::TYPE_ERROR);
|
599 |
-
return false;
|
600 |
-
}
|
601 |
|
602 |
if (false === @wpstg_put_contents($path, $content)) {
|
603 |
-
$this->log(
|
604 |
return false;
|
605 |
}
|
606 |
-
|
|
|
607 |
return true;
|
608 |
}
|
609 |
|
@@ -618,6 +621,7 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
618 |
|
619 |
// Skip - Table does not exist
|
620 |
if (false === $this->isTable($this->prefix . 'options')) {
|
|
|
621 |
return true;
|
622 |
}
|
623 |
|
@@ -633,6 +637,12 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
633 |
)
|
634 |
);
|
635 |
|
|
|
|
|
|
|
|
|
|
|
|
|
636 |
$this->Log("Preparing Data Step7: Finished successfully");
|
637 |
return true;
|
638 |
}
|
@@ -647,14 +657,14 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
647 |
$this->log("Preparing Data Step8: Updating permalink_structure in {$this->prefix}options {$this->db->last_error}");
|
648 |
|
649 |
// Keep Permalinks
|
650 |
-
if (isset($this->settings->keepPermalinks) && $this->settings->keepPermalinks
|
651 |
-
=== "1") {
|
652 |
$this->log("Preparing Data Step8: Skipping");
|
653 |
return true;
|
654 |
}
|
655 |
|
656 |
// Skip - Table does not exist
|
657 |
if (false === $this->isTable($this->prefix . 'options')) {
|
|
|
658 |
return true;
|
659 |
}
|
660 |
|
@@ -671,12 +681,12 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
671 |
);
|
672 |
|
673 |
// All good
|
674 |
-
if ($result) {
|
675 |
-
$this->
|
676 |
return true;
|
677 |
}
|
678 |
|
679 |
-
$this->
|
680 |
return true;
|
681 |
}
|
682 |
|
@@ -706,12 +716,12 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
706 |
);
|
707 |
|
708 |
// All good
|
709 |
-
if ($result) {
|
710 |
-
$this->
|
711 |
return true;
|
712 |
}
|
713 |
|
714 |
-
$this->
|
715 |
return true;
|
716 |
}
|
717 |
|
@@ -739,8 +749,8 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
739 |
|
740 |
$pattern = "/define\s*\(\s*['\"]WP_HOME['\"]\s*,\s*(.*)\s*\);.*/";
|
741 |
|
742 |
-
$replace = "define('WP_HOME','" . $this->getStagingSiteUrl() . "'); // " . $matches[1];
|
743 |
-
//$replace
|
744 |
|
745 |
if (null === ($content = preg_replace(array($pattern), $replace, $content))) {
|
746 |
$this->log("Preparing Data: Failed to update WP_HOME", Logger::TYPE_ERROR);
|
@@ -754,7 +764,7 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
754 |
$this->log("Preparing Data Step10: Failed to update WP_HOME. Can't save contents", Logger::TYPE_ERROR);
|
755 |
return false;
|
756 |
}
|
757 |
-
$this->Log("Preparing Data
|
758 |
return true;
|
759 |
}
|
760 |
|
@@ -782,11 +792,11 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
782 |
|
783 |
$pattern = "/define\s*\(\s*['\"]WP_SITEURL['\"]\s*,\s*(.*)\s*\);.*/";
|
784 |
|
785 |
-
$replace = "define('WP_SITEURL','" . $this->getStagingSiteUrl() . "'); // " . $matches[1];
|
786 |
-
//$replace
|
787 |
|
788 |
if (null === ($content = preg_replace(array($pattern), $replace, $content))) {
|
789 |
-
$this->log("Preparing Data Step11: Failed to update WP_SITEURL", Logger::TYPE_ERROR);
|
790 |
return false;
|
791 |
}
|
792 |
} else {
|
@@ -795,10 +805,10 @@ define( 'DB_COLLATE', '" . DB_COLLATE . "' );\r\n";
|
|
795 |
|
796 |
|
797 |
if (false === @wpstg_put_contents($path, $content)) {
|
798 |
-
$this->log("Preparing Data Step11: Failed to update WP_SITEURL. Can't save contents", Logger::TYPE_ERROR);
|
799 |
return false;
|
800 |
}
|
801 |
-
$this->Log("Preparing Data
|
802 |
return true;
|
803 |
}
|
804 |
|
9 |
|
10 |
use WPStaging\Utils\Logger;
|
11 |
use WPStaging\WPStaging;
|
|
|
|
|
12 |
use WPStaging\Utils\Strings;
|
13 |
use WPStaging\Backend\Modules\Jobs\JobExecutable;
|
14 |
|
556 |
}
|
557 |
|
558 |
/**
|
559 |
+
* Reset index.php to WordPress default
|
560 |
* This is needed if live site is located in subfolder
|
561 |
* Check first if main wordpress is used in subfolder and index.php in parent directory
|
562 |
* @see: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
|
565 |
protected function step6()
|
566 |
{
|
567 |
|
568 |
+
$step = "Preparing Data Step6: ";
|
569 |
+
|
570 |
if (!$this->isSubDir()) {
|
571 |
+
$this->debugLog($step . ": WP installation is not in a subdirectory! All good, skipping this step");
|
572 |
return true;
|
573 |
}
|
574 |
|
575 |
+
$this->log($step . "WP installation is in a subdirectory");
|
576 |
+
|
577 |
$path = $this->options->destinationDir . "index.php";
|
578 |
|
579 |
if (false === ($content = file_get_contents($path))) {
|
580 |
+
$this->log($step . ": Failed to reset {$path}. Error: Can't read contents", Logger::TYPE_ERROR);
|
581 |
return false;
|
582 |
}
|
583 |
|
584 |
+
/*
|
585 |
+
* Before WordPress 5.4: require( dirname( __FILE__ ) . '/wp-blog-header.php' );
|
586 |
+
* Since WordPress 5.4: require __DIR__ . '/wp-blog-header.php';
|
587 |
+
*/
|
588 |
+
$pattern = "/require(.*)wp-blog-header.php(.*)/";
|
589 |
|
590 |
+
if (preg_match($pattern, $content, $matches)) {
|
591 |
+
$replace = "require __DIR__ . '/wp-blog-header.php'; // " . $matches[0] . " Changed by WP-Staging";
|
592 |
+
|
593 |
+
if (null === ($content = preg_replace(array($pattern), $replace, $content))) {
|
594 |
+
$this->log($step . "Failed to reset index.php for sub directory; replacement failed", Logger::TYPE_ERROR);
|
595 |
+
return false;
|
596 |
+
}
|
597 |
+
} else {
|
598 |
$this->log(
|
599 |
+
$step . "Failed to reset index.php for sub directory. Can not find code 'require(.*)wp-blog-header.php' or require __DIR__ . '/wp-blog-header.php'; in index.php", Logger::TYPE_ERROR
|
600 |
);
|
601 |
return false;
|
602 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
603 |
|
604 |
if (false === @wpstg_put_contents($path, $content)) {
|
605 |
+
$this->log($step . "Failed to reset index.php for sub directory; can't save contents", Logger::TYPE_ERROR);
|
606 |
return false;
|
607 |
}
|
608 |
+
|
609 |
+
$this->Log($step . "Finished successfully");
|
610 |
return true;
|
611 |
}
|
612 |
|
621 |
|
622 |
// Skip - Table does not exist
|
623 |
if (false === $this->isTable($this->prefix . 'options')) {
|
624 |
+
$this->log("Preparing Data Step7: Skipping Table {$this->prefix}'options' does not exist");
|
625 |
return true;
|
626 |
}
|
627 |
|
637 |
)
|
638 |
);
|
639 |
|
640 |
+
// All good
|
641 |
+
if (false === $result) {
|
642 |
+
$this->log("Failed to update wpstg_rmpermalinks_executed in {$this->prefix}options {$this->db->last_error}", Logger::TYPE_WARNING);
|
643 |
+
return true;
|
644 |
+
}
|
645 |
+
|
646 |
$this->Log("Preparing Data Step7: Finished successfully");
|
647 |
return true;
|
648 |
}
|
657 |
$this->log("Preparing Data Step8: Updating permalink_structure in {$this->prefix}options {$this->db->last_error}");
|
658 |
|
659 |
// Keep Permalinks
|
660 |
+
if (isset($this->settings->keepPermalinks) && $this->settings->keepPermalinks === "1") {
|
|
|
661 |
$this->log("Preparing Data Step8: Skipping");
|
662 |
return true;
|
663 |
}
|
664 |
|
665 |
// Skip - Table does not exist
|
666 |
if (false === $this->isTable($this->prefix . 'options')) {
|
667 |
+
$this->log("Preparing Data Step8: Skipping");
|
668 |
return true;
|
669 |
}
|
670 |
|
681 |
);
|
682 |
|
683 |
// All good
|
684 |
+
if (false === $result) {
|
685 |
+
$this->log("Failed to update permalink_structure in {$this->prefix}options {$this->db->last_error}", Logger::TYPE_ERROR);
|
686 |
return true;
|
687 |
}
|
688 |
|
689 |
+
$this->Log("Preparing Data Step8: Finished successfully");
|
690 |
return true;
|
691 |
}
|
692 |
|
716 |
);
|
717 |
|
718 |
// All good
|
719 |
+
if (false === $result) {
|
720 |
+
$this->log("Can not update staging site to noindex. Possible already done!", Logger::TYPE_WARNING);
|
721 |
return true;
|
722 |
}
|
723 |
|
724 |
+
$this->Log("Preparing Data Step9: Finished successfully");
|
725 |
return true;
|
726 |
}
|
727 |
|
749 |
|
750 |
$pattern = "/define\s*\(\s*['\"]WP_HOME['\"]\s*,\s*(.*)\s*\);.*/";
|
751 |
|
752 |
+
$replace = "define('WP_HOME','" . $this->getStagingSiteUrl() . "'); // " . $matches[1] . " Changed by WP-Staging";
|
753 |
+
//$replace.= " // Changed by WP-Staging";
|
754 |
|
755 |
if (null === ($content = preg_replace(array($pattern), $replace, $content))) {
|
756 |
$this->log("Preparing Data: Failed to update WP_HOME", Logger::TYPE_ERROR);
|
764 |
$this->log("Preparing Data Step10: Failed to update WP_HOME. Can't save contents", Logger::TYPE_ERROR);
|
765 |
return false;
|
766 |
}
|
767 |
+
$this->Log("Preparing Data Step10: Finished successfully");
|
768 |
return true;
|
769 |
}
|
770 |
|
792 |
|
793 |
$pattern = "/define\s*\(\s*['\"]WP_SITEURL['\"]\s*,\s*(.*)\s*\);.*/";
|
794 |
|
795 |
+
$replace = "define('WP_SITEURL','" . $this->getStagingSiteUrl() . "'); // " . $matches[1] . " Changed by WP-Staging";
|
796 |
+
//$replace.= " // Changed by WP-Staging";
|
797 |
|
798 |
if (null === ($content = preg_replace(array($pattern), $replace, $content))) {
|
799 |
+
$this->log("Preparing Data Step11: Failed to update WP_SITEURL to " . $this->getStagingSiteUrl(), Logger::TYPE_ERROR);
|
800 |
return false;
|
801 |
}
|
802 |
} else {
|
805 |
|
806 |
|
807 |
if (false === @wpstg_put_contents($path, $content)) {
|
808 |
+
$this->log("Preparing Data Step11: Failed to update WP_SITEURL to " . $this->getStagingSiteUrl() . " Can't save contents", Logger::TYPE_ERROR);
|
809 |
return false;
|
810 |
}
|
811 |
+
$this->Log("Preparing Data Step11: Finished successfully");
|
812 |
return true;
|
813 |
}
|
814 |
|
readme.txt
CHANGED
@@ -9,7 +9,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
9 |
Tags: staging, duplication, cloning, clone, migration, sandbox, test site, testing, backup, post, admin, administration, duplicate posts
|
10 |
Requires at least: 3.6+
|
11 |
Tested up to: 5.3
|
12 |
-
Stable tag: 2.7.
|
13 |
Requires PHP: 5.3
|
14 |
|
15 |
A duplicator plugin - clone/move, duplicate & migrate live websites to independent staging and development sites that are accessible by authorized users only.
|
@@ -153,6 +153,9 @@ https://wp-staging.com
|
|
153 |
|
154 |
== Changelog ==
|
155 |
|
|
|
|
|
|
|
156 |
= 2.7.0 =
|
157 |
* HotFix: Fix fatal error in step 6 after updating to WordPress 5.4
|
158 |
|
9 |
Tags: staging, duplication, cloning, clone, migration, sandbox, test site, testing, backup, post, admin, administration, duplicate posts
|
10 |
Requires at least: 3.6+
|
11 |
Tested up to: 5.3
|
12 |
+
Stable tag: 2.7.1
|
13 |
Requires PHP: 5.3
|
14 |
|
15 |
A duplicator plugin - clone/move, duplicate & migrate live websites to independent staging and development sites that are accessible by authorized users only.
|
153 |
|
154 |
== Changelog ==
|
155 |
|
156 |
+
= 2.7.1 =
|
157 |
+
* HotFix: Prefix hotfix failed
|
158 |
+
|
159 |
= 2.7.0 =
|
160 |
* HotFix: Fix fatal error in step 6 after updating to WordPress 5.4
|
161 |
|
wp-staging.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* Author: WP-Staging
|
8 |
* Author URI: https://wp-staging.com
|
9 |
* Contributors: ReneHermi, ilgityildirim
|
10 |
-
* Version: 2.7.
|
11 |
* Text Domain: wp-staging
|
12 |
* Domain Path: /languages/
|
13 |
*
|
@@ -39,7 +39,7 @@ if (!defined('WPSTG_PLUGIN_SLUG')) {
|
|
39 |
|
40 |
// Plugin Version
|
41 |
if (!defined('WPSTG_VERSION')) {
|
42 |
-
define('WPSTG_VERSION', '2.7.
|
43 |
}
|
44 |
|
45 |
// Compatible up to WordPress Version
|
7 |
* Author: WP-Staging
|
8 |
* Author URI: https://wp-staging.com
|
9 |
* Contributors: ReneHermi, ilgityildirim
|
10 |
+
* Version: 2.7.1
|
11 |
* Text Domain: wp-staging
|
12 |
* Domain Path: /languages/
|
13 |
*
|
39 |
|
40 |
// Plugin Version
|
41 |
if (!defined('WPSTG_VERSION')) {
|
42 |
+
define('WPSTG_VERSION', '2.7.1');
|
43 |
}
|
44 |
|
45 |
// Compatible up to WordPress Version
|