Revert "Move logic to preparing step"

This reverts commit 6bb8ed56d886b9ee4f697875b269a3755db2bff9.
This commit is contained in:
Julian Prieber 2024-12-09 16:33:55 +01:00
parent 6bf1863315
commit 2302dc1f1d
2 changed files with 64 additions and 63 deletions

View File

@ -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()]);
}
?>
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()]);
}
?>

View File

@ -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()]);
}