Fix Wrong default number of project builds if BOM is empty #1038

This commit is contained in:
Marc 2025-09-18 11:04:52 +00:00 committed by Jan Böhmer
parent 7a1a458abe
commit 05839a549c
3 changed files with 18 additions and 8 deletions

View file

@ -63,17 +63,19 @@ class ProjectBuildHelper
*/
public function getMaximumBuildableCount(Project $project): int
{
$bom_entries = $project->getBomEntries();
if ($bom_entries->isEmpty()) {
return 0;
}
$maximum_buildable_count = PHP_INT_MAX;
foreach ($project->getBomEntries() as $bom_entry) {
foreach ($bom_entries as $bom_entry) {
//Skip BOM entries without a part (as we can not determine that)
if (!$bom_entry->isPartBomEntry()) {
continue;
}
//The maximum buildable count for the whole project is the minimum of all BOM entries
$maximum_buildable_count = min($maximum_buildable_count, $this->getMaximumBuildableCountForBOMEntry($bom_entry));
}
return $maximum_buildable_count;
}