WordPress.org

Make WordPress Core

Opened 2 months ago

Closed 2 months ago

Last modified 7 weeks ago

#48949 closed defect (bug) (worksforme)

ftp_rmdir(): Remove directory operation failed.

Reported by: didax Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.3
Component: Upgrade/Install Keywords: has-patch
Focuses: Cc:

Description

Whenever you need to update a plugin, this error is triggered:

Warning: ftp_rmdir(): Remove directory operation failed. in /wp-admin/includes/class-wp-filesystem-ftpext.php on line 381

when

define('FS_METHOD', 'ftpext');

is defined inside wp_config.php.

In this situation, the error seems to be caused by the deleting attemp of .maintenance file.
In this scenario the delete method of the class-wp-filesystem-ftpext.php is called with $recursive = false.
So, when .maintenance file not exists the condition on line 377 of class-wp-filesystem-ftpext.php is not executed and the next condition on line 380 is reached.
ftp_rmdir returns (rightly) a fault.

Attachments (1)

48949.diff (564 bytes) - added by anubisthejackle 2 months ago.

Download all attachments as: .zip

Change History (5)

#1 follow-up: @anubisthejackle
2 months ago

  • Keywords has-patch added; needs-patch removed

Something like the attached patch should do the trick: Verify the directory exists before attempting to run the delete on it.

#2 in reply to: ↑ 1 @didax
2 months ago

Yes, that's fine.

I think that the check can be placed before (outside the conditional statement) and simply return true because the file/dir was deleted.

Replying to anubisthejackle:

Something like the attached patch should do the trick: Verify the directory exists before attempting to run the delete on it.

#3 @didax
2 months ago

  • Resolution set to worksforme
  • Status changed from new to closed

This is my solution...

if ( empty( $file ) ) {
    return false;
}
if ( ! $this->exists( $file ) ) {
    return true;
}
if ( 'f' == $type || $this->is_file( $file ) ) {
    return ftp_delete( $this->link, $file );
}
if ( ! $recursive ) {
    // ...
    // ...

Last edited 2 months ago by didax (previous) (diff)

#4 @netweb
7 weeks ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.