duncanmcclean / simple-commerce

A simple, yet powerful e-commerce addon for Statamic.
https://statamic.com/simple-commerce
Other
143 stars 34 forks source link

Array to string conversion on Runway's BaseFieldtype.php #1016

Closed Web10-Joris closed 4 months ago

Web10-Joris commented 5 months ago

Description

Hi Duncan, I recently updated again to the most recent versions of Runway & SC, but facing this error (stacktrace below) now on a cart update action when I fill in all the billing/shipping details.

I'm not sure if this error is more related to Runway, but the origin is Simple Commerce. Let me know if you need more information or tests to debug more.

This was the post body for the {{ sc:cart:update }} form send using axios:

_token: hvfGQp4KRRZU0MlecLfGzxQXZ5YeNHyDv68CwXDa
_redirect: eyJpdiI6InRuMkZ2d0RoK3lYS2dmcGZTWmpVU3c9PSIsInZhbHVlIjoiSkcwY3ZKZjNRRUF2SWdLckdVME5ZQU4za3FXaFF2c1FLSkJmTUxPSkNoTWpjR2FudTZiMi9TUGFBUk1sNi9PMCIsIm1hYyI6IjkxMjk0NzQwZGQzNTBiYWFlNjBhNzlkZjVlYzdlNzQ2NmM5Yzk1ZjVmOGE5ZTFmOTU4ODlkZDE0NjliYTY5MzIiLCJ0YWciOiIifQ==
_error_redirect: eyJpdiI6ImJGSDJIZ1RoQzhPNDRsOXpzaTZUTHc9PSIsInZhbHVlIjoiT0t5Z29iQW1jRlM4aFU3UURZc3Zha2o3eHBWUXdXME5KTExEZkdkbVoraz0iLCJtYWMiOiIxZTM0YjY4ZjZiOGU0NjJlNzI2NWI1ZmMwNDQ2YTI4YjQwYmFmYzVkMGI3NmY4NjcwZWJlZmNiNWQ3YzAyNzZhIiwidGFnIjoiIn0=
_request: eyJpdiI6IlZDQ0g1eVBXMXFhQ2x5ZVdCTWlRY2c9PSIsInZhbHVlIjoiV24vUCtEZVlMc3dwdDVGdUdDRktJUT09IiwibWFjIjoiMzBlMGJhZWIyNDU1NjE3MmE2MGJkODkzNTY3MjkyZDJjZTljY2NiOTdmZmIwMzFmZDVjMzNlYzI1NzQzZmM1MCIsInRhZyI6IiJ9
name: Name
shipping_company: Company name
email: email@test.com
phone: +123456789
shipping_name: Name
shipping_address: Street 100
shipping_address_line2: 
shipping_city: City
shipping_postal_code: 1234DD
shipping_country: DE
shipping_region: de-be
use_shipping_address_for_billing: 
_token: hvfGQp4KRRZU0MlecLfGzxQXZ5YeNHyDv68CwXDa

Full stacktrace:

[2024-02-16 17:46:34] local.ERROR: Array to string conversion {"exception":"[object] (ErrorException(code: 0): Array to string conversion at /var/www/html/vendor/statamic-rad-pack/runway/src/Fieldtypes/BaseFieldtype.php:221)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(255): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /var/www/html/vendor/statamic-rad-pack/runway/src/Fieldtypes/BaseFieldtype.php(221): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}()
#2 [internal function]: StatamicRadPack\\Runway\\Fieldtypes\\BaseFieldtype->StatamicRadPack\\Runway\\Fieldtypes\\{closure}()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(588): array_map()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(777): Illuminate\\Support\\Arr::map()
#5 /var/www/html/vendor/statamic-rad-pack/runway/src/Fieldtypes/BaseFieldtype.php(217): Illuminate\\Support\\Collection->map()
#6 /var/www/html/vendor/statamic-rad-pack/runway/src/Fieldtypes/BaseFieldtype.php(186): StatamicRadPack\\Runway\\Fieldtypes\\BaseFieldtype->getAugmentableModels()
#7 /var/www/html/vendor/statamic/cms/src/Fields/Value.php(48): StatamicRadPack\\Runway\\Fieldtypes\\BaseFieldtype->augment()
#8 /var/www/html/vendor/statamic/cms/src/Fields/Value.php(61): Statamic\\Fields\\Value->value()
#9 [internal function]: Statamic\\Fields\\Value->jsonSerialize()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php(84): json_encode()
#11 /var/www/html/vendor/symfony/http-foundation/JsonResponse.php(49): Illuminate\\Http\\JsonResponse->setData()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php(32): Symfony\\Component\\HttpFoundation\\JsonResponse->__construct()
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ResponseFactory.php(102): Illuminate\\Http\\JsonResponse->__construct()
#14 /var/www/html/vendor/duncanmcclean/simple-commerce/src/Http/Controllers/BaseActionController.php(19): Illuminate\\Routing\\ResponseFactory->json()
#15 /var/www/html/vendor/duncanmcclean/simple-commerce/src/Http/Controllers/CartController.php(59): DuncanMcClean\\SimpleCommerce\\Http\\Controllers\\BaseActionController->withSuccess()
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): DuncanMcClean\\SimpleCommerce\\Http\\Controllers\\CartController->update()
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\\Routing\\Controller->callAction()
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(259): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()
#20 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(806): Illuminate\\Routing\\Route->run()
#21 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#22 /var/www/html/vendor/duncanmcclean/simple-commerce/src/Http/Middleware/EnsureFormParametersArriveIntact.php(66): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): DuncanMcClean\\SimpleCommerce\\Http\\Middleware\\EnsureFormParametersArriveIntact->handle()
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#28 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#29 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#30 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#31 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#32 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Session\\Middleware\\StartSession->handle()
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#34 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#35 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#37 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#38 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(805): Illuminate\\Pipeline\\Pipeline->then()
#39 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(784): Illuminate\\Routing\\Router->runRouteWithinStack()
#40 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(748): Illuminate\\Routing\\Router->runRoute()
#41 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(737): Illuminate\\Routing\\Router->dispatchToRoute()
#42 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch()
#43 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#44 /var/www/html/vendor/statamic/cms/src/Http/Middleware/StopImpersonating.php(12): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#45 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\StopImpersonating->handle()
#46 /var/www/html/vendor/statamic/cms/src/Http/Middleware/DisableFloc.php(17): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#47 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\DisableFloc->handle()
#48 /var/www/html/vendor/statamic/cms/src/Http/Middleware/CheckMultisite.php(14): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#49 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\CheckMultisite->handle()
#50 /var/www/html/vendor/statamic/cms/src/Http/Middleware/CheckComposerJsonScripts.php(14): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#51 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\CheckComposerJsonScripts->handle()
#52 /var/www/html/vendor/statamic/cms/src/Http/Middleware/PoweredByHeader.php(18): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#53 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Statamic\\Http\\Middleware\\PoweredByHeader->handle()
#54 /var/www/html/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(66): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#55 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle()
#56 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#57 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#58 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#59 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#60 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#61 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#62 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#63 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#64 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(99): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#65 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#66 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#67 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\HandleCors->handle()
#68 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#69 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#70 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#71 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then()
#72 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#73 /var/www/html/public/index.php(51): Illuminate\\Foundation\\Http\\Kernel->handle()
#74 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php(16): require_once('...')
#75 {main}
"} 

Steps to reproduce

  1. Upgrade to v6
  2. Update existing cart on a checkout page to fill in order data
  3. Error 500 on that axios post request

Environment

Application Name: XXX Laravel Version: 10.44.0 PHP Version: 8.1.5 Composer Version: 2.5.5 Environment: local Debug Mode: ENABLED URL: localhost/ Maintenance Mode: OFF

Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: NOT CACHED

Drivers Broadcasting: log Cache: statamic Database: mysql Logs: stack / single Mail: smtp Queue: sync Session: file

Simple Commerce Currencies: EUR, EUR, EUR, EUR Gateways: Mollie Repository: Customer: DuncanMcClean\SimpleCommerce\Customers\EloquentCustomerRepository Repository: Order: DuncanMcClean\SimpleCommerce\Orders\EloquentOrderRepository Repository: Product: DuncanMcClean\SimpleCommerce\Products\EntryProductRepository Shipping Methods: Pallet, International Tax Engine: App\SimpleCommerce\CompanyTaxEngine

Statamic Addons: 6 Antlers: runtime Sites: 4 (Nederlands, Duits, Engels, Pools) Stache Watcher: Enabled Static Caching: Disabled Version: 4.48.0 PRO

Statamic Addons aerni/advanced-seo: 2.4.3 appswithlove/statamic-one-click-content-translation: 4.35.0 duncanmcclean/simple-commerce: 6.0.7 heidkaemper/statamic-toolbar: 1.1.2 statamic-rad-pack/runway: 6.2.0 statamic/collaboration: 0.8.1

duncanmcclean commented 5 months ago

Hmm, I can't seem to reproduce this myself using the latest version of SC & Runway.

In vendor/statamic-rad-pack/runway/src/Fieldtypes/BaseFieldtype.php, on line 220, can you add the following code, try again and paste a screenshot of what you see?

dd($this->config('resource'), $model, $eagerLoadingRelationships);
Web10-Joris commented 5 months ago

See screenshot below :)

Scherm­afbeelding 2024-02-16 om 19 44 21
duncanmcclean commented 5 months ago

Hmm, that's odd. None of those values look like they'd be causing that error. 🤔

I don't suppose you're able to give me access to your site repository and I can figure out the problem at some point this week?

Web10-Joris commented 5 months ago

I'll try to recreate it on another environment this week, will share you the repository soon!

duncanmcclean commented 4 months ago

Thanks for sharing access to your site - I was able to reproduce the issue.

It should be fixed now if you update to the latest version of Runway (v6.2.2) and Simple Commerce (v6.0.8).