During the time of the Messenger of Allah ﷺ, a man would speak to his companion during the prayer about something he needed, until this verse was revealed, "Guard strictly the prayers, especially the middle prayer, and stand before Allah devoutly obedient" [Baqarah 2:238]. We were then commanded to remain silent.
أخبرنا إسمعيل بن مسعود قال حدثنا يحيى بن سعيد قال حدثنا إسمعيل بن أبي خالد قال حدثني الحارث بن شبيل عن أبي عمرو الشيباني
كان الرجل يكلم صاحبه في الصلاة بالحاجة على عهد رسول الله ﷺ حتى نزلت هذه الآية {حافظوا على الصلوات والصلاة الوسطى وقوموا لله قانتين} فأمرنا بالسكوت
Bukhari narrated it in the Tafsir, chapter, "Stand before Allah in humble devotion," no. 4534, from the hadith of Yahya bin Saeed Qattan.Muslim narrated it in the Mosques, chapter on the prohibition of speaking during prayer and the abrogation of what had been permitted of it, no. 539, from the hadith of Ismail bin Abu Khalid, with the same wording.It is also in Al-Kubra, no. 557.