Skip to content

Commit 6065979

Browse files
authored
Merge pull request #164 from ComputerScienceHouse/develop
Fixing Parsing Error and Stopping 10,000+ schedules
2 parents 5fe7a53 + b3d162f commit 6065979

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

api/generate.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,19 @@ function pruneSpecialCourses($schedules, $courseGroups) {
391391
$courseGroupsByCourseId = array();
392392

393393
$courseSet = array();
394+
395+
// Check to make sure schedule wont exceed 10,000 options
396+
$totalSchedules = 1;
397+
for($i = 1; $i <= $_POST['courseCount']; $i++) {
398+
if(!isset($_POST["courses{$i}Opt"])) { continue; }
399+
$totalSchedules *= count($_POST["courses{$i}Opt"]);
400+
}
401+
if ($totalSchedules >= 10000){
402+
echo json_encode(array("error" => "argument", "msg" => "Too many schedule possibilities to generate, try to remove classes from your shopping cart.
403+
Adding classes like YearOne or classes with hundreds of sections can cause this to occur.", "arg" => "action"));
404+
break;
405+
}
406+
394407
for($i = 1; $i <= $_POST['courseCount']; $i++) { // It's 1-indexed... :[
395408
// Iterate over the courses in that course slot
396409
if(!isset($_POST["courses{$i}Opt"])) { continue; }

tools/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,4 @@ function procInstrArray(array $lineSplit): array {
293293
$lineSplit[4] = str_pad($lineSplit[4], 2, '0', STR_PAD_LEFT);
294294
return $lineSplit;
295295
}
296-
}
296+
}

tools/processDump.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@
299299
$row['course_descrlong'] = mysqli_real_escape_string($dbConn, $row['course_descrlong']);
300300

301301
// Insert or update the course
302-
$courseId = $parser->insertOrUpdateCourse($row['qtr'], $row['acad_org'], $row['subject'], $row['catalog_nbr'],
303-
$row['units'], $row['descr'], $row['course_descrlong']);
302+
@$courseId = $parser->insertOrUpdateCourse($row['qtr'], $row['acad_org'], $row['subject'], $row['catalog_nbr'],
303+
(int)$row['units'], $row['descr'], $row['course_descrlong']);
304304
if (!is_numeric($courseId)) {
305305
echo(" *** Error: Failed to update {$row['qtr']} {$row['subject']}-{$row['catalog_nbr']}\n");
306306
echo(" ");

0 commit comments

Comments
 (0)