Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Janitorial: Handle deprecation notices found in wild #41733

3 changes: 1 addition & 2 deletions projects/packages/videopress/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Prevent deprecation notices on PHP 8.
7 changes: 7 additions & 0 deletions projects/packages/videopress/src/class-divi.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ class Divi {
**/
private $running = false;

/**
* VideoPress Divi Extension object.
*
* @var ?\VideoPress_Divi_Extension
**/
private $vidi_extension;

/**
* Initializes VideoPress/Divi integration.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Prevent deprecation notices on PHP 8.
2 changes: 1 addition & 1 deletion projects/plugins/jetpack/class.jetpack-post-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,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 );
if ( str_ends_with( $img_host, '.files.wordpress.com' ) ) {
if ( $img_host && str_ends_with( $img_host, '.files.wordpress.com' ) ) {
return add_query_arg(
array(
'w' => $width,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,9 @@ class_exists( 'Jetpack_AMP_Support' )
* @return string
*/
public function add_data_img_tags_and_enqueue_assets( $content ) {
if ( ! is_string( $content ) || $content === '' ) {
return '';
}
if (
class_exists( 'Jetpack_AMP_Support' )
&& Jetpack_AMP_Support::is_amp_request()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ?? '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding that fallback before the filter happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't catch the edge case where the value is filtered and returns null.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there broken filter implementations that do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know in the wild that there are quite a few instances that result in $text being null. We don't know what causes them, or if it's before vs. after the filter, but either could be possible and this catches both.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the cause is a code path through the function that doesn't return.

// ensure our paragraphs are separated.
$text = str_replace( array( '</p><p>', "</p>\n<p>" ), "</p>\n\n<p>", $text );
// visual editor likes to add <p>s. Buh-bye.
Expand Down
5 changes: 4 additions & 1 deletion projects/plugins/jetpack/modules/widgets/contact-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ public function widget( $args, $instance ) {
}
}

if ( is_email( trim( $instance['email'] ) ) ) {
if (
$instance['email']
&& is_email( trim( $instance['email'] ) )
) {
printf(
'<div class="confit-email"><a href="mailto:%1$s">%1$s</a></div>',
esc_html( $instance['email'] )
Expand Down
Loading