From 234b7eafcb1f813ea64841d7841c3c7a2b2820d4 Mon Sep 17 00:00:00 2001 From: thisismyurl <122108986+thisismyurl@users.noreply.github.com> Date: Tue, 7 Jul 2026 09:54:32 -0400 Subject: [PATCH 1/3] Guard settings destructure so the settings page doesn't blank when classifAISettings is missing The settings bundle destructured window.classifAISettings at module scope, before React mounts, so an undefined global (script-order interference from a caching/optimization plugin) threw a TypeError and blanked the whole settings page. Default services and features to {} and fall back to {} when the global is absent; downstream code already treats these defensively. Closes #1073 --- CHANGELOG.md | 4 ++++ src/js/settings/components/classifai-settings/index.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60037b977..cc1e36d38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file, per [the Ke ## [Unreleased] - TBD +### Fixed + +- Settings page no longer crashes to a blank screen when `window.classifAISettings` is undefined (for example when a caching or optimization plugin changes script order); the settings data is now read defensively (props [@thisismyurl](https://github.com/thisismyurl) via [#XXXX](https://github.com/10up/classifai/pull/XXXX)). + ## [3.8.0] - 2026-03-20 ### Added diff --git a/src/js/settings/components/classifai-settings/index.js b/src/js/settings/components/classifai-settings/index.js index 05cf1678d..7ec4f7381 100644 --- a/src/js/settings/components/classifai-settings/index.js +++ b/src/js/settings/components/classifai-settings/index.js @@ -31,7 +31,7 @@ import { ClassifAIRegistration } from '../classifai-registration'; import { ClassifAIWelcomeGuide } from './welcome-guide'; import { Notices } from '../feature-settings/notices'; -const { services, features } = window.classifAISettings; +const { services = {}, features = {} } = window.classifAISettings || {}; /** * FeatureSettingsWrapper component to render the feature settings. From 53dd7094ef77ea5c987c639622d4ca6a637984ef Mon Sep 17 00:00:00 2001 From: thisismyurl <122108986+thisismyurl@users.noreply.github.com> Date: Tue, 7 Jul 2026 09:54:52 -0400 Subject: [PATCH 2/3] Add PR number to changelog entry (#1135) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc1e36d38..9cf8556c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file, per [the Ke ### Fixed -- Settings page no longer crashes to a blank screen when `window.classifAISettings` is undefined (for example when a caching or optimization plugin changes script order); the settings data is now read defensively (props [@thisismyurl](https://github.com/thisismyurl) via [#XXXX](https://github.com/10up/classifai/pull/XXXX)). +- Settings page no longer crashes to a blank screen when `window.classifAISettings` is undefined (for example when a caching or optimization plugin changes script order); the settings data is now read defensively (props [@thisismyurl](https://github.com/thisismyurl) via [#1135](https://github.com/10up/classifai/pull/1135)). ## [3.8.0] - 2026-03-20 From 0615f0de7834f8161dcbe9e45e4bb037584937d0 Mon Sep 17 00:00:00 2001 From: thisismyurl <122108986+thisismyurl@users.noreply.github.com> Date: Tue, 7 Jul 2026 11:37:39 -0400 Subject: [PATCH 3/3] Render nothing when there are no features to route to The settings-global guard let `features` default to an empty object, so FeatureSettingsWrapper could compute an empty serviceFeatures list and then render with an undefined target, reintroducing a broken route on the path the guard was meant to protect. Return null when there are no features to route to. Addresses the Copilot review feedback on #1135. --- src/js/settings/components/classifai-settings/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/js/settings/components/classifai-settings/index.js b/src/js/settings/components/classifai-settings/index.js index 7ec4f7381..5c2fa53a2 100644 --- a/src/js/settings/components/classifai-settings/index.js +++ b/src/js/settings/components/classifai-settings/index.js @@ -43,6 +43,13 @@ const FeatureSettingsWrapper = () => { const { service, feature } = useParams(); const serviceFeatures = Object.keys( features[ service ] || {} ); + // When the settings data is unavailable (for example the global was + // missing) there is no feature to route to, so render nothing rather than + // navigating to an undefined path. + if ( ! serviceFeatures.length ) { + return null; + } + if ( ! serviceFeatures.includes( feature ) ) { return ; }