Skip to content

Commit f264c89

Browse files
authored
Update src/Checksum_Plugin_Command.php
1 parent 762e4ed commit f264c89

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

‎src/Checksum_Plugin_Command.php‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,20 +291,18 @@ private function get_all_plugin_names() {
291291
// Also scan the filesystem for plugin directories
292292
$plugin_dir = WP_PLUGIN_DIR;
293293
if ( is_dir( $plugin_dir ) && is_readable( $plugin_dir ) ) {
294-
$dirs = @scandir( $plugin_dir ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
295-
if ( false !== $dirs ) {
296-
foreach ( $dirs as $dir ) {
297-
// Skip special directories and files
298-
if ( '.' === $dir || '..' === $dir ) {
294+
try {
295+
foreach ( new DirectoryIterator( $plugin_dir ) as $fileinfo ) {
296+
if ( $fileinfo->isDot() || ! $fileinfo->isDir() || $fileinfo->isLink() ) {
299297
continue;
300298
}
301-
302-
$full_path = $plugin_dir . '/' . $dir;
303-
// Only include real directories, not symlinks or files
304-
if ( is_dir( $full_path ) && ! is_link( $full_path ) && ! in_array( $dir, $names, true ) ) {
299+
$dir = $fileinfo->getFilename();
300+
if ( ! in_array( $dir, $names, true ) ) {
305301
$names[] = $dir;
306302
}
307303
}
304+
} catch ( UnexpectedValueException $e ) {
305+
WP_CLI::warning( "Could not scan plugin directory '{$plugin_dir}': " . $e->getMessage() );
308306
}
309307
}
310308

0 commit comments

Comments
 (0)