]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5873 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 20 Apr 2023 10:13:55 +0000 (12:13 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 20 Apr 2023 10:13:55 +0000 (12:13 +0200)
app/Console/Commands/WorkshopMigration.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php
app/Models/FluidbookPublication.php

index 6ace5fa13ca26da1d033df264917c6317d580dce..6660b4a70905f779ff2277a6c3dc457b0cf1d649 100644 (file)
@@ -33,9 +33,6 @@ class WorkshopMigration extends CubistCommand
 
     public function handle()
     {
-        $user = AuthUser::where('id', self::$_admin)->first();
-        backpack_auth()->login($user);
-
         $actions = [
             //'Backup current database' => 'backup',
             'Migrate magic models' => 'migrate',
@@ -53,7 +50,6 @@ class WorkshopMigration extends CubistCommand
         $this->line(' Data migration, please wait');
         $this->progressBar->start();
 
-
         foreach ($actions as $comment => $action) {
             $this->line($comment);
             $this->$action();
@@ -91,7 +87,7 @@ class WorkshopMigration extends CubistCommand
         $q = DB::table($this->_oldDB . '.documents')->orderBy('document_id', 'desc');
 
         if ($this->option('documents') === 'missing') {
-            $maxID = FluidbookDocument::where('id', '<', self::WS3_DOC_ID)->orderBy('id', 'DESC')->first()->id;
+            $maxID = FluidbookDocument::withoutGlobalScopes()->where('id', '<', self::WS3_DOC_ID)->orderBy('id', 'DESC')->first()->id;
             $q = DB::table($this->_oldDB . '.documents')->where('document_id', '>', $maxID)->orderBy('document_id', 'desc');
 
         } else if ($this->option('documents') === 'v2') {
@@ -100,7 +96,7 @@ class WorkshopMigration extends CubistCommand
             FluidbookDocument::truncate();
         } else {
             $range = ArrayUtil::parseRange($this->option('documents'));
-            FluidbookDocument::whereIn('id', $range)->delete();
+            FluidbookDocument::withoutGlobalScopes()->whereIn('id', $range)->delete();
             $q->whereIn('document_id', $range);
         }
 
@@ -211,7 +207,7 @@ class WorkshopMigration extends CubistCommand
             FluidbookPublication::truncate();
         } else {
             $range = ArrayUtil::parseRange($this->option('publications'));
-            FluidbookPublication::whereIn('id', $range)->delete();
+            FluidbookPublication::withoutGlobalScopes()->whereIn('id', $range)->delete();
             $q->whereIn('book_id', $range);
         }
 
index 28defeb52d37c5e5c78dd2ff87dd84f4344d045b..bd729627ea19df837da863df35c63d591f5732a0 100644 (file)
@@ -34,7 +34,7 @@ trait CompositionOperation
     {
 
         /** @var FluidbookDocument $doc */
-        $doc = FluidbookDocument::find($doc_id);
+        $doc = FluidbookDocument::withoutGlobalScopes()->find($doc_id);
         $path = $doc->getFile($doc_page, 'jpg', 'thumb', true, true, '');
         if (filesize($path) === 0) {
             for ($i = 1; $i <= 8; $i++) {
index e05f3e2c456dbf662392ee528b332fac3acfda23..911ecf057232e7b1aced56762b179085a27fe03a 100644 (file)
@@ -512,7 +512,15 @@ class FluidbookPublication extends ToolboxSettingsModel
             $l10n = FluidbookTranslate::getCompiledTranslations();
         }
         $res = $l10n[$defaultLocale];
+
         if ($this->translations) {
+            if(is_string($this->translations)) {
+                if (Json::isJson($this->translations)) {
+                    $this->translations = json_decode($this->translations);
+                }else{
+                    $this->translations=[];
+                }
+            }
             foreach ($this->translations as $k => $v) {
                 $res[$k] = $v;
             }