Ported bug fix for issue 27863 to J! 3.x

As the bugfix for 2.5.x for issue 27863 has never been ported to the 3.x branch, it's still present. This pull request fixes the issue. 

2.5 issue: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=27863