Ensure compatibility patches are only applied once.
Review Request #11899 — Created Jan. 2, 2022 and submitted
apply_patches()can technically be called more than once, which could
result in some bad patches. As a precaution, it now checks if it's been
called before, and if so, it bails.
Unit tests pass.