The Serb, who learned on Wednesday that he would be back as world number one next week following Rafa Nadal's withdrawal from the tournament through injury, was leading 6-1 2-1 when the Bosnian submitted to a back problem that had flared up in the first set.
Dzumhur upset 14th-seeded Stefanos Tsitsipas 6-3, 6-3, while big-hitting Russian Karen Khachanov also advanced to the third round.
Yet his opponent, Milos Raonic, pulled out because of injury, leaving Federer to think that it had actually turned out to be a blessing in disguise.
Nadal won't be making a return trip to the final this year as he was forced to withdraw from the tournament due to an abdominal injury, and Murray's season has been over for a while now as he works his way back to full health.
Kevin Anderson of South Africa will come up against Nikoloz Basilashvili of Georgia, who beat several players ranked higher than him to win the China Open earlier this month. He led 6-2, 2-0 against Matthew Ebden when the Australian retired. "I feel like I recovered well from last week". "I enjoyed it [and] I felt in terms of tennis better than one week ago".
Federer applied pressure from the off and, with Fognini evidently vulnerable on his second serve, a swift break was secured as the Italian found the net.
"I was a bit bumpy".
Djokovic can regain top spot from Rafael Nadal this week if he betters the Spaniard's performance in the French capital, where the Serb is a four-time victor of the indoor tournament.
"Of course I'm aware of the situation".
"But it's not the end of the season, so I can't be too ecstatic about it". It has been a rapid, but rocky, ride back to the top for the man whose 14 grand slam titles put him behind only Nadal and Federer on the all-time list.
He then completed a sweep of Masters victories by downing Federer to claim an elusive Cincinnati title. "After that, I couldn't get any points on return, so I took some risks and played more aggressive, and I did it. So starting on Wednesday and winning five matches in a row with this caliber (of players) is very hard", Federer said. It's a great journey that I've had.
Raonic injured himself during a three-set win against Jo-Wilfried Tsonga on Tuesday.