From 2302dc1f1d807dd044b5439d54dfe43abd28665f Mon Sep 17 00:00:00 2001 From: Julian Prieber Date: Mon, 9 Dec 2024 16:33:55 +0100 Subject: [PATCH] Revert "Move logic to preparing step" This reverts commit 6bb8ed56d886b9ee4f697875b269a3755db2bff9. --- .../views/components/finishing.blade.php | 65 ++++++++++++++++++- .../views/components/pre-update.blade.php | 62 ------------------ 2 files changed, 64 insertions(+), 63 deletions(-) diff --git a/resources/views/components/finishing.blade.php b/resources/views/components/finishing.blade.php index 975f1ac..c8938a2 100644 --- a/resources/views/components/finishing.blade.php +++ b/resources/views/components/finishing.blade.php @@ -7,6 +7,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; use Database\Seeders\ButtonSeeder; use App\Models\Page; +use App\Models\Link; set_time_limit(0); @@ -429,4 +430,66 @@ try { session(['update_error' => $e->getMessage()]); } -?> \ No newline at end of file +try { + + $links = Link::where('button_id', 94)->get()->groupBy('user_id'); + + foreach ($links as $userId => $userLinks) { + $hasXTwitter = $userLinks->contains('title', 'x-twitter'); + + foreach ($userLinks as $link) { + if ($link->title == 'twitter') { + if ($hasXTwitter) { + $link->delete(); + } else { + $link->title = 'x-twitter'; + $link->save(); + $hasXTwitter = true; + } + } + } + } + +} catch (exception $e) { +session(['update_error' => $e->getMessage()]); +} + +try { + + $themesPath = base_path('themes'); + $regex = '/[0-9.-]/'; + $files = scandir($themesPath); + $files = array_diff($files, array('.', '..')); + + $themeError = 'The update was successful. Your theme-filesystem was detected as corrupted and has been reset.'; + + foreach ($files as $file) { + + $basename = basename($file); + $filePath = $themesPath . '/' . $basename; + + if (!is_dir($filePath)) { + + File::deleteDirectory($themesPath); + mkdir($themesPath); + session(['update_error' => $themeError]); + break; + + } + + if (preg_match($regex, $basename)) { + + $newBasename = preg_replace($regex, '', $basename); + $newPath = $themesPath . '/' . $newBasename; + File::copyDirectory($filePath, $newPath); + File::deleteDirectory($filePath); + + } + + } + +} catch (exception $e) { + session(['update_error' => $e->getMessage()]); +} + +?> diff --git a/resources/views/components/pre-update.blade.php b/resources/views/components/pre-update.blade.php index 51ee560..bf0bfba 100644 --- a/resources/views/components/pre-update.blade.php +++ b/resources/views/components/pre-update.blade.php @@ -80,66 +80,4 @@ if (!Schema::hasColumn('links', 'type_params')) { $link->save(); } } -} - -try { - - $links = Link::where('button_id', 94)->get()->groupBy('user_id'); - - foreach ($links as $userId => $userLinks) { - $hasXTwitter = $userLinks->contains('title', 'x-twitter'); - - foreach ($userLinks as $link) { - if ($link->title == 'twitter') { - if ($hasXTwitter) { - $link->delete(); - } else { - $link->title = 'x-twitter'; - $link->save(); - $hasXTwitter = true; - } - } - } - } - -} catch (exception $e) { - session(['update_error' => $e->getMessage()]); -} - -try { - - $themesPath = base_path('themes'); - $regex = '/[0-9.-]/'; - $files = scandir($themesPath); - $files = array_diff($files, array('.', '..')); - - $themeError = 'Your theme-filesystem was detected as corrupted and has been reset. Rerun the updater to complete the update.'; - - foreach ($files as $file) { - - $basename = basename($file); - $filePath = $themesPath . '/' . $basename; - - if (!is_dir($filePath)) { - - File::deleteDirectory($themesPath); - mkdir($themesPath); - session(['update_error' => $themeError]); - break; - - } - - if (preg_match($regex, $basename)) { - - $newBasename = preg_replace($regex, '', $basename); - $newPath = $themesPath . '/' . $newBasename; - File::copyDirectory($filePath, $newPath); - File::deleteDirectory($filePath); - - } - - } - -} catch (exception $e) { - session(['update_error' => $e->getMessage()]); } \ No newline at end of file