The ban was in place for centuries, written or not. The free love 60s and 70s opened the seminaries to active homosexuality, and homosexuals in positions of power excluded potential seminarians who had traditional values.
As I understand it, homosexuals were permitted if they weren’t “active”; Benedict ended that.
Before the dearth of vocations following Vatican II, all of them were probably rejected out of hand; when the shortage of priests became acute, they probably started reviewing old files looking for the least risky...