The extra check here is incorrect. For generated keys the temp_zone should always be NULL. And if they are generated by OpenDNSSEC they will be in a repository. With this check in place all generated keys show as "NOT IN repository", which is incorrect. 
Please revert the change to this line.