Photons don't travel in straight lines through the Sun.
The Sun's core is incredibly dense and hot. Photons constantly collide with particles, changing direction and getting absorbed and re-emitted. This "random walk" process makes their journey incredibly slow.
Estimated Time:
It's estimated that it takes a photon hundreds of thousands of years to travel from the Sun's core to its surface.
Important Note: This is just an average. Some photons might take much longer or shorter depending on their specific path.