Skip to content
Prev Previous commit
Apply suggestions from code review
Co-authored-by: Copilot <[email protected]>
  • Loading branch information
kangzj and Copilot authored Dec 9, 2025
commit bd5a7b129326e625e540e5f2ba3e2a095d0c3905
9 changes: 6 additions & 3 deletions projects/packages/stats/src/class-wpcom-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,12 @@ protected function fetch_post_stats( $args, $post_id ) {
if ( ( time() - $time ) < $expiration ) {
$cached_value = $data[ $time ];

// If it's an array or WP_Error, add cached time and return to user.
if ( is_array( $cached_value ) || is_wp_error( $cached_value ) ) {
return array_merge( array( 'cached_at' => $time ), (array) $cached_value );
// If it's an array or WP_Error, handle appropriately.
if ( is_wp_error( $cached_value ) ) {
return $cached_value;
}
if ( is_array( $cached_value ) ) {
return array_merge( array( 'cached_at' => $time ), $cached_value );
}

// For any other unexpected type, treat as malformed cache.
Expand Down
Loading