Thābit likewise corroborated it from Abū Burdah with a similar wording.
Muslim and Aḥmad both record the report through Ḥammād b. Salamah from him; this version contains the first additional phrase and the third wording, although Muslim omits the clause “or a mosque.”
Layth—namely Ibn Abī Sulaym—also supports it in Aḥmad with a comparable narration.
In addition, the final wording appears in Aḥmad through the route of Abū Aḥmad: “Burayd b. ʿAbd Allāh related it to us from Abū Mūsā, who said: ‘When any of you passes …’” and so on.
This is how it occurs in the Musnad, stopping with Abū Mūsā; yet al-Ṭaḥāwī transmits it through the same line, by two routes from Abū Aḥmad, as a report traced back to the Prophet. I do not know whether the Musnad consciously recorded it in mawqūf form, or whether the attribution to the Prophet ﷺ dropped out by mistake.
The ḥadith, therefore, establishes the permissibility of passing through the mosque even when one is carrying a weapon. Al-Bukhārī, as noted earlier, headed a chapter with it, titling it, “Chapter: Passing through the Mosque.” Al-Ḥāfiẓ comments, “Meaning: it is permissible, a point inferred from the ḥadith itself by a fortiori reasoning.”
I would add, however, that this license should be confined to situations of need and kept infrequent, lest it turn the mosque into a regular thoroughfare, which has been prohibited, as mentioned above. Allah knows best.