Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion pinc/CharSuites.inc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ class CharSuites
return;
}

$charsuite_files = glob($relPath."charsuite-*.inc");
if (($charsuite_files = glob($relPath."charsuite-*.inc")) === false) {
throw new RuntimeException(_("Failed to load CharSuites files."));
}
foreach ($charsuite_files as $charsuite_file) {
include($charsuite_file);
}
Expand Down
14 changes: 12 additions & 2 deletions pinc/Project.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,12 @@ class Project
$db_names = $this->get_page_names_from_db();

chdir($this->dir);
$disk_names = glob("*.{png,jpg}", GLOB_BRACE);
if (($disk_names = glob("*.{png,jpg}", GLOB_BRACE)) === false) {
throw new RuntimeException(sprintf(
_("Failed to list page images for %s."),
$this->projectid
));
}
sort($disk_names);
return array_intersect($db_names, $disk_names);
}
Expand Down Expand Up @@ -1347,7 +1352,12 @@ class Project
$page_image_names = $this->get_page_names_from_db();

chdir($this->dir);
$existing_image_names = glob("*.{png,jpg}", GLOB_BRACE);
if (($existing_image_names = glob("*.{png,jpg}", GLOB_BRACE)) === false) {
throw new RuntimeException(sprintf(
_("Failed to list page images for %s."),
$this->projectid
));
}
sort($existing_image_names);
return array_diff($existing_image_names, $page_image_names);
}
Expand Down
8 changes: 7 additions & 1 deletion pinc/archiving.inc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ function archive_project(Project $project, bool $dry_run = false): void
echo " Move $project_dir to $new_dir.\n";
} else {
// Remove uncompressed versions of whole-project texts, leaving zips.
foreach (glob("$project_dir/projectID*.txt") as $filename) {
if (($filenames = glob("$project_dir/projectID*.txt")) === false) {
throw new RuntimeException(sprintf(
_("Failed to list whole-project texts when archiving %s."),
$projectid
));
}
foreach ($filenames as $filename) {
if (!unlink($filename)) {
throw new RuntimeException(sprintf(_("Unable to delete %s"), $filename));
}
Expand Down
6 changes: 4 additions & 2 deletions pinc/iso_lang_list.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ function get_languages_with_dictionaries(): array
global $aspell_prefix;

$returnArray = [];

foreach (glob("$aspell_prefix/lib/aspell/*.multi") as $filename) {
if (($filenames = glob("$aspell_prefix/lib/aspell/*.multi")) === false) {
throw new RuntimeException(_("Failed to list aspell dictionaries."));
}
foreach ($filenames as $filename) {
// dictionaries need to map to a two- or three-letter language code
if (preg_match("#/(\w{2,3})\.multi\$#", $filename, $matches)) {
$langname = langname_for_langcode($matches[1]);
Expand Down
7 changes: 6 additions & 1 deletion pinc/project_quick_check.inc
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,12 @@ function _test_project_for_illo_images(string $projectid): PQCResult
$page_image_names = $project->get_page_names_from_db();

chdir($project->dir);
$existing_image_names = glob("*.{png,jpg}", GLOB_BRACE);
if (($existing_image_names = glob("*.{png,jpg}", GLOB_BRACE)) === false) {
throw new RuntimeException(sprintf(
_("Failed to list page images for %s."),
$project->projectid
));
}
// That returns a sorted list of the .png files
// followed by a sorted list of the .jpg files,
// but we want the two lists interleaved...
Expand Down
10 changes: 6 additions & 4 deletions pinc/showavailablebooks.inc
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,13 @@ function show_project_listing(
// Uploaded is a special case because it is pulled from the
// filesystem and not from the database, and is hence not sortable.
global $projects_dir;
if ($done_files = glob("$projects_dir/{$book['projectid']}/*smooth_done_*.zip")) {
$num_done = count($done_files);
} else {
$num_done = 0;
if (($done_files = glob("$projects_dir/{$book['projectid']}/*smooth_done_*.zip")) === false) {
throw new RuntimeException(sprintf(
_("Failed to list smoothread uploads for %s."),
$book['projectid']
));
}
$num_done = count($done_files);
$cell = $num_done;
} elseif ($col_id == "days_avail" || $col_id == "days_left") {
$cell = sprintf("%.1f", $book[$col_id]);
Expand Down