Skip to content

Commit ce9a726

Browse files
Copilotswissspidy
andcommitted
Short-circuit early in remove_old_files_from_list() before expensive realpath calls
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 17a6032 commit ce9a726

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Core_Command.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,12 @@ private function remove_old_files_from_list( $files ) {
19721972

19731973
$file_path = ABSPATH . $file;
19741974

1975+
// Short-circuit early: skip expensive realpath validation if the path
1976+
// doesn't exist and isn't a (potentially broken) symlink.
1977+
if ( ! file_exists( $file_path ) && ! is_link( $file_path ) ) {
1978+
continue;
1979+
}
1980+
19751981
// For symlinks, validate the symlink itself is within ABSPATH (not where it points)
19761982
// For other files, validate the real path is within ABSPATH
19771983
if ( is_link( $file_path ) ) {

0 commit comments

Comments
 (0)