Scottish Water has been fined £140,000 after a worker broke his back when he fell through an insecure floor into sewage at a pumping station.
James Anderson also suffered a broken collar bone and ribs in the fall at the Prestonpans station in East Lothian in June 2017.
Safety investigators found the floor had been damaged by floods over a number of years.
Scottish Water admitted breaching health and safety at work regulations.
In his sentencing statement at Edinburgh Sheriff Court, Sheriff Robert D M Fife said: "It would be reasonable to say this was an accident waiting to happen."
An agreed narrative provided to the court stated the practice for 10 years had been to work around the gaps in the floor until they could be refitted.
It said: "There was no safe system of work and no risk assessment. It was readily foreseeable that someone would eventually fall."
Sheriff Fife said: "Employees were working in an environment with sewage and at height.
"The potential for serious or very serious injury, including fatality, in the event of an accident was obvious."
Mr Anderson was in intensive care at the Royal Infirmary of Edinburgh for 10 days before being transferred to the Western General Infirmary where he remained for three weeks.
He underwent multiple operations on his head, with the wound twice becoming infected due to the bacterial build-up from the sewage he fell into.
A number of metal rods and pins were inserted into his spine and he was off work for nine months before a phased return in February 2018.
Lawyers for Scottish Water said failings did not occur as a result of a deliberate breach but because of an "honest oversight" in relation to one activity at one pumping station.
Peter Farrer, Scottish Water's chief operating officer, said: "This was a terrible accident which left one of our employees with serious injuries and it's important that we do everything possible to prevent something like this happening again."