Skip to content

Commit 9c049f7

Browse files
committed
Fix preg_match() usage when looking for extension type
https://www.php.net/manual/en/splfileobject.fgets.php may return False
1 parent d675556 commit 9c049f7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Drupal/ExtensionDiscovery.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,11 @@ protected function scanDirectory($dir): array
377377
$type = false;
378378
$file = $fileinfo->openFile('r');
379379
while (!$type && !$file->eof()) {
380-
preg_match('@^type:\s*(\'|")?(\w+)\1?\s*$@', $file->fgets(), $matches);
381-
if (isset($matches[2])) {
382-
$type = $matches[2];
380+
if ($line = $file->fgets()) {
381+
preg_match('@^type:\s*(\'|")?(\w+)\1?\s*$@', $line, $matches);
382+
if (isset($matches[2])) {
383+
$type = $matches[2];
384+
}
383385
}
384386
}
385387
if ($type === false) {

0 commit comments

Comments
 (0)