The prev. code "explode(",", $this->flavorParamsIds)" is a bug IMO, because for a null value, the result is:
array(1) {
  [0]=>
  string(0) ""
}

The empty string is misleading, because PHP will regard it as 0 (zero) when iterating the array, causing client code to look for a flavor param with id 0.