diff --git a/src/wp-admin/includes/class-wp-filesystem-direct.php b/src/wp-admin/includes/class-wp-filesystem-direct.php
index 9b1757cc65..9a7efec0a2 100644
a
|
b
|
class WP_Filesystem_Direct extends WP_Filesystem_Base { |
332 | 332 | } |
333 | 333 | $file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise |
334 | 334 | |
335 | | if ( 'f' == $type || $this->is_file( $file ) ) { |
336 | | return @unlink( $file ); |
| 335 | if ( 'f' == $type || $this->is_file( $file ) || $this->is_link( $file ) ) { |
| 336 | if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) && |
| 337 | $this->is_link( $file ) && $this->is_dir( $file ) ) { |
| 338 | // on windows unlink()'ing a symlink that points to a directory fails. |
| 339 | // @link https://bugs.php.net/bug.php?id=52176 |
| 340 | return @rmdir( $file ); |
| 341 | } |
| 342 | else { |
| 343 | // rtrim() needed to remove symlinks successfully. |
| 344 | return @unlink( rtrim( $file, '/' ) ); |
| 345 | } |
337 | 346 | } |
338 | 347 | if ( ! $recursive && $this->is_dir( $file ) ) { |
339 | 348 | return @rmdir( $file ); |
… |
… |
class WP_Filesystem_Direct extends WP_Filesystem_Base { |
383 | 392 | return @is_file( $file ); |
384 | 393 | } |
385 | 394 | |
| 395 | /** |
| 396 | * Checks if resource is a symbolic link. |
| 397 | * |
| 398 | * @since 5.3.0 |
| 399 | * |
| 400 | * @param string $file File path. |
| 401 | * @return bool Whether $file is a symbolic link. |
| 402 | */ |
| 403 | public function is_link( $file ) { |
| 404 | // Strip trailing slashes, to avoid directory symlinks resolving. |
| 405 | return @is_link( rtrim( $file, '/' ) ); |
| 406 | } |
| 407 | |
386 | 408 | /** |
387 | 409 | * Checks if resource is a directory. |
388 | 410 | * |
… |
… |
class WP_Filesystem_Direct extends WP_Filesystem_Base { |
557 | 579 | * } |
558 | 580 | */ |
559 | 581 | public function dirlist( $path, $include_hidden = true, $recursive = false ) { |
560 | | if ( $this->is_file( $path ) ) { |
| 582 | if ( $this->is_dir( $path ) && $this->is_link( $path ) ) { |
| 583 | // Directory is symlink, therefore return no listing. |
| 584 | return array(); |
| 585 | } |
| 586 | elseif ( $this->is_file( $path ) || $this->is_link( $path ) ) { |
561 | 587 | $limit_file = basename( $path ); |
562 | 588 | $path = dirname( $path ); |
563 | 589 | } else { |
… |
… |
class WP_Filesystem_Direct extends WP_Filesystem_Base { |
602 | 628 | $struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] ); |
603 | 629 | $struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f'; |
604 | 630 | |
605 | | if ( 'd' == $struc['type'] ) { |
| 631 | if ( 'd' == $struc['type'] && ! $this->is_link( $path . '/' . $struc['name'] ) ) { |
606 | 632 | if ( $recursive ) { |
607 | 633 | $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive ); |
608 | 634 | } else { |