Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Fix attempts to count possible non-countable variables or usage of undefined variables #11473

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/BlockTypes/ProductCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ function( $acc, $query ) {
*/
if (
! empty( $merged_query['post__in'] ) &&
is_array( $merged_query['post__in'] ) &&
count( $merged_query['post__in'] ) > count( array_unique( $merged_query['post__in'] ) )
) {
$merged_query['post__in'] = array_unique(
Expand Down
1 change: 1 addition & 0 deletions src/BlockTypes/ProductQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ function( $acc, $query ) {
*/
if (
! empty( $merged_query['post__in'] ) &&
is_array( $merged_query['post__in'] ) &&
count( $merged_query['post__in'] ) > count( array_unique( $merged_query['post__in'] ) )
) {
$merged_query['post__in'] = array_unique(
Expand Down
13 changes: 3 additions & 10 deletions src/StoreApi/Schemas/V1/ProductReviewSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ public function get_properties() {
* @return array
*/
public function get_item_response( $review ) {
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
$rating = get_comment_meta( $review->comment_ID, 'rating', true ) === '' ? null : (int) get_comment_meta( $review->comment_ID, 'rating', true );
$data = [
$rating = get_comment_meta( $review->comment_ID, 'rating', true ) === '' ? null : (int) get_comment_meta( $review->comment_ID, 'rating', true );
return [
'id' => (int) $review->comment_ID,
'date_created' => wc_rest_prepare_date_response( $review->comment_date ),
'formatted_date_created' => get_comment_date( 'F j, Y', $review->comment_ID ),
Expand All @@ -171,16 +170,10 @@ public function get_item_response( $review ) {
'product_permalink' => get_permalink( (int) $review->comment_post_ID ),
'product_image' => $this->image_attachment_schema->get_item_response( get_post_thumbnail_id( (int) $review->comment_post_ID ) ),
'reviewer' => $review->comment_author,
'review' => $review->comment_content,
'review' => wp_autop( $review->comment_content ),
'rating' => $rating,
'verified' => wc_review_is_from_verified_owner( $review->comment_ID ),
'reviewer_avatar_urls' => rest_get_avatar_urls( $review->comment_author_email ),
];

if ( 'view' === $context ) {
$data['review'] = wpautop( $data['review'] );
}

return $data;
}
}
2 changes: 1 addition & 1 deletion src/Templates/SingleProductTemplateCompatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ private static function has_single_product_template_blocks( $parsed_blocks ) {
private static function group_blocks( $parsed_blocks ) {
return array_reduce(
$parsed_blocks,
function( $carry, $block ) {
function( array $carry, array $block ) {
if ( 'core/template-part' === $block['blockName'] ) {
$carry[] = array( $block );
return $carry;
Expand Down
2 changes: 1 addition & 1 deletion templates/notices/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
exit;
}

if ( ! $notices ) {
if ( empty( $notices ) || ! is_array( $notices ) ) {
return;
}

Expand Down
Loading