contentful / contentful_model

A lightweight wrapper around the Contentful api gem, to make it behave more like ActiveRecord
MIT License
44 stars 42 forks source link

Lost configuration on ContentfulModel::Management.new #131

Open MattFenelon opened 5 years ago

MattFenelon commented 5 years ago

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.