Skip to content

Commit

Permalink
Core Data: Fix 'getEntityRecordPermissions' memoization (#64091)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored Jul 30, 2024
1 parent dbae6a2 commit 02fe91a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/core-data/src/private-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export const getBlockPatternsForPostType = createRegistrySelector(
export const getEntityRecordsPermissions = createRegistrySelector( ( select ) =>
createSelector(
( state: State, kind: string, name: string, ids: string[] ) => {
return ids.map( ( id ) => ( {
const normalizedIds = Array.isArray( ids ) ? ids : [ ids ];
return normalizedIds.map( ( id ) => ( {
delete: select( STORE_NAME ).canUser( 'delete', {
kind,
name,
Expand Down Expand Up @@ -90,5 +91,5 @@ export function getEntityRecordPermissions(
name: string,
id: string
) {
return getEntityRecordsPermissions( state, kind, name, [ id ] )[ 0 ];
return getEntityRecordsPermissions( state, kind, name, id )[ 0 ];
}

0 comments on commit 02fe91a

Please sign in to comment.