Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions packages/core-data/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,25 @@ export const getEntityRecords =
response.headers.get( 'X-WP-TotalPages' )
);

if ( ! meta ) {
meta = {
totalItems: parseInt(
response.headers.get( 'X-WP-Total' )
),
totalPages: 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be using X-WP-TotalPages? We could use the totalPages constant from above:

Suggested change
totalPages: 1,
totalPages,

Copy link
Member Author

@Mamaduka Mamaduka Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The total pages definition above is used for the loop. The number of pages for unbound queries should be one, as it fetches all results and technically isn't "paginated".

From previous work - #64772.

meta = {
totalItems: records.length,
totalPages: 1,
};
.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍

};
}

records.push( ...pageRecords );
registry.batch( () => {
dispatch.receiveEntityRecords(
kind,
name,
records,
query
query,
false,
undefined,
meta
);
dispatch.finishResolutions(
'getEntityRecord',
Expand All @@ -322,11 +334,6 @@ export const getEntityRecords =
} );
page++;
} while ( page <= totalPages );

meta = {
totalItems: records.length,
totalPages: 1,
};
} else {
records = Object.values( await apiFetch( { path } ) );
meta = {
Expand Down
Loading