Mahler was a servant of the Great Intelligence who was in a position of authority, answering only to Rosemary Kizlet.
Before falling under the influence of the Intelligence, Mahler intended to fix the Shard's toilets. However, following his conversion the Intelligence's influence caused him to affect a more upper class demeanour, wearing glasses, changing his accent and working in the offices.
When Miss Kizlet was absorbed into the Wi-Fi in 2013, the Eleventh Doctor altered his propensity to obey, causing Mahler to free her and the rest of the data cloud.
Soon after, the Intelligence removed its influence from its servants, which freed Mahler's original personality, leaving no memory of how he came to be there for so long. The puzzled man noticed the passage of time when he saw his clothes were different than those he wore when he first arrived to fix the toilets at the Shard. (TV: The Bells of Saint John)