statamic-rad-pack / mailchimp

Mailchimp integration for Statamic
https://statamic.com/addons/rad-pack/mailchimp
MIT License
19 stars 13 forks source link

Saved config in CP not saving #123

Closed dave-smyth closed 3 weeks ago

dave-smyth commented 1 month ago

Description

Have a strange issue in Mailchimp:

We’ve been using the Mailchimp addon successfully over the last few years on a client’s site where they have lots of forms synced to different audiences/tags in Mailchimp.

They’ve tried adding connecting a new form through the CP. When they save the page, it seems all is ok and we receive the confirmation message, but when we refresh nothing is saved.

Other notes:

Steps to reproduce

  1. Save new form/Mailchimp config in CP
  2. Refresh the page

Environment

Environment Application Name: Laravel Version: 10.43.0 PHP Version: 8.2.21 Composer Version: 2.7.7 Environment: production Debug Mode: OFF Maintenance Mode: OFF

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

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

Statamic Addons: 6 Antlers: runtime Sites: 1 Stache Watcher: Enabled Static Caching: Disabled Version: 4.48.0 PRO

Statamic Addons aryehraber/statamic-captcha: 1.10.0 edalzell/forma: 2.1 jaygeorge/statamic-vanilla-peak-seo: dev-main spatie/statamic-responsive-images: 4.1.1 statamic-rad-pack/mailchimp: 4.1.1 withcandour/aardvark-seo: 3.0.0

ryanmitchell commented 1 month ago

Sorry for the delay - we're going to change the approach to not save form settings to the config in the next version (https://github.com/statamic-rad-pack/mailchimp/pull/124) which should hopefully get around this issue.

I suspect you're just putting a lot of data in the config and its struggling.

dave-smyth commented 1 month ago

Delay? This is nothing 😄

If that would cause this, I can believe it – we have loads of forms...

Just so I can set expectations: do we have a rough ETA on that? And I guess that will be a v5 release (no problem if so)?

ryanmitchell commented 1 month ago

Yeah it will require v5.18+, hopefully thats not too much of a problem? ETA - I'd expect it to be in the next 2 weeks.

dave-smyth commented 1 month ago

All good, thank you!

edalzell commented 4 weeks ago

@websmyth can you update and give it a try? It should migrate your config over to YAML files then everything should work. It was done in this PR: https://github.com/statamic-rad-pack/mailchimp/pull/124

dave-smyth commented 3 weeks ago

Thanks – given this a go and had to upgrade the site from S4 > S5. I think the addon is generating this error (think because if I remove the addon and composer update the issue goes away).

When I run composer update or just about any other command (php artisan... or php please...) I get this:


> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   TypeError 

  array_key_exists(): Argument #2 ($array) must be of type array, null given

  at vendor/laravel/framework/src/Illuminate/Collections/Arr.php:178
    174▕         if (is_float($key)) {
    175▕             $key = (string) $key;
    176▕         }
    177▕ 
  ➜ 178▕         return array_key_exists($key, $array);
    179▕     }
    180▕ 
    181▕     /**
    182▕      * Return the first element in an array passing a given truth test.

      +12 vendor frames 

  13  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1```
dave-smyth commented 3 weeks ago

Ah, laravel.log reveals more:

[2024-08-23 08:27:52] local.ERROR: array_key_exists(): Argument #2 ($array) must be of type array, null given {"exception":"[object] (TypeError(code: 0): array_key_exists(): Argument #2 ($array) must be of type array, null given at [redacted]/vendor/laravel/framework/src/Illuminate/Collections/Arr.php:178)
[stacktrace]
#0 [redacted]/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(178): array_key_exists('id', NULL)
#1 [redacted]/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(298): Illuminate\\Support\\Arr::exists(NULL, 'id')
#2 [redacted]/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(152): Illuminate\\Support\\Arr::forget(NULL, Array)
#3 [redacted]/vendor/statamic/cms/src/Support/Arr.php(323): Illuminate\\Support\\Arr::except(NULL, Array)
#4 [redacted]/vendor/statamic-rad-pack/mailchimp/src/ServiceProvider.php(364): Statamic\\Support\\Arr::__callStatic('except', Array)
#5 [redacted]/vendor/statamic-rad-pack/mailchimp/src/ServiceProvider.php(84): StatamicRadPack\\Mailchimp\\ServiceProvider->migrateUserToYaml()
#6 [redacted]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1162): StatamicRadPack\\Mailchimp\\ServiceProvider->StatamicRadPack\\Mailchimp\\{closure}(Object(Illuminate\\Foundation\\Application))
#7 [redacted]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1105): Illuminate\\Foundation\\Application->fireAppCallbacks(Array)
#8 [redacted]/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\\Foundation\\Application->boot()
#9 /[redacted]vendor/laravel/framework/src/Illuminate/Foundation/Application.php(316): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap(Object(Illuminate\\Foundation\\Application))
#10 [redacted]/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(473): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#11 [redacted]/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(195): Illuminate\\Foundation\\Console\\Kernel->bootstrap()
#12 [redacted]/artisan(35): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#13 {main}
"} 
ryanmitchell commented 3 weeks ago

Would you mind applying this fix and see if it works for you? https://github.com/statamic-rad-pack/mailchimp/pull/125

dave-smyth commented 3 weeks ago

Yep, you genius. Issue resolved...

ryanmitchell commented 3 weeks ago

Going to close this as its fixed by the new release.