Youfront / statamic-export

MIT License
3 stars 3 forks source link

Array to string conversion error #2

Open freshface opened 3 years ago

freshface commented 3 years ago

Hi

Got the following error in the plugin. Working whith Statamic v3.0.40


[2021-02-03 14:59:58] local.ERROR: Array to string conversion {"userId":"7f4d8694-0a90-4265-8158-f305cf70887d","exception":"[object] (ErrorException(code: 0): Array to string conversion at /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/league/csv/src/Stream.php:311)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Array to string...', '/Users/frederik...', 311, Array)
#1 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/league/csv/src/Stream.php(311): fputcsv(Resource id #311, Array, ',', '\"', '\\\\')
#2 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/league/csv/src/Writer.php(166): League\\Csv\\Stream->fputcsv(Array, ',', '\"', '\\\\')
#3 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/league/csv/src/Writer.php(149): League\\Csv\\Writer->addRecord(Array)
#4 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/league/csv/src/Writer.php(123): League\\Csv\\Writer->insertOne(Array)
#5 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/youfront/statamic-export/src/Export.php(29): League\\Csv\\Writer->insertAll(Array)
#6 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/statamic/cms/src/Http/Controllers/CP/ActionController.php(40): Youfront\\Export\\Export->download(Object(Illuminate\\Support\\Collection), Array)
#7 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): Statamic\\Http\\Controllers\\CP\\ActionController->run(Object(Illuminate\\Http\\Request), Object(Statamic\\Entries\\Collection))
#8 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('run', Array)
#9 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Routing/Route.php(239): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Statamic\\Http\\Controllers\\CP\\Collections\\EntryActionController), 'run')
#10 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Routing/Route.php(196): Illuminate\\Routing\\Route->runController()
#11 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Routing/Router.php(685): Illuminate\\Routing\\Route->run()
#12 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#13 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/statamic/cms/src/Http/Middleware/CP/CountUsers.php(18): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#14 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\CP\\CountUsers->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#15 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/statamic/cms/src/Http/Middleware/CP/Localize.php(16): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#16 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\CP\\Localize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#17 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/statamic/cms/src/Http/Middleware/CP/Authorize.php(25): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\CP\\Authorize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#19 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/statamic/cms/src/Http/Middleware/CP/ContactOutpost.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#20 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\CP\\ContactOutpost->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#21 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/statamic/cms/src/Http/Middleware/CP/ControlPanel.php(16): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#22 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\CP\\ControlPanel->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#27 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#28 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest(Object(Illuminate\\Http\\Request), Object(Illuminate\\Session\\Store), Object(Closure))
#31 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#32 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#33 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#34 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#35 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#36 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/statamic/cms/src/Http/Middleware/SwapExceptionHandler.php(19): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#37 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\SwapExceptionHandler->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#38 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#39 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Routing/Router.php(687): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#40 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#41 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Routing/Router.php(628): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#42 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Routing/Router.php(617): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#43 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(165): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#44 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#45 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/statamic/cms/src/Http/Middleware/CheckMultisite.php(14): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#46 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\CheckMultisite->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#47 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/statamic/cms/src/Http/Middleware/PoweredByHeader.php(19): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#48 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Statamic\\Http\\Middleware\\PoweredByHeader->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#49 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(60): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#50 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#51 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#52 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#53 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#54 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#55 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#56 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#57 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#58 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#59 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/fruitcake/laravel-cors/src/HandleCors.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#60 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#61 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#62 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#63 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#64 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#65 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#66 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/www/index.php(60): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#67 /Users/frederikheyninck/Figure8/mamp/trevi-env/website/server.php(21): require_once('/Users/frederik...')
#68 {main}
"} 
freshface commented 3 years ago

Update:

This is the data L:29 on ->insertAll() is using:

array:3 [
  0 => array:5 [
    "title" => "Nederlandse versie"
    "updated_by" => "7f4d8694-0a90-4265-8158-f305cf70887d"
    "updated_at" => 1612357967
    "omschrijving" => null
    "logo" => null
  ]
  1 => array:5 [
    "title" => "Naam van de erkinning"
    "updated_by" => "7f4d8694-0a90-4265-8158-f305cf70887d"
    "updated_at" => 1612357804
    "omschrijving" => array:1 [
      0 => array:2 [
        "type" => "paragraph"
        "content" => array:1 [
          0 => array:2 [
            "type" => "text"
            "text" => "Omschrijving"
          ]
        ]
      ]
    ]
    "logo" => "erkenningen/afbeeldingen/20191117-mdb-215e2ad1b2ee6b5.jpg"
  ]
  2 => array:5 [
    "title" => "Titel erkenning"
    "updated_by" => "7f4d8694-0a90-4265-8158-f305cf70887d"
    "updated_at" => 1612353637
    "omschrijving" => array:1 [
      0 => array:2 [
        "type" => "paragraph"
        "content" => array:1 [
          0 => array:2 [
            "type" => "text"
            "text" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas faucibus mollis interdum. Maecenas sed diam eget risus varius blandit sit amet non magna. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Curabitur blandit tempus porttitor."
          ]
        ]
      ]
    ]
    "logo" => null
  ]
]
andershagbard commented 3 years ago

Makes sense. I am not sure how to represent an array in CSV format. Do you have any ideas?

My idea right now, would be to omit arrays from the export.

freshface commented 3 years ago

Hi, As a comma seperated string? So we can handle linked taxonomies?

freshface commented 3 years ago

Hi, Wondering if you had time to look at this :)

Hesesses commented 3 years ago

Hello, i'm having the same problem.

I have a product and the product has linked reviews... i would like to export all products with reviews