Fix for tracker #31256

Replaces GitHub PR #1364

http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=31256