New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(history): capture content types history #19343
Conversation
packages/core/content-manager/server/src/history/services/history.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
// Check if store already exists | ||
const oldStore = storage.getStore(); | ||
|
||
return storage.run<ReturnType<TCallback>, void[]>( | ||
{ trx: store, commitCallbacks: [], rollbackCallbacks: [] }, | ||
{ | ||
trx: store, | ||
commitCallbacks: oldStore?.commitCallbacks || [], | ||
rollbackCallbacks: oldStore?.rollbackCallbacks || [], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix was found by @Marc-Roig, it's because nested transactions weren't inheriting the parent transaction context. Marc will ship another dedicated PR with tests but bundling the change in this PR too allows us to move on with this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally and it's working.
packages/core/content-manager/shared/contracts/history-versions.ts
Outdated
Show resolved
Hide resolved
createdAt: new Date(), | ||
createdBy: strapi.requestContext.get()?.state?.user.id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already discussed on slack but put this here anyway. I don't know how it works now but in v4 these were already set when using content-types, well you get them using an util:
const releaseWithCreatorFields = await setCreatorFields({ user })(releaseData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks I'll look more at what this does when I implement the model API
What does it do?
Why is it needed?
To make history
How to test it?