You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The data in the content directory is correct and if you check the orbit sqlite cache it is correct. But then at some point orbit decides to refresh the data from the flat file. Something in that process causes the array/json attribute to be double json encoded.
For example before the refresh the flat file would look like:
summary: '[{"test":"test"}]'
And the sqlite database column would look like:
summary
[{"test":"test"}]
But after Orbit does it's refresh, the database column looks like:
My guess would be that since the data is loaded directly from the flat file and the flat file stores json columns as strings, then when it refreshes the database like this it must be feeding the already json encoded data into Eloquent's cast system again only for Eloquent to re-encode it.
Update:
Before I even submitted this, I had a thought that maybe the ->setAttribute() call in the loop https://github.com/ryangjchandler/orbit/blob/2.x/src/Actions/MaybeRefreshDatabaseContent.php#L56-L58 is the problem. I did a bit of research and found there is another method ->setRawAttributes(). Removing the whole loop and using that completely solved my problem in this case. But it may cause other side effects I am not aware of? If I get time I'll write a few tests and see if that is the solution.
The text was updated successfully, but these errors were encountered:
Not sure how to explain this but when you have a array/json-like cast column like so:
And then you save data to it:
The data in the content directory is correct and if you check the orbit sqlite cache it is correct. But then at some point orbit decides to refresh the data from the flat file. Something in that process causes the array/json attribute to be double json encoded.
For example before the refresh the flat file would look like:
And the sqlite database column would look like:
But after Orbit does it's refresh, the database column looks like:
Which means somewhere along the line the data got re-encoded as json. I am guessing it has something to do with these lines: https://github.com/ryangjchandler/orbit/blob/2.x/src/Actions/MaybeRefreshDatabaseContent.php#L56-L62
My guess would be that since the data is loaded directly from the flat file and the flat file stores json columns as strings, then when it refreshes the database like this it must be feeding the already json encoded data into Eloquent's cast system again only for Eloquent to re-encode it.
Update:
Before I even submitted this, I had a thought that maybe the
->setAttribute()
call in the loop https://github.com/ryangjchandler/orbit/blob/2.x/src/Actions/MaybeRefreshDatabaseContent.php#L56-L58 is the problem. I did a bit of research and found there is another method->setRawAttributes()
. Removing the whole loop and using that completely solved my problem in this case. But it may cause other side effects I am not aware of? If I get time I'll write a few tests and see if that is the solution.The text was updated successfully, but these errors were encountered: