Fix Uncaught TypeError count(NULL) for php8+ in Marketing.php (https://github.com/woocommerce/woocommerce-admin/pull/8213)

* Fix Uncaught TypeError count(NULL) for php8+ in Marketing.php

* Add changelog
This commit is contained in:
Chi-Hsuan Huang 2022-01-26 22:42:03 +08:00 committed by GitHub
parent bfa445f600
commit 8281eac885
2 changed files with 5 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: Fix
Fix Uncaught TypeError count(NULL) for php8+ in Marketing.php. #8213

View File

@ -265,8 +265,7 @@ class Marketing {
'author_avatar' => isset( $raw_post['author_avatar_url'] ) ? $raw_post['author_avatar_url'] : '', 'author_avatar' => isset( $raw_post['author_avatar_url'] ) ? $raw_post['author_avatar_url'] : '',
]; ];
$featured_media = $raw_post['_embedded']['wp:featuredmedia']; $featured_media = $raw_post['_embedded']['wp:featuredmedia'] ?? [];
if ( count( $featured_media ) > 0 ) { if ( count( $featured_media ) > 0 ) {
$image = current( $featured_media ); $image = current( $featured_media );
$post['image'] = add_query_arg( $post['image'] = add_query_arg(