2.5.x Added same changes as in commit https://github.com/joomla/joomla-cms/commit/af510cc3026f783a475b811af4f7d35881e4ac90 for the joomla master (3) branch.