Web domain update via remote API might cause impaired ISPConfig frontend and database
Whenever a web domain is created, either via the frontend or via the Remote API, certain fields are mandatory, required to be not-empty, unique, or have to be formatted in a predefined way according to the rules in web_domain.tform.php
Now, when one uses the remote API to update a web domain, and uses only the required fields stated in web_domain.tform.php, plus any fields that need to change, for example 'redirect_path' and 'redirect_type', the following occurs after running /usr/local/ispconfig/server/server.sh:
- The web_domain will be set to inactive.
- The syntax of /etc/httpd/conf/sites-available/web_domain.vhost file becomes invalid (ip address missing).
- Options are lost from the apache vhost config-file.
- Key settings to the web_domain table for the domain are at least reset to default values in the ispconfig database.
- The web_domain will never ever become visible again in the frontend, so you cannot delete, modify, or perform any action on the web_domain from the frontend, since certain fields that the frontend needs to display a web domain are empty in the database.
The following example shows the original values in the web_domain database table before the update -with required fields filled in-.
ip_address => '*', type => 'vhost', vhost_type => 'name', error_docs => 1, subdomain => 'www', php => 'fast-cgi', stats_type => 'webalizer', backup_interval => 'none', active => 'y'
The values after the update:
ip_address => '', type => '', vhost_type => '', error_docs => 0, subdomain => '', php => '', stats_type => '', backup_interval => '', active => 'n'
IMHO most of these fields should be mandatory in web_domain.tform.php because lack of them seriously impair the system.
Example PHP code that will cause this bug:
$params = array( 'server_id' => 1, 'domain' => 'example.com', 'hd_quota' => 100, 'traffic_quota' => 1000, 'document_root' => '/var/www/example.com/web', 'system_user' => 'web123', 'system_group' => 'client456', 'allow_override' => 'All', 'php_open_basedir' => '/var/www/example.com/web:/var/www/client456/web123/web:/var/tmp', 'redirect_path' => $redirect_path, 'redirect_type' => $redirect_type, ); $update = $soapclient->sites_web_domain_update($session_id, $client_id, $domain_id, $params);
A workaround for API users might be to get the values from sites_web_domain_get(), rewrite the values of the keys that need to be changed, and use that to feed sites_web_domain_update().