diff --git src/wp-admin/includes/class-wp-filesystem-direct.php src/wp-admin/includes/class-wp-filesystem-direct.php
index 1676a55658..f359e7207e 100644
|
|
class WP_Filesystem_Direct extends WP_Filesystem_Base { |
333 | 333 | } |
334 | 334 | $file = str_replace( '\\', '/', $file ); // For Win32, occasional problems deleting files otherwise. |
335 | 335 | |
336 | | if ( 'f' == $type || $this->is_file( $file ) ) { |
337 | | return @unlink( $file ); |
| 336 | if ( 'f' == $type || $this->is_file( $file ) || $this->is_link( $file ) ) { |
| 337 | if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) && |
| 338 | $this->is_link( $file ) && $this->is_dir( $file ) ) { |
| 339 | // on windows unlink()'ing a symlink that points to a directory fails. |
| 340 | // @link https://bugs.php.net/bug.php?id=52176 |
| 341 | return @rmdir( $file ); |
| 342 | } |
| 343 | else { |
| 344 | // untrailingslashit() needed to remove symlinks successfully. |
| 345 | return @unlink( untrailingslashit( $file ) ); |
| 346 | } |
338 | 347 | } |
339 | 348 | if ( ! $recursive && $this->is_dir( $file ) ) { |
340 | 349 | return @rmdir( $file ); |
… |
… |
class WP_Filesystem_Direct extends WP_Filesystem_Base { |
372 | 381 | return @file_exists( $file ); |
373 | 382 | } |
374 | 383 | |
| 384 | /** |
| 385 | * Checks if resource is a symbolic link. |
| 386 | * |
| 387 | * @since 5.5.0 |
| 388 | * |
| 389 | * @param string $file File path. |
| 390 | * @return bool Whther `$file` is a symbolic link. |
| 391 | */ |
| 392 | public function is_link( $file ) { |
| 393 | // Strip trailing slashes, to avoid directory symlinks resolving. |
| 394 | return @is_link( untrailingslashit( $file ) ); |
| 395 | } |
| 396 | |
375 | 397 | /** |
376 | 398 | * Checks if resource is a file. |
377 | 399 | * |
… |
… |
class WP_Filesystem_Direct extends WP_Filesystem_Base { |
558 | 580 | * } |
559 | 581 | */ |
560 | 582 | public function dirlist( $path, $include_hidden = true, $recursive = false ) { |
561 | | if ( $this->is_file( $path ) ) { |
| 583 | if ( $this->is_dir( $path ) && $this->is_link( $path ) ) { |
| 584 | // Directory is a symlink, therefore return no listing. |
| 585 | return array(); |
| 586 | } |
| 587 | elseif ( $this->is_file( $path ) || $this->is_link( $path ) ) { |
562 | 588 | $limit_file = basename( $path ); |
563 | 589 | $path = dirname( $path ); |
564 | 590 | } else { |
… |
… |
class WP_Filesystem_Direct extends WP_Filesystem_Base { |
603 | 629 | $struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] ); |
604 | 630 | $struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f'; |
605 | 631 | |
606 | | if ( 'd' == $struc['type'] ) { |
| 632 | if ( 'd' == $struc['type'] && ! $this->is_link( $path . '/' . $struc['name'] ) ) { |
607 | 633 | if ( $recursive ) { |
608 | 634 | $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive ); |
609 | 635 | } else { |