From bf8902e1717275192e87ad811a3b7c638e493219 Mon Sep 17 00:00:00 2001 From: Danny Gershman Date: Tue, 24 Mar 2026 14:51:02 -0400 Subject: [PATCH] Add server health check for missing PHP curl extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show a warning notice on the settings page when the PHP curl extension is not installed, and a success notice with version info when it is. The curl extension is critical for performance — without it, WordPress falls back to PHP streams, adding ~5s per outbound HTTP request. Server info is only exposed to admin users to avoid leaking details. Co-Authored-By: Claude Opus 4.6 (1M context) --- assets/js/src/components/admin/Settings.js | 15 ++++++++++++++- includes/Rest/SettingsController.php | 14 ++++++++++++-- readme.txt | 1 + 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/assets/js/src/components/admin/Settings.js b/assets/js/src/components/admin/Settings.js index 2118c5e..e0aa34a 100644 --- a/assets/js/src/components/admin/Settings.js +++ b/assets/js/src/components/admin/Settings.js @@ -105,7 +105,8 @@ const Settings = () => { setSettings({ bmlt_root_server: response.bmlt_root_server || '', notification_email: response.notification_email || '', - default_service_bodies: response.default_service_bodies || '' + default_service_bodies: response.default_service_bodies || '', + server_info: response.server_info || null }); setExternalSources(Array.isArray(response.external_sources) ? response.external_sources : []); @@ -338,6 +339,18 @@ const Settings = () => {

Important: This plugin requires Pretty Permalinks to be enabled for the REST API to function correctly. If you're experiencing 404 errors when accessing external source or settings BMLT server, please ensure your WordPress site is using Pretty Permalinks (Settings → Permalinks) and not the "Plain" setting.

+ + {settings.server_info && !settings.server_info.curl_available && ( + +

Performance Warning: The PHP curl extension is not installed. External source requests will be significantly slower. Ask your hosting provider to install the php-curl extension for PHP {settings.server_info.php_version}.

+
+ )} + + {settings.server_info && settings.server_info.curl_available && ( + +

PHP {settings.server_info.php_version} with curl {settings.server_info.curl_version} detected.

+
+ )} {error && ( setError(null)}> diff --git a/includes/Rest/SettingsController.php b/includes/Rest/SettingsController.php index 1833106..d52eed8 100644 --- a/includes/Rest/SettingsController.php +++ b/includes/Rest/SettingsController.php @@ -38,7 +38,7 @@ public static function get_settings($request) { $settings = get_option('mayo_settings', []); $external_sources = get_option('mayo_external_sources', []); - return new \WP_REST_Response([ + $response_data = [ 'bmlt_root_server' => $settings['bmlt_root_server'] ?? '', 'notification_email' => $settings['notification_email'] ?? '', 'default_service_bodies' => $settings['default_service_bodies'] ?? '', @@ -47,7 +47,17 @@ public static function get_settings($request) { 'subscription_tags' => $settings['subscription_tags'] ?? [], 'subscription_service_bodies' => $settings['subscription_service_bodies'] ?? [], 'subscription_new_option_behavior' => $settings['subscription_new_option_behavior'] ?? 'opt_in' - ]); + ]; + + if (current_user_can('manage_options')) { + $response_data['server_info'] = [ + 'php_version' => PHP_VERSION, + 'curl_available' => extension_loaded('curl'), + 'curl_version' => extension_loaded('curl') ? curl_version()['version'] : null, + ]; + } + + return new \WP_REST_Response($response_data); } /** diff --git a/readme.txt b/readme.txt index b4c1588..2d11a24 100644 --- a/readme.txt +++ b/readme.txt @@ -193,6 +193,7 @@ This project is licensed under the GPL v2 or later. * Changed external source event type dropdown from "Select an event type" to "All Event Types" to clarify that leaving it blank fetches all types. * Added support for comma-separated event types in the REST API (e.g., `event_type=Activity,Service`), enabling a single external source to fetch multiple event types in one request. * Fixed admin events list page taking minutes to load when many events exist by caching service body lookups instead of making an HTTP request per row. +* Added server health check warning on settings page when PHP curl extension is missing, which causes significantly slower external source requests. = 1.8.7 = * Fixed announcement form flyer upload field never appearing even when `show_flyer="true"` shortcode attribute was set. [#252]