Very slow MySQL Queries in mail_[user|forward|alias]_edit.php

short description

Affected files in interface/web/mail/ : mail_user_edit.php mail_forward_edit.php mail_alias_edit.php

The is a mysql query in the function onShowEnd() which returns the available domains for a user. The where clause in the mysql queries first searches for all domains which are not type aliasdomain and then it gets limited to the user domains. This can be very slow if you have a lot of Domains.

correct behaviour

If you swap the where clauses it's much more efficient. It saved about 10 seconds for every query.

environment

Server OS: ubuntu Server OS version: xenial ISPConfig version: 3.1.1p1

proposed fix

I try to create a merge request.