Skip to content

Commit 17f0f02

Browse files
authored
fix: fetch entity before publish or unpublish actions (#199)
1 parent 6633f19 commit 17f0f02

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server/services/publication-service.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ export default ({ strapi }) => ({
1212
try {
1313
const { hooks } = getPluginService('settingsService').get();
1414

15-
await hooks.beforePublish({ strapi, uid, entity: publishedEntity });
15+
// Fetch the entity before publishing
16+
const entity = await strapi.entityService.findOne(uid, entityId, { locale });
17+
18+
await hooks.beforePublish({ strapi, uid, entity });
1619

1720
const publishedEntity = await strapi.documents(uid).publish({
1821
documentId: entityId,
@@ -36,7 +39,10 @@ export default ({ strapi }) => ({
3639
try {
3740
const { hooks } = getPluginService('settingsService').get();
3841

39-
await hooks.beforeUnpublish({ strapi, uid, entity: unpublishedEntity });
42+
// Fetch the entity before unpublishing
43+
const entity = await strapi.entityService.findOne(uid, entityId, { locale });
44+
45+
await hooks.beforeUnpublish({ strapi, uid, entity });
4046

4147
const unpublishedEntity = await strapi.documents(uid).unpublish({
4248
documentId: entityId,

0 commit comments

Comments
 (0)