Injury to formations bearing oil or gas or to oil or gas wells caused by the subsurface migration of any substance as a result of secondary recovery operations for oil or gas conducted in accordance with good oilfield practices shall not be grounds for enjoining the secondary recovery operations if an undertaking is given for the payment of any compensable damages to which the owners of interests in the formations or wells may be entitled resulting from the injury. Any benefit to the injured property from the secondary recovery operation shall be considered in mitigation of damages for the injury.