Skip to content

Commit 831e197

Browse files
committed
Lint & test fixes
1 parent 6b30e73 commit 831e197

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/Core_Command.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,7 @@ private function remove_old_files_from_list( $files ) {
17151715
WP_CLI::debug( 'Failed to resolve ABSPATH realpath', 'core' );
17161716
return $count;
17171717
}
1718-
$abspath_realpath_trailing = trailingslashit( $abspath_realpath );
1718+
$abspath_realpath_trailing = Utils\trailingslashit( $abspath_realpath );
17191719

17201720
foreach ( $files as $file ) {
17211721
// wp-content should be considered user data
@@ -1748,14 +1748,11 @@ private function remove_old_files_from_list( $files ) {
17481748
} else {
17491749
WP_CLI::debug( "Failed to remove directory: {$file}", 'core' );
17501750
}
1751+
} elseif ( unlink( $file_path ) ) {
1752+
WP_CLI::log( "File removed: {$file}" );
1753+
++$count;
17511754
} else {
1752-
// Remove file
1753-
if ( unlink( $file_path ) ) {
1754-
WP_CLI::log( "File removed: {$file}" );
1755-
++$count;
1756-
} else {
1757-
WP_CLI::debug( "Failed to remove file: {$file}", 'core' );
1758-
}
1755+
WP_CLI::debug( "Failed to remove file: {$file}", 'core' );
17591756
}
17601757
}
17611758
}
@@ -1770,14 +1767,14 @@ private function remove_old_files_from_list( $files ) {
17701767
* @return bool True on success, false on failure.
17711768
*/
17721769
private function remove_directory( $dir ) {
1773-
$dir_realpath = realpath( $dir );
1770+
$dir_realpath = realpath( $dir );
17741771
$abspath_realpath = realpath( ABSPATH );
17751772
if ( false === $dir_realpath || false === $abspath_realpath ) {
17761773
WP_CLI::debug( "Failed to resolve realpath for directory or ABSPATH: {$dir}", 'core' );
17771774
return false;
17781775
}
17791776
// Normalize paths with trailing slashes for accurate comparison
1780-
if ( 0 !== strpos( $dir_realpath, trailingslashit( $abspath_realpath ) ) ) {
1777+
if ( 0 !== strpos( $dir_realpath, Utils\trailingslashit( $abspath_realpath ) ) ) {
17811778
WP_CLI::debug( "Attempted to remove directory outside of ABSPATH: {$dir_realpath}", 'core' );
17821779
return false;
17831780
}
@@ -1812,11 +1809,9 @@ private function remove_directory( $dir ) {
18121809
WP_CLI::debug( "Failed to remove subdirectory: {$path}", 'core' );
18131810
return false;
18141811
}
1815-
} else {
1816-
if ( ! unlink( $path ) ) {
1812+
} elseif ( ! unlink( $path ) ) {
18171813
WP_CLI::debug( "Failed to remove file in directory: {$path}", 'core' );
18181814
return false;
1819-
}
18201815
}
18211816
}
18221817

0 commit comments

Comments
 (0)