Commit d3eb9ab262 for woocommerce
commit d3eb9ab2628f794471dcd0be6b58816d0300c475
Author: Jilani Ahmed <jilani53@users.noreply.github.com>
Date: Fri Jan 23 23:25:13 2026 +0600
Fix PHP 8.5 deprecation notice in PageController (#62925)
* Fix PHP 8.5 deprecation notice in PageController
Ensure the page ID is not null when used as an array offset. This provides explicit backward compatibility and resolves the PHP 8.5 deprecation warning. \n\nScreenshot: https://prnt.sc/P6pAXcryj3vw
* Improve ID check condition.
* Add changefile(s) from automation for the following project(s): woocommerce
---------
Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/62925-php-8-5-deprecation-page-controller b/plugins/woocommerce/changelog/62925-php-8-5-deprecation-page-controller
new file mode 100644
index 0000000000..659f59ba6f
--- /dev/null
+++ b/plugins/woocommerce/changelog/62925-php-8-5-deprecation-page-controller
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Validate page IDs returned by the `woocommerce_navigation_connect_page_options` filter before registering them
\ No newline at end of file
diff --git a/plugins/woocommerce/src/Admin/PageController.php b/plugins/woocommerce/src/Admin/PageController.php
index 0b2b4edda9..0f61e3b274 100644
--- a/plugins/woocommerce/src/Admin/PageController.php
+++ b/plugins/woocommerce/src/Admin/PageController.php
@@ -117,7 +117,11 @@ class PageController {
$options = apply_filters( 'woocommerce_navigation_connect_page_options', $options );
// @todo check for null ID, or collision.
- $this->pages[ $options['id'] ] = $options;
+ $id = $options['id'] ?? null;
+
+ if ( is_string( $id ) && '' !== $id ) {
+ $this->pages[ $id ] = $options;
+ }
}
/**