Ported #2604 fix by @sovainfo

Ported #2604 fix by @sovainfo.

http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=32618&start=0