Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: directory file list step to properly handle glob returns #815

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions classes/local/step/directory_file_list_trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,17 @@ public function run() {
$this->get_engine()->abort($error);
}

// Get the list of files.
$pathpattern = $path . DIRECTORY_SEPARATOR . $pattern;
$filelist = glob($pathpattern, GLOB_BRACE) || [];
if ($filelist !== false) {
$this->apply_list_constraints($filelist, $returnvalue, $config->sort, $offset, $limit, $includedir, $path);
$filelist = glob($pathpattern, GLOB_BRACE);
if (empty($filelist)) {
$this->log->notice("No files returned", ['pattern' => $pathpattern]);
return [];
}

// Apply constraints.
$filelist = $this->apply_list_constraints($filelist, $returnvalue, $config->sort, $offset, $limit, $includedir, $path);

return $filelist;
}

Expand Down Expand Up @@ -178,7 +183,7 @@ public function validate_for_run() {
* @param bool $includedir
* @param string $basepath
* @param string $pattern
* @return array Will return true or an array of errors.
* @return array new file list
*/
public function apply_list_constraints(
array $filelist,
Expand Down
Loading