This is to track the regression introduced in master, which needs fixing for 0.14. See #9240, #9371, etc.
{
    const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1;
    
    int nLockTimeFlags = 0;
    if (VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_CSV, versionbitscache) == THRESHOLD_ACTIVE) {
        nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST;
    }
    int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST)
                              ? pindexPrev->GetMedianTimePast()
                              : block.GetBlockTime();
    
    for (const auto& tx : block.vtx) {