API and web_domain.sys_groupid in case of $client_id=0
Following that discussion https://www.howtoforge.com/community/threads/api-and-groupid.87230/#post-424590
Summary
When creating a web site with API for admin, sys_groupid in web_domain table is set to 1 instead of 0 with web interface. This bug is almost invisible because as soon as you open web interface and look at domain, web interface will correct the problem (autosave when tab changing) Moreover it has no global impact on ISPConfig: I saw it because API request to that domain gives nothing in some cases
Steps to reproduce
- Run below script
#nano file
insert code and modify first variables as appropriate
<?php
//variables to adapt
$server='myserver.test.fr';
$remoteUser='myremoteuser';
$remotePassword='mypass';
$domain='test.test.fr';
$client_id=0;
//script
$remoteSoapLocation='https://'.$server.':8080/remote/index.php' ;
$remoteSoapUri='https://'.$server.':8080/remote/' ;
$context = stream_context_create([
'ssl' => [
'verify_host' => true,
'verify_peer' => true,
'verify_peer_name' => true,
'allow_self_signed' => false
]
]);
$client = new SoapClient(null,
array('location' => $remoteSoapLocation,
'uri' => $remoteSoapUri,
'trace' => 1,
'exceptions' => 1,
'stream_context' => $context));
$session_id = $client->login($remoteUser, $remotePassword) ;
$tstamp=date("Y-m-d H:i:s") ;
$params = array(
'server_id' => 1,
'ip_address' => '*',
'domain' => $domain,
'type' => 'vhost',
'parent_domain_id' => 0,
'vhost_type' => 'name',
'hd_quota' => -1,
'traffic_quota' => -1,
'cgi' => 'n',
'ssi' => 'n',
'ruby' => 'n',
'python' => 'n',
'perl' => 'n',
'suexec' => 'n',
'errordocs' => 1,
'is_subdomainwww' => 1,
'subdomain' => 'none',
'php' => 'php-fpm',
'redirect_type' => '',
'redirect_path' => '',
'seo_redirect' => 'www_to_non_www',
'rewrite_to_https' => 'y',
'ssl' => 'y',
'ssl_letsencrypt' => 'y',
'ssl_letsencrypt_exclude' => 'n',
'ssl_state' => '',
'ssl_locality' => '',
'ssl_organisation' => '',
'ssl_organisation_unit' => '',
'ssl_country' => '',
'ssl_domain' => '',
'ssl_request' => '',
'ssl_key' => '',
'ssl_cert' => '',
'ssl_bundle' => '',
'ssl_action' => '',
'stats_password' => 'toto_toto!',
'stats_type' => 'awstats',
'allow_override' => 'All',
'apache_directives' => '',
'php_fpm_use_socket' => 'y',
'php_fpm_chroot' => 'n',
'pm' => 'ondemand',
'pm_max_children' => 10,
'pm_start_servers' => 2,
'pm_min_spare_servers' => 1,
'pm_max_spare_servers' => 5,
'pm_process_idle_timeout' => 10,
'pm_max_requests' => 0,
'pm_max_requests' => 0,
'custom_php_ini' => '' ,
'backup_interval' => 'none',
'backup_copies' => 2,
'backup_format_web' => 'default',
'backup_format_db' => 'gzip',
'backup_encrypt' => 'n',
'backup_password' => '' ,
'backup_excludes' => '',
'active' => 'y',
'traffic_quota_lock' => 'n',
'http_port' => '80',
'https_port' => '443',
'log_retention' => 5 ,
'proxy_protocol' => 'n' ,
'added_date' => $tstamp ,
'added_by' => 'admin'
);
$sites_web_id = $client->sites_web_domain_add($session_id, $client_id, $params) ;
$client->logout($session_id) ;
?>
run code
#php file
#mysql
> select `sys_groupid` FROM `dbispconfig`.`web_domain` WHERE `domain` LIKE 'test.test.fr' ;
2. Open web_interface>sites>websites, open test.test.fr domain and save
3. run
#mysql
> select `sys_groupid` FROM `dbispconfig`.`web_domain` WHERE `domain` LIKE 'test.test.fr' ;
Correct behaviour
step 1 (API) gives me
+-------------+
| sys_groupid |
+-------------+
| 1 |
+-------------+
step 3 (web interface) gives me
+-------------+
| sys_groupid |
+-------------+
| 0 |
+-------------+
Working behavior is step 3 sys_group_id=0
Environment
Server OS + version: Ubuntu 20.04
ISPConfig version: 3.2.5
Software version of the related software:
Server version: Apache/2.4.41 (Ubuntu)
Server built: 2021-06-17T18:27:53
Proposed fix
I didn't find out where is it.
May be, you will not have that behavior !?
References
https://www.howtoforge.com/community/threads/api-and-groupid.87230/#post-424590