I tried applying your original patch and the later patch from that thread to REL_12_STABLE, unfortunately no luck on either. The original patch errors with:
error: src/backend/utils/adt/array_typanalyze.c: already exists in working directory
I just use the GNU "patch -p1" command. I don't know what "git apply" is up to here, and the error message isn't very informative.
By the way, the patch says "However, there is no histogram to fall back on when the MCE array is NULL", which is a bit of nonsense. It is ndistinct, not histogram, which the scalar case falls back on when MCV is NULL. But there isn't an ndistinct for MCE either, so the conclusion is still sound.