[2.5.x] #3465 to the 2.5.x branche

Backport the bugfix by @Kubik-Rubik to the 2.5 branche
https://github.com/joomla/joomla-cms/pull/3465

Tracker:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33624&start=0