From 5be281b477e6473b6c0df9a51674927ce7e16635 Mon Sep 17 00:00:00 2001 From: Ella <4710635+ellatrix@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:58:48 +0100 Subject: [PATCH] one problem at a time --- lib/compat/wordpress-6.8/preload.php | 7 ++----- packages/core-data/src/entities.js | 6 +----- .../sync-state-with-url/use-init-edited-entity-from-url.js | 1 - 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/compat/wordpress-6.8/preload.php b/lib/compat/wordpress-6.8/preload.php index 612f244b83a9f0..084c2d5d49ce94 100644 --- a/lib/compat/wordpress-6.8/preload.php +++ b/lib/compat/wordpress-6.8/preload.php @@ -10,13 +10,10 @@ */ function gutenberg_block_editor_preload_paths_6_8( $paths, $context ) { if ( 'core/edit-site' === $context->name ) { + // Core already preloads both of these for `core/edit-post`. $paths[] = '/wp/v2/settings'; $paths[] = array( '/wp/v2/settings', 'OPTIONS' ); - // Append a pseudo context value to allow preloading twice. `canUser` - // uses the same path. Ideally the raw result is cached and used by both - // `canUser` and `loadSiteEntity`. - $paths[] = array( '/wp/v2/settings?context=schema', 'OPTIONS' ); } return $paths; } -add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_block_editor_preload_paths_6_8', 10, 2 ); \ No newline at end of file +add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_block_editor_preload_paths_6_8', 10, 2 ); diff --git a/packages/core-data/src/entities.js b/packages/core-data/src/entities.js index 759260de40a124..8d09402087cf90 100644 --- a/packages/core-data/src/entities.js +++ b/packages/core-data/src/entities.js @@ -418,11 +418,7 @@ async function loadSiteEntity() { }; const site = await apiFetch( { - // Append a pseudo context value to allow preloading twice. `canUser` - // uses the same path. Ideally the raw result is cached and used by both - // `canUser` and `loadSiteEntity`. - // Please check the preloaded paths whenever this is changed. - path: entity.baseURL + '?context=schema', + path: entity.baseURL, method: 'OPTIONS', } ); diff --git a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js index e6555d30fcaf11..35eeb5963fb546 100644 --- a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +++ b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js @@ -39,7 +39,6 @@ function useResolveEditedEntityAndContext( { postId, postType } ) { frontPageTemplateId, } = useSelect( ( select ) => { const { getEntityRecord, getEntityRecords } = select( coreDataStore ); - // Please check the preloaded paths whenever this is changed. const siteData = getEntityRecord( 'root', 'site' ); const base = getEntityRecord( 'root', '__unstableBase' ); const templates = getEntityRecords( 'postType', TEMPLATE_POST_TYPE, {