Skip to content

Commit

Permalink
fix(Tests): check if property exists
Browse files Browse the repository at this point in the history
  • Loading branch information
harunbleech committed Oct 23, 2024
1 parent 80b890c commit 7cc3abc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions includes/core/utilities/class-image-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public static function alert_image_aspect_ratio( $alert ) {
*/
public static function get_screenshot_url( $object, $type, $size = 'full' ) {
$property = "${type}_screenshot_url";

if ( ! property_exists( $object, $property ) ) {
return '';
}

$url = 'preview' === $size ? maybe_unserialize( $object->meta )['preview_url'] ?? $object->$property : $object->$property;
return self::get_cloudfront_url( $url );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/features/class-enqueue-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function enqueue_block_editor_assets() {
'rest_url' => esc_url_raw( rest_url() ),
'has_post_alert' => Test::has_post_alert( $post->ID ),
'base_screenshot_url' => Image_Helpers::get_screenshot_url( $test, 'base' ),
'base_screenshot_date' => Date_Time_Helpers::get_formatted_date_time( $test->base_screenshot_date ),
'base_screenshot_date' => Date_Time_Helpers::get_formatted_date_time( $test->base_screenshot_date ?? null ),
'remaining_tests' => Subscription::get_remaining_tests(),
'total_tests' => Subscription::get_total_tests(),
'upgrade_url' => Url_Helpers::get_page_url( 'upgrade' ),
Expand Down

0 comments on commit 7cc3abc

Please sign in to comment.