Skip to content

Commit 67bddfa

Browse files
committed
fix(#22): plugin core functionality with strapi v5.37.0
With the Strapi release `v5.37.0` the `populateAll` is lost on `event.params`. Use `strapi.requestContext.get()?.query?.populateAll` instead to make the plugin work again.
1 parent b217616 commit 67bddfa

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

sandbox/types/generated/contentTypes.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -852,12 +852,13 @@ export interface PluginUploadFile extends Struct.CollectionTypeSchema {
852852
};
853853
};
854854
attributes: {
855-
alternativeText: Schema.Attribute.String;
856-
caption: Schema.Attribute.String;
855+
alternativeText: Schema.Attribute.Text;
856+
caption: Schema.Attribute.Text;
857857
createdAt: Schema.Attribute.DateTime;
858858
createdBy: Schema.Attribute.Relation<"oneToOne", "admin::user"> &
859859
Schema.Attribute.Private;
860860
ext: Schema.Attribute.String;
861+
focalPoint: Schema.Attribute.JSON;
861862
folder: Schema.Attribute.Relation<"manyToOne", "plugin::upload.folder"> &
862863
Schema.Attribute.Private;
863864
folderPath: Schema.Attribute.String &
@@ -877,7 +878,7 @@ export interface PluginUploadFile extends Struct.CollectionTypeSchema {
877878
Schema.Attribute.Private;
878879
mime: Schema.Attribute.String & Schema.Attribute.Required;
879880
name: Schema.Attribute.String & Schema.Attribute.Required;
880-
previewUrl: Schema.Attribute.String;
881+
previewUrl: Schema.Attribute.Text;
881882
provider: Schema.Attribute.String & Schema.Attribute.Required;
882883
provider_metadata: Schema.Attribute.JSON;
883884
publishedAt: Schema.Attribute.DateTime;
@@ -886,7 +887,7 @@ export interface PluginUploadFile extends Struct.CollectionTypeSchema {
886887
updatedAt: Schema.Attribute.DateTime;
887888
updatedBy: Schema.Attribute.Relation<"oneToOne", "admin::user"> &
888889
Schema.Attribute.Private;
889-
url: Schema.Attribute.String & Schema.Attribute.Required;
890+
url: Schema.Attribute.Text & Schema.Attribute.Required;
890891
width: Schema.Attribute.Integer;
891892
};
892893
}

server/src/bootstrap.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ const bootstrap = ({ strapi }: { strapi: Core.Strapi }) => {
88
event.action === "beforeFindMany" ||
99
event.action === "beforeFindOne"
1010
) {
11-
// @ts-expect-error it's a new key
12-
if (event.params?.populateAll) {
11+
if (strapi.requestContext.get()?.query?.populateAll) {
1312
strapi.log.debug(
1413
`[populate-all] recursively populate ${event.model.uid}`
1514
);

server/src/middlewares/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import type { Context, Next } from "koa";
2+
13
export default {
24
/**
35
* This is a global middleware to add support for the custom query param `?populate=all`.
46
* Since Strapi's validator does not allow custom values for the populate param, we intercept the request here.
57
* If `?populate=all` is detected, we omit the value and set `?populateAll=true` instead.
68
* The bootstrap script later picks up `?populateAll=true` to apply the desired populate logic.
79
*/
8-
populateAll: async (ctx, next) => {
10+
populateAll: async (ctx: Context, next: Next) => {
911
if (ctx.query.populate === "all") {
1012
ctx.query.populate = undefined;
1113
ctx.query.populateAll = true;

0 commit comments

Comments
 (0)