-I believe in 3e there was either an actual spell or a class ability from some prestige class that repaired portals. In terms of do-it-yourself for a game, I'd say it would probably be some combination of knowledge: arcana and performing the correct ritual.
(A Tri-Partite Arcanist Who Has Forgotten More Than Most Will Ever Know)
It's probably faster, easier, simpler (and safer) to seal a broken portal then create a new portal from scratch. Unless you're just too low-level to cast things like teleport and gate - in which case your only options are to gain experience or to risk going wherever the bad portal might take you.