WordPress.org

Make WordPress Core

Opened 8 hours ago

Last modified 6 hours ago

#49889 new enhancement

Image.php - Wrap Error Suppressors in WP_DEBUG Conditionals

Reported by: Howdy_McGee Owned by:
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch dev-feedback
Focuses: coding-standards Cc:

Description

Ideally, we want to remove all PHP error suppression flags. In some cases this may not be optimal so an alternative is to wrap any necessary suppressors in a WP_DEBUG conditional:

if( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
	$imagesize = getimagesize( $file );
} else {
	$imagesize = @getimagesize( $file );
}

This ticket is to track anything and everything we can do to minimize the suppression flags in the image.php file.

Attachments (1)

49889.diff (3.2 KB) - added by Howdy_McGee 8 hours ago.
WP_DEBUG Wrapped

Download all attachments as: .zip

Change History (4)

@Howdy_McGee
8 hours ago

WP_DEBUG Wrapped

#1 @Howdy_McGee
7 hours ago

  • Keywords has-patch dev-feedback added

This patch wraps all @ suppressed methods with WP DEBUG conditionals. If anyone has ideas to further minimize the suppressed methods please submit an additive patch. Related to #24780 ( Spreadsheet )

#2 @SergeyBiryukov
7 hours ago

  • Milestone changed from Awaiting Review to 5.5

Thanks for the patch!

With ~15 instances of @getimagesize() in core, I think it would make sense to introduce wp_get_image_size() as a wrapper with the defined( 'WP_DEBUG' ) && WP_DEBUG check, to avoid repetition.

@iptcparse() and @exif_read_data(), on the other hand, are only used once or twice, so probably don't need a wrapper at this point.

This ticket was mentioned in Slack in #core by howdy_mcgee. View the logs.


6 hours ago

Note: See TracTickets for help on using tickets.