Backported r11196 from trunk (#7510).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.2-stable@11229 e93f8b46-1217-0410-a6f0-8f06a7374b81
Merged r11159 from trunk (#12799).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.2-stable@11230 e93f8b46-1217-0410-a6f0-8f06a7374b81
Backported r11157 and r11158 from trunk (#12801).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.2-stable@11231 e93f8b46-1217-0410-a6f0-8f06a7374b81