Create a course with outcomes.
Add a new forum and associate it with an outcome, but do not set ratings for the forum (this will result in no grade item being created).
When saving a warning will result:
Notice: Undefined variable: outcomeexists in /PATH/modlib.php on line 296
It's basically caused by having outcomeexists defined in the if($items) because an unrated forum will have no grade item. I suspect it would be safe to just move the declaration of outcomeexists outside the if statement.