-
Notifications
You must be signed in to change notification settings - Fork 43
Milestone
Description
Description
The Plugin Check GitHub Action is failing with the following errors:
Error: unlink() is discouraged. Use wp_delete_file() to delete a file.
Error: unlink() is discouraged. Use wp_delete_file() to delete a file.
Error: Process completed with exit code 1.
The issue is in includes/Abilities/Image/Import_Base64_Image.php where unlink() is being used to clean up temporary files. WordPress coding standards require using wp_delete_file() instead of the native PHP unlink() function.
Affected lines:
- Line 245: Error handling when writing to temp file fails
- Line 279: Cleanup of temp file after
media_handle_sideload()
Step-by-step reproduction instructions
- Push code to any branch that includes
includes/Abilities/Image/Import_Base64_Image.php - Wait for GitHub Actions to run
- Check the "Plugin Check Plugin" workflow
- Observe the failure with the
unlink()deprecation errors
Code snippet
Line 245:
if ( false === $bytes_written ) {
@unlink( $temp_file ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, Generic.PHP.NoSilencedErrors.Forbidden, WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink
return new WP_Error(
'write_failed',
esc_html__( 'Failed to write image data to temporary file.', 'ai' )
);
}Line 279:
// Clean up temp file if it still exists.
if ( file_exists( $temp_file ) ) {
@unlink( $temp_file ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, Generic.PHP.NoSilencedErrors.Forbidden, WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink
}Environment info
- Affected branches:
developand any branch based on it
The commit 36e080b that added the unlink() call belongs to the #134 PR that was merged on Dec 12, 2025
The "Plugin Check" GitHub Action was added on #139 that was also merged on Dec 12, 2025
It seems The "Plugin Check" GitHub Action has been failing since then.
Proposed Solution
Replace both unlink() calls with wp_delete_file():
Line 245:
if ( false === $bytes_written ) {
wp_delete_file( $temp_file );
return new WP_Error(
'write_failed',
esc_html__( 'Failed to write image data to temporary file.', 'ai' )
);
}Line 279:
// Clean up temp file if it still exists.
if ( file_exists( $temp_file ) ) {
wp_delete_file( $temp_file );
}This change will:
- Comply with WordPress coding standards
- Fix the Plugin Check CI failures
- Remove the need for phpcs:ignore comments on these lines
cc: @dkotter
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done