[wp-trac] [WordPress Trac] #61590: Make wp_delete_file return to be compliant both with PHP and WPCS
WordPress Trac
noreply at wordpress.org
Mon Jul 8 04:12:23 UTC 2024
#61590: Make wp_delete_file return to be compliant both with PHP and WPCS
----------------------------+-----------------------------
Reporter: bedas | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Filesystem API | Version: trunk
Severity: normal | Keywords: 2nd-opinion
Focuses: |
----------------------------+-----------------------------
When you use unlink() you can check if it was successful via the return
value of unlink().
But WPCS expects us to use wp_delete_file() which does not return, making
it impossible to check if it was successful, without doing overhead checks
if the file still exists.
I suggest returning the value of unlink in wp_delete_file so we can
actually comply with WPCS while still using PHP features.
{{{#!php
function wp_delete_file( $file ) {
/**
* Filters the path of the file to delete.
*
* @since 2.1.0
*
* @param string $file Path to the file to delete.
*/
$delete = apply_filters( 'wp_delete_file', $file );
if ( ! empty( $delete ) ) {
return @unlink( $delete );
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61590>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list