contentful_model icon indicating copy to clipboard operation
contentful_model copied to clipboard

Lost configuration on ContentfulModel::Management.new

Open MattFenelon opened this issue 6 years ago • 0 comments

This is related to #130.

I'm not sure if this is a bug in this library or contentful/contentful-management.rb.

In the initialiser for Contentful::Management::Client the initialised object is saved to a thread variable.

https://github.com/contentful/contentful-management.rb/blob/6401797059672994269220594dff8c084957de27/lib/contentful/management/client.rb#L91-L98

The thread variable is accessed via the shared_instance method in various places in contentful/contentful-management.rb. Any new initialisation of Contentful::Management::Client overwrites the thread variable, causing subsequent calls within contentful/contentful-management.rb to use the new instance, with the new configuration. This caused me issues with default_locale, which I dealt with in #130. I guess this could also cause issues with options like raise_errors.

As I said, I'm not sure if this is a bug in this library or contentful/contentful-management.rb. The behaviour in contentful/contentful-management.rb is by-design so perhaps this library should be made to use the shared_instance variable.

MattFenelon avatar May 23 '19 14:05 MattFenelon