The query in get_taskbypolicy should limit results to tasks in the public space. Public tasks that were created before spaces could have space_phid set to NULL.