From 10f9975e5878f960f930f2ff5720320cbacf08a4 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Fri, 23 Oct 2026 12:37:04 -0400 Subject: [PATCH 1/4] fix(faustwp): stop passing null to preg_match when a front-end URL is missing --- plugins/faustwp/includes/settings/callbacks.php | 2 +- .../tests/integration/ProcessTelemetryRouteTests.php | 1 + .../faustwp/tests/integration/SettingsCallbacksTests.php | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/faustwp/includes/settings/callbacks.php b/plugins/faustwp/includes/settings/callbacks.php index 91a0d73f2..18d37cad2 100644 --- a/plugins/faustwp/includes/settings/callbacks.php +++ b/plugins/faustwp/includes/settings/callbacks.php @@ -203,7 +203,7 @@ function sanitize_faustwp_settings( $settings, $option ) { switch ( $name ) { case 'frontend_uri': - if ( '' === $value || preg_match( '#http(s?)://(.+)#i', $value ) ) { + if ( '' === $value || ( is_string( $value ) && preg_match( '#http(s?)://(.+)#i', $value ) ) ) { $settings[ $name ] = esc_url_raw( $value, $protocols ); } else { $errors[ $name ] = __( 'The Front-end site URL you entered did not appear to be a valid URL. Please enter a valid URL.', 'faustwp' ); diff --git a/plugins/faustwp/tests/integration/ProcessTelemetryRouteTests.php b/plugins/faustwp/tests/integration/ProcessTelemetryRouteTests.php index e2d720d0b..dc4809b70 100644 --- a/plugins/faustwp/tests/integration/ProcessTelemetryRouteTests.php +++ b/plugins/faustwp/tests/integration/ProcessTelemetryRouteTests.php @@ -7,6 +7,7 @@ class ProcessTelemetryRouteTests extends WP_UnitTestCase { + private $server; private $request; private $route_name; diff --git a/plugins/faustwp/tests/integration/SettingsCallbacksTests.php b/plugins/faustwp/tests/integration/SettingsCallbacksTests.php index d09238080..ddc3c0bbb 100644 --- a/plugins/faustwp/tests/integration/SettingsCallbacksTests.php +++ b/plugins/faustwp/tests/integration/SettingsCallbacksTests.php @@ -8,6 +8,7 @@ namespace WPE\FaustWP\Tests\Integration; use function WPE\FaustWP\Settings\sanitize_faustwp_settings; +use function WPE\FaustWP\Settings\faustwp_get_setting; class SettingsCallbacksTests extends \WP_UnitTestCase { @@ -41,6 +42,12 @@ public function test_sanitize_faustwp_settings_does_not_change_existing_settings $this->assertSame( $this->init_settings, sanitize_faustwp_settings( $this->init_settings, $this->option ) ); } + public function test_sanitize_faustwp_settings_rejects_a_null_frontend_uri() { + $sanitized = sanitize_faustwp_settings( [ 'frontend_uri' => null ], $this->option ); + + $this->assertSame( faustwp_get_setting( 'frontend_uri' ), $sanitized['frontend_uri'] ); + } + public function test_sanitize_faustwp_settings_allows_valid_frontend_uris() { $valid_uris = [ // Clean URLs From 09991041a8c54b3a82c03f5d5b1b22cde095f6d3 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Fri, 23 Oct 2026 13:03:34 -0400 Subject: [PATCH 2/4] fix(faustwp): handle a null front-end URL in the trailing slash filter --- plugins/faustwp/includes/settings/callbacks.php | 3 ++- .../faustwp/tests/integration/SettingsCallbacksTests.php | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/faustwp/includes/settings/callbacks.php b/plugins/faustwp/includes/settings/callbacks.php index 18d37cad2..4a81aca67 100644 --- a/plugins/faustwp/includes/settings/callbacks.php +++ b/plugins/faustwp/includes/settings/callbacks.php @@ -566,5 +566,6 @@ function trim_frontend_uri_trailing_slash( $value, $name ) { return $value; } - return untrailingslashit( $value ); + // A front-end URL saved outside the settings screen may be null. + return untrailingslashit( (string) $value ); } diff --git a/plugins/faustwp/tests/integration/SettingsCallbacksTests.php b/plugins/faustwp/tests/integration/SettingsCallbacksTests.php index ddc3c0bbb..8a46b375b 100644 --- a/plugins/faustwp/tests/integration/SettingsCallbacksTests.php +++ b/plugins/faustwp/tests/integration/SettingsCallbacksTests.php @@ -9,6 +9,7 @@ use function WPE\FaustWP\Settings\sanitize_faustwp_settings; use function WPE\FaustWP\Settings\faustwp_get_setting; +use function WPE\FaustWP\Settings\trim_frontend_uri_trailing_slash; class SettingsCallbacksTests extends \WP_UnitTestCase { @@ -48,6 +49,11 @@ public function test_sanitize_faustwp_settings_rejects_a_null_frontend_uri() { $this->assertSame( faustwp_get_setting( 'frontend_uri' ), $sanitized['frontend_uri'] ); } + public function test_trim_frontend_uri_trailing_slash_handles_a_null_frontend_uri() { + $this->assertSame( '', trim_frontend_uri_trailing_slash( null, 'frontend_uri' ) ); + $this->assertSame( 'http://localhost:3000', trim_frontend_uri_trailing_slash( 'http://localhost:3000/', 'frontend_uri' ) ); + } + public function test_sanitize_faustwp_settings_allows_valid_frontend_uris() { $valid_uris = [ // Clean URLs From 56f843d3e8bfbe4d7979ea56e75f78e719f253bf Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Fri, 23 Oct 2026 13:04:50 -0400 Subject: [PATCH 3/4] test(faustwp): check the saved URL and error when a null front-end URL is rejected --- .../faustwp/tests/integration/SettingsCallbacksTests.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/faustwp/tests/integration/SettingsCallbacksTests.php b/plugins/faustwp/tests/integration/SettingsCallbacksTests.php index 8a46b375b..663a12adb 100644 --- a/plugins/faustwp/tests/integration/SettingsCallbacksTests.php +++ b/plugins/faustwp/tests/integration/SettingsCallbacksTests.php @@ -8,7 +8,6 @@ namespace WPE\FaustWP\Tests\Integration; use function WPE\FaustWP\Settings\sanitize_faustwp_settings; -use function WPE\FaustWP\Settings\faustwp_get_setting; use function WPE\FaustWP\Settings\trim_frontend_uri_trailing_slash; class SettingsCallbacksTests extends \WP_UnitTestCase { @@ -46,7 +45,10 @@ public function test_sanitize_faustwp_settings_does_not_change_existing_settings public function test_sanitize_faustwp_settings_rejects_a_null_frontend_uri() { $sanitized = sanitize_faustwp_settings( [ 'frontend_uri' => null ], $this->option ); - $this->assertSame( faustwp_get_setting( 'frontend_uri' ), $sanitized['frontend_uri'] ); + $this->assertSame( $this->init_settings['frontend_uri'], $sanitized['frontend_uri'] ); + $errors = get_settings_errors( $this->option ); + $this->assertCount( 1, $errors ); + $this->assertEquals( $errors[0]['code'], 'faustwp_invalid_frontend_uri' ); } public function test_trim_frontend_uri_trailing_slash_handles_a_null_frontend_uri() { From c6ad5622445280c3ab6da4697eb1c7625df5a352 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Fri, 23 Oct 2026 13:07:54 -0400 Subject: [PATCH 4/4] test(faustwp): fail the plugin tests on PHP deprecations --- plugins/faustwp/phpunit.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/faustwp/phpunit.xml.dist b/plugins/faustwp/phpunit.xml.dist index 14b76e3d9..b4107a0b1 100644 --- a/plugins/faustwp/phpunit.xml.dist +++ b/plugins/faustwp/phpunit.xml.dist @@ -3,6 +3,7 @@ backupGlobals="false" bootstrap="tests/bootstrap.php" colors="true" + convertDeprecationsToExceptions="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true"