diff --git a/projects/packages/protect-status/changelog/fix-php-undefined-array-key-warning b/projects/packages/protect-status/changelog/fix-php-undefined-array-key-warning new file mode 100644 index 0000000000000..72562089ff171 --- /dev/null +++ b/projects/packages/protect-status/changelog/fix-php-undefined-array-key-warning @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix PHP warnings caused by uninstalled extensions. diff --git a/projects/packages/protect-status/src/class-scan-status.php b/projects/packages/protect-status/src/class-scan-status.php index 32deca2eba526..6f743cc397b63 100644 --- a/projects/packages/protect-status/src/class-scan-status.php +++ b/projects/packages/protect-status/src/class-scan-status.php @@ -243,7 +243,7 @@ private static function normalize_api_data( $scan_data ) { // Theme and Plugin Threats if ( ! empty( $scan_threat->extension ) && in_array( $scan_threat->extension->type, array( 'plugin', 'theme' ), true ) ) { - $installed_extension = 'plugin' === $scan_threat->extension->type ? $plugins[ $scan_threat->extension->slug ] : $themes[ $scan_threat->extension->slug ]; + $installed_extension = 'plugin' === $scan_threat->extension->type ? ( $plugins[ $scan_threat->extension->slug ] ?? null ) : ( $themes[ $scan_threat->extension->slug ] ?? null ); // If the extension is no longer installed, skip this threat. // todo: use version_compare()