From 573088a5e0b6397359e0c2eaca779f63118f11c6 Mon Sep 17 00:00:00 2001 From: Nichita Date: Sat, 7 Oct 2023 12:17:00 +0300 Subject: [PATCH 1/3] Fix: bagrinsergiu/blox-editor#23906 - changing the way of versioning compatibility check when importing the json block (update) --- editor/zip/archiver.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/editor/zip/archiver.php b/editor/zip/archiver.php index 992376bbe3..3b0cd398ab 100644 --- a/editor/zip/archiver.php +++ b/editor/zip/archiver.php @@ -20,17 +20,17 @@ class Brizy_Editor_Zip_Archiver implements Brizy_Editor_Zip_ArchiverInterface /** * @var string */ - protected $editorVersion; + protected $syncVersion; public function __construct( Brizy_Editor_Project $project, Brizy_Admin_Fonts_Manager $fontManager, - $editorVersion + $syncVersion ) { $this->project = $project; $this->fontManager = $fontManager; - $this->editorVersion = $editorVersion; + $this->syncVersion = $syncVersion; if (!class_exists('ZipArchive')) { throw new InvalidArgumentException(__('Please install/enable php zip extension. Contact your hosting company for more info and help.')); @@ -87,7 +87,7 @@ public function addEntityToZip(ZipArchive $z, Brizy_Editor_Zip_ArchiveItem $item 'meta' => $block->getMeta(), 'media' => $block->getMedia(), 'data' => $block->get_editor_data(), - 'editorVersion' => $block->get_editor_version(), + 'editorVersion' => $this->syncVersion, 'files' => [ 'images' => [], 'uploads' => [], @@ -223,12 +223,11 @@ private function createSingleFromZipPath(ZipArchive $z, $dir) public function getEditorVersion() { - return $this->editorVersion; + return $this->syncVersion; } public function isVersionSupported($version) { - $version = preg_replace("/-wp/i", "", $version); return version_compare($this->getEditorVersion(), $version, '>='); } From 0a6a25ea3e0739d610ed0d787b827b4b7dda7369 Mon Sep 17 00:00:00 2001 From: Nichita Date: Mon, 9 Oct 2023 10:55:35 +0300 Subject: [PATCH 2/3] Fix: bagrinsergiu/blox-editor#23906 - added and implemented a new function, and renamed several variables --- editor/zip/archiver-interface.php | 2 ++ editor/zip/archiver.php | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/editor/zip/archiver-interface.php b/editor/zip/archiver-interface.php index b7ec2e6feb..3b425fa629 100644 --- a/editor/zip/archiver-interface.php +++ b/editor/zip/archiver-interface.php @@ -8,6 +8,8 @@ public function createFromZip( $zipPath ); public function getEditorVersion(); + public function getSyncVersion(); + public function isVersionSupported($version); public function getScreenshotType($archiveType); diff --git a/editor/zip/archiver.php b/editor/zip/archiver.php index 3b0cd398ab..781f24e48e 100644 --- a/editor/zip/archiver.php +++ b/editor/zip/archiver.php @@ -221,14 +221,17 @@ private function createSingleFromZipPath(ZipArchive $z, $dir) return $block; } - public function getEditorVersion() - { - return $this->syncVersion; + public function getEditorVersion() {} + + public function getSyncVersion() { + return $this->syncVersion; } public function isVersionSupported($version) { - return version_compare($this->getEditorVersion(), $version, '>='); + $version = preg_replace("/-wp/i", "", $version); + $version = preg_replace("/-cloud/i", "", $version); + return version_compare($this->getSyncVersion(), $version, '>='); } protected function prepareArchiveFilepath($fileName) From b0d4b57c8de7f97e312c688bbd8d36d63f18426d Mon Sep 17 00:00:00 2001 From: Nichita Date: Mon, 9 Oct 2023 11:07:10 +0300 Subject: [PATCH 3/3] Fix: bagrinsergiu/blox-editor#23906 - deleted a function that is not used to not be implemented --- editor/zip/archiver-interface.php | 2 -- editor/zip/archiver.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/editor/zip/archiver-interface.php b/editor/zip/archiver-interface.php index 3b425fa629..d62eef844d 100644 --- a/editor/zip/archiver-interface.php +++ b/editor/zip/archiver-interface.php @@ -6,8 +6,6 @@ public function createZip( $posts, $fileName ); public function createFromZip( $zipPath ); - public function getEditorVersion(); - public function getSyncVersion(); public function isVersionSupported($version); diff --git a/editor/zip/archiver.php b/editor/zip/archiver.php index 781f24e48e..919e330e59 100644 --- a/editor/zip/archiver.php +++ b/editor/zip/archiver.php @@ -221,8 +221,6 @@ private function createSingleFromZipPath(ZipArchive $z, $dir) return $block; } - public function getEditorVersion() {} - public function getSyncVersion() { return $this->syncVersion; }