Which Photon would win the race?
It seems to me that your central question is: Does the particular lensed path light travels on affect its arrival time? If so, the answer is a resounding yes, with evidence from astronomy! For example, the Twin Quasar (https://en.wikipedia.org/wiki/Twin_Quasar) is a system consisting of two images of the same quasar, which traveled different paths to the observer and hence generate two different images. The interesting part of this is that one of the images is 400 days behind the other! Researchers identify this difference with a path length difference of 1.1 ly. So it seems that the photon with shorter path length (i.e. photon #1) would win.
To anticipate some attacks involving the fact that space is curved around a massive object and so maybe photon #2 wins, I say that the problem never provides dimensions, in particular the vertical separation between points A and B. Take those two points far enough away from each other, and it becomes extremely clear that, at least in this limit, photon 1 wins. At that point the total relative alteration to photon 1's path becomes miniscule, but photon 2 still has to travel in quite a large arc. My argument here is that since the Sun is (hopefully) not (yet) a compact object, but instead has a rather low density, significant curvature will not be seen within its body. Therefore, the same gentle-curvature limit should apply in all reasonable cases.