# HG changeset patch # User Nathan Phillip Brink # Date 2011-03-22 00:32:41 # Node ID 34aabb706e1834dcff663f5b7bc94ddd48b357da # Parent 150d5bddeadc8854aa37e9ca0d8abb5d6d1a5ed0 Fix some php errors by removing empty courses completely. This case was not caught before because courses may appear to be nonempty during the parsing of POST data. Thus, an additional filtering process was added. diff --git a/inc/class.schedule.php b/inc/class.schedule.php --- a/inc/class.schedule.php +++ b/inc/class.schedule.php @@ -154,6 +154,19 @@ class Schedule //-------------------------------------------------- function findPossibilities() { + /* + * Clean crud (completely empty courses) out of the + * schedule. For some crud, it's much easier to detect that + * it's crud now than during parsing of postData[]. + */ + foreach ($this->courses as $i => $course) + if (!$course->getnsections()) + { + unset($this->courses[$i]); + $this->courses = array_values($this->courses); + return $this->findPossibilities(); + } + $this->possiblePermutations = 1; /* special case: there is nothing entered into the schedule and thus there is one, NULL permutation */ if (!count($this->courses)) diff --git a/process.php b/process.php --- a/process.php +++ b/process.php @@ -178,7 +178,7 @@ if(!$DEBUG) /* Skip the section name, which isn't a section */ if(is_array($section)) { - $error_string = $allClasses->addSection($class['name'], $section['letter'], $section['start'], $section['end'], arrayToDays($section['days'], 'alpha'), $section['synonym'], $section['professor'], $section['location'], $section['type']); + $error_string = $allClasses->addSection($class['name'], $section['letter'], $section['start'], $section['end'], arrayToDays(empty($section['days']) ? array() : $section['days'], 'alpha'), $section['synonym'], $section['professor'], $section['location'], $section['type']); if ($error_string !== NULL) $errors[] = $error_string; }