From 8ff1c5a83b9cde083cf1faaadc53229fe552c181 Mon Sep 17 00:00:00 2001
From: Florian Bogner <f.bogner@pcsg.de>
Date: Fri, 15 Sep 2017 14:56:37 +0200
Subject: [PATCH] fix: Added temporary fix for updating systems

---
 src/QUI/Ckeditor/EventHandler.php    | 25 +++++++++++++++++++++++++
 src/QUI/Ckeditor/Plugins/Manager.php |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/QUI/Ckeditor/EventHandler.php b/src/QUI/Ckeditor/EventHandler.php
index b87c62a..d2db7f2 100644
--- a/src/QUI/Ckeditor/EventHandler.php
+++ b/src/QUI/Ckeditor/EventHandler.php
@@ -8,6 +8,7 @@ namespace QUI\Ckeditor;
 
 use QUI\Ckeditor\Plugins\Manager;
 use QUI\Package\Package;
+use QUI\Utils\System\File;
 
 /**
  * Class EventHandler
@@ -26,6 +27,30 @@ class EventHandler
         }
 
         $PluginManager = new Manager();
+
+        // ----- Begin tempfix -----
+        // This is a temporary fix for updating the systems
+        // there was a bug in the utils package which compromised the update process of the ckeditor, thus rendering the ckeditor useless
+        echo "Checking: " . VAR_DIR . "package/quiqqer/ckeditor4/plugins/bin/image/dialogs/image.js" . PHP_EOL;
+        if (!file_exists(VAR_DIR . "package/quiqqer/ckeditor4/plugins/bin/image/dialogs/image.js")) {
+            echo "Does not exist!" . PHP_EOL;
+
+//            File::deleteDir(VAR_DIR . "package/quiqqer/ckeditor4/plugins");
+            $newFolder = VAR_DIR . "package/quiqqer/ckeditor4/plugins." . time() . ".bak";
+            rename(
+                VAR_DIR . "package/quiqqer/ckeditor4/plugins",
+                $newFolder
+            );
+
+            file_put_contents(
+                $newFolder . "/README.md",
+                "This directory was created as backup. If your ckeditor is working as intended you can delete this directory if you do not need it anymore"
+            );
+        }
+
+        // ----- End tempfix -----
+
+
         $PluginManager->installPluginsFromSource();
     }
 
diff --git a/src/QUI/Ckeditor/Plugins/Manager.php b/src/QUI/Ckeditor/Plugins/Manager.php
index e6377e9..607d6b0 100644
--- a/src/QUI/Ckeditor/Plugins/Manager.php
+++ b/src/QUI/Ckeditor/Plugins/Manager.php
@@ -591,7 +591,7 @@ class Manager
     public function copyDir($src, $target)
     {
         if (!is_dir($target)) {
-            mkdir($target, 0755);
+            mkdir($target, 0755, true);
         }
 
         $entries = scandir($src);
-- 
GitLab