McDonald’s second-quarter earnings topped estimates, but its revenue fell short of expectations partly due to closure of its Russian and Ukrainian restaurants.