From b61aa3017020827a80a2cc89e9c6c927bea21174 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Tue, 11 Feb 2025 14:13:32 -0700 Subject: [PATCH 01/11] Declare class property in Divi class --- projects/packages/videopress/src/class-divi.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/projects/packages/videopress/src/class-divi.php b/projects/packages/videopress/src/class-divi.php index bb3894c0f7089..5fc967f0706bf 100644 --- a/projects/packages/videopress/src/class-divi.php +++ b/projects/packages/videopress/src/class-divi.php @@ -25,6 +25,13 @@ class Divi { **/ private $running = false; + /** + * VideoPress Divi Extension object. + * + * @var ?VideoPress_Divi_Extension + **/ + private $vidi_extension; + /** * Initializes VideoPress/Divi integration. * From 4c68580486ad470c6a8c99215c1e02776be82ac0 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Tue, 11 Feb 2025 14:42:22 -0700 Subject: [PATCH 02/11] Force strings when required --- projects/plugins/jetpack/class.jetpack-post-images.php | 2 +- .../plugins/jetpack/modules/carousel/jetpack-carousel.php | 5 ++++- projects/plugins/jetpack/modules/markdown/easy-markdown.php | 2 +- projects/plugins/jetpack/modules/widgets/contact-info.php | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/projects/plugins/jetpack/class.jetpack-post-images.php b/projects/plugins/jetpack/class.jetpack-post-images.php index f34d62dbc8b5f..ec411553eb675 100644 --- a/projects/plugins/jetpack/class.jetpack-post-images.php +++ b/projects/plugins/jetpack/class.jetpack-post-images.php @@ -897,7 +897,7 @@ public static function fit_image_url( $src, $width, $height ) { } // If WPCOM hosted image use native transformations. - $img_host = wp_parse_url( $src, PHP_URL_HOST ); + $img_host = wp_parse_url( $src, PHP_URL_HOST ) ?? ''; if ( str_ends_with( $img_host, '.files.wordpress.com' ) ) { return add_query_arg( array( diff --git a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php index b7abb5fb2ab40..a592af0025e3a 100644 --- a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php +++ b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php @@ -817,7 +817,10 @@ class_exists( 'Jetpack_AMP_Support' ) * @param string $content HTML content of the post. * @return string */ - public function add_data_img_tags_and_enqueue_assets( $content ) { + public function add_data_img_tags_and_enqueue_assets( $content = '' ) { + if ( ! is_string( $content ) ) { + $content = ''; + } if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() diff --git a/projects/plugins/jetpack/modules/markdown/easy-markdown.php b/projects/plugins/jetpack/modules/markdown/easy-markdown.php index fb61aa1835917..6b0c2b4aa1e59 100644 --- a/projects/plugins/jetpack/modules/markdown/easy-markdown.php +++ b/projects/plugins/jetpack/modules/markdown/easy-markdown.php @@ -667,7 +667,7 @@ public function transform( $text, $args = array() ) { * @param string $text Content to be run through Markdown * @param array $args Array of Markdown options. */ - $text = apply_filters( 'wpcom_markdown_transform_pre', $text, $args ); + $text = apply_filters( 'wpcom_markdown_transform_pre', $text, $args ) ?? ''; // ensure our paragraphs are separated. $text = str_replace( array( '

', "

\n

" ), "

\n\n

", $text ); // visual editor likes to add

s. Buh-bye. diff --git a/projects/plugins/jetpack/modules/widgets/contact-info.php b/projects/plugins/jetpack/modules/widgets/contact-info.php index a8bda55a5e5b8..f763020dc1b1a 100644 --- a/projects/plugins/jetpack/modules/widgets/contact-info.php +++ b/projects/plugins/jetpack/modules/widgets/contact-info.php @@ -163,7 +163,7 @@ public function widget( $args, $instance ) { } } - if ( is_email( trim( $instance['email'] ) ) ) { + if ( is_email( trim( $instance['email'] ?? '' ) ) ) { printf( '

%1$s
', esc_html( $instance['email'] ) From 33acbb3c39f99b431ef8cdc723eff6b3344f7889 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Tue, 11 Feb 2025 14:44:14 -0700 Subject: [PATCH 03/11] Add changelog --- ...e_deprecation_notices_in_wild_found_during_14.4-a.3_deploy | 4 ++++ ...e_deprecation_notices_in_wild_found_during_14.4-a.3_deploy | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 projects/packages/videopress/changelog/fix-jetpack-handle_deprecation_notices_in_wild_found_during_14.4-a.3_deploy create mode 100644 projects/plugins/jetpack/changelog/fix-jetpack-handle_deprecation_notices_in_wild_found_during_14.4-a.3_deploy diff --git a/projects/packages/videopress/changelog/fix-jetpack-handle_deprecation_notices_in_wild_found_during_14.4-a.3_deploy b/projects/packages/videopress/changelog/fix-jetpack-handle_deprecation_notices_in_wild_found_during_14.4-a.3_deploy new file mode 100644 index 0000000000000..ad55ef30b341d --- /dev/null +++ b/projects/packages/videopress/changelog/fix-jetpack-handle_deprecation_notices_in_wild_found_during_14.4-a.3_deploy @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Prevent deprecation notices on PHP 8. diff --git a/projects/plugins/jetpack/changelog/fix-jetpack-handle_deprecation_notices_in_wild_found_during_14.4-a.3_deploy b/projects/plugins/jetpack/changelog/fix-jetpack-handle_deprecation_notices_in_wild_found_during_14.4-a.3_deploy new file mode 100644 index 0000000000000..8783c5b61c2a2 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-jetpack-handle_deprecation_notices_in_wild_found_during_14.4-a.3_deploy @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Prevent deprecation notices on PHP 8. From d68cbae1bec5df1afcc3da8173cd70ce636026ed Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Tue, 11 Feb 2025 15:12:30 -0700 Subject: [PATCH 04/11] Fix annotation --- projects/packages/videopress/src/class-divi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/packages/videopress/src/class-divi.php b/projects/packages/videopress/src/class-divi.php index 5fc967f0706bf..392a853ed2fab 100644 --- a/projects/packages/videopress/src/class-divi.php +++ b/projects/packages/videopress/src/class-divi.php @@ -28,7 +28,7 @@ class Divi { /** * VideoPress Divi Extension object. * - * @var ?VideoPress_Divi_Extension + * @var ?\Automattic\Jetpack\VideoPress\VideoPress_Divi_Extension **/ private $vidi_extension; From fb6612fac69c496b8dd69226a9e021d5a5b0558f Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Tue, 11 Feb 2025 15:18:37 -0700 Subject: [PATCH 05/11] Try this instead? --- projects/packages/videopress/src/class-divi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/packages/videopress/src/class-divi.php b/projects/packages/videopress/src/class-divi.php index 392a853ed2fab..7f3d180bdb3ac 100644 --- a/projects/packages/videopress/src/class-divi.php +++ b/projects/packages/videopress/src/class-divi.php @@ -28,7 +28,7 @@ class Divi { /** * VideoPress Divi Extension object. * - * @var ?\Automattic\Jetpack\VideoPress\VideoPress_Divi_Extension + * @var ?\VideoPress_Divi_Extension **/ private $vidi_extension; From ed41f0469a458714b5a2308972da0598a901bb7d Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Tue, 11 Feb 2025 15:49:32 -0700 Subject: [PATCH 06/11] Update baseline --- projects/packages/videopress/.phan/baseline.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/packages/videopress/.phan/baseline.php b/projects/packages/videopress/.phan/baseline.php index 4293758e30be3..b648b5c708a88 100644 --- a/projects/packages/videopress/.phan/baseline.php +++ b/projects/packages/videopress/.phan/baseline.php @@ -10,9 +10,9 @@ return [ // # Issue statistics: // PhanPluginDuplicateConditionalNullCoalescing : 20+ occurrences - // PhanUndeclaredProperty : 8 occurrences // PhanTypeMismatchArgumentProbablyReal : 7 occurrences // PhanTypeMismatchReturnProbablyReal : 7 occurrences + // PhanUndeclaredProperty : 7 occurrences // PhanTypeArraySuspicious : 6 occurrences // PhanTypeMismatchReturn : 6 occurrences // PhanUndeclaredClassMethod : 6 occurrences @@ -42,7 +42,6 @@ 'src/class-block-editor-content.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/class-block-editor-extensions.php' => ['PhanRedundantCondition', 'PhanTypeMismatchReturnProbablyReal'], 'src/class-data.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspicious', 'PhanTypeMismatchReturn'], - 'src/class-divi.php' => ['PhanUndeclaredProperty'], 'src/class-initializer.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing'], 'src/class-jwt-token-bridge.php' => ['PhanTypeMismatchReturn'], 'src/class-plan.php' => ['PhanTypeMismatchReturnProbablyReal'], From 08b4f44971f34a23582f120a21439d906ebbef0f Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Wed, 12 Feb 2025 06:42:39 -0700 Subject: [PATCH 07/11] Return empty string if content is not a string --- projects/plugins/jetpack/modules/carousel/jetpack-carousel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php index a592af0025e3a..d376a65d0a889 100644 --- a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php +++ b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php @@ -819,7 +819,7 @@ class_exists( 'Jetpack_AMP_Support' ) */ public function add_data_img_tags_and_enqueue_assets( $content = '' ) { if ( ! is_string( $content ) ) { - $content = ''; + return ''; } if ( class_exists( 'Jetpack_AMP_Support' ) From ee260d203a714b5f0f407dbb392369524f979e8f Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Wed, 12 Feb 2025 06:49:40 -0700 Subject: [PATCH 08/11] Split condition in two Co-authored-by: Jeremy Herve --- projects/plugins/jetpack/modules/widgets/contact-info.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/modules/widgets/contact-info.php b/projects/plugins/jetpack/modules/widgets/contact-info.php index f763020dc1b1a..57f09c9c19b57 100644 --- a/projects/plugins/jetpack/modules/widgets/contact-info.php +++ b/projects/plugins/jetpack/modules/widgets/contact-info.php @@ -163,7 +163,10 @@ public function widget( $args, $instance ) { } } - if ( is_email( trim( $instance['email'] ?? '' ) ) ) { + if ( + ! empty( $instance['email'] ) + && is_email( trim( $instance['email'] ) ) + ) { printf( '
%1$s
', esc_html( $instance['email'] ) From c670f5dd3e4fdaf84b95cabd832aca221e179628 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Wed, 12 Feb 2025 10:51:39 -0700 Subject: [PATCH 09/11] More tweaks --- .../plugins/jetpack/modules/carousel/jetpack-carousel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php index d376a65d0a889..1a033b3e9bb41 100644 --- a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php +++ b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php @@ -817,8 +817,8 @@ class_exists( 'Jetpack_AMP_Support' ) * @param string $content HTML content of the post. * @return string */ - public function add_data_img_tags_and_enqueue_assets( $content = '' ) { - if ( ! is_string( $content ) ) { + public function add_data_img_tags_and_enqueue_assets( $content ) { + if ( ! is_string( $content ) || $content === '' ) { return ''; } if ( From f2261ec074af2d98018aac22e6731a443fdefca3 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Wed, 12 Feb 2025 11:06:25 -0700 Subject: [PATCH 10/11] Account for parse error Co-authored-by: Brad Jorsch --- projects/plugins/jetpack/class.jetpack-post-images.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/plugins/jetpack/class.jetpack-post-images.php b/projects/plugins/jetpack/class.jetpack-post-images.php index ec411553eb675..280a5a040d0a4 100644 --- a/projects/plugins/jetpack/class.jetpack-post-images.php +++ b/projects/plugins/jetpack/class.jetpack-post-images.php @@ -897,8 +897,8 @@ public static function fit_image_url( $src, $width, $height ) { } // If WPCOM hosted image use native transformations. - $img_host = wp_parse_url( $src, PHP_URL_HOST ) ?? ''; - if ( str_ends_with( $img_host, '.files.wordpress.com' ) ) { + $img_host = wp_parse_url( $src, PHP_URL_HOST ); + if ( $img_host && str_ends_with( $img_host, '.files.wordpress.com' ) ) { return add_query_arg( array( 'w' => $width, From 76b7c9d1bb4aa128026dab4be0962c6722f3c7d1 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:49:43 -0700 Subject: [PATCH 11/11] Update projects/plugins/jetpack/modules/widgets/contact-info.php Co-authored-by: Brad Jorsch --- projects/plugins/jetpack/modules/widgets/contact-info.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/modules/widgets/contact-info.php b/projects/plugins/jetpack/modules/widgets/contact-info.php index 57f09c9c19b57..d1f769b630771 100644 --- a/projects/plugins/jetpack/modules/widgets/contact-info.php +++ b/projects/plugins/jetpack/modules/widgets/contact-info.php @@ -164,7 +164,7 @@ public function widget( $args, $instance ) { } if ( - ! empty( $instance['email'] ) + $instance['email'] && is_email( trim( $instance['email'] ) ) ) { printf(