Skip to content

Commit

Permalink
Check the return value of glob() (#9946)
Browse files Browse the repository at this point in the history
Fixes #9213.
  • Loading branch information
pento authored Sep 18, 2018
1 parent c9d3669 commit 826395b
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,19 @@


// Register server-side code for individual blocks.
foreach ( glob( dirname( __FILE__ ) . '/../block-library/*/index.php' ) as $block_logic ) {
require $block_logic;
}
foreach ( glob( dirname( __FILE__ ) . '/../packages/block-library/src/*/index.php' ) as $block_logic ) {
require $block_logic;
$paths = array(
dirname( __FILE__ ) . '/../block-library/*/index.php',
dirname( __FILE__ ) . '/../packages/block-library/src/*/index.php',
);

foreach ( $paths as $path ) {
$block_logic_files = glob( $path );
// glob() can sometimes return false if there's an error, or it couldn't find any files.
if ( ! $block_logic_files ) {
continue;
}

foreach ( $block_logic_files as $block_logic ) {
require $block_logic;
}
}

0 comments on commit 826395b

Please sign in to comment.