
18th April 2012, 14:54
|
|
Senior Member
|
|
Join Date: Jul 2007
Location: Italy
Posts: 654
Thanks: 77
Thanked 12 Times in 7 Posts
|
|
domain_error_unique when there is no domain in db table
Hi guys,
I have tested this simple code:
Code:
$params = array(
'server_id' => $ServerId,
'domain' => $domain['domain'],
'active' => 'y');
try{
// Get the domain name ID
$record = $client->mail_domain_get_by_domain($this->getSession(), $domain['domain']);
// Create the mail domain
if(empty($record['domain_id'])){
$domainId = $client->mail_domain_add($this->getSession(), $clientId, $params);
}else{
$domainId = $record['domain_id'];
}
echo $domainId;
} catch ( SoapFault $e ) {
throw new Exception("There was a problem with the Mail Domain creation: " . $e->getMessage() . " - " . __METHOD__ . " - Paramenters: " . json_encode($params) , "3506");
}
If you execute this code you'll get the exception domain_error_unique
why this happens?
|

18th April 2012, 15:01
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,872
Thanks: 689
Thanked 4,184 Times in 3,202 Posts
|
|
Either there is already a email domain with that value or the domain variable is empty or a similar problem.
|

18th April 2012, 15:03
|
|
Senior Member
|
|
Join Date: Jul 2007
Location: Italy
Posts: 654
Thanks: 77
Thanked 12 Times in 7 Posts
|
|
these issues suggested are already tested.
|

18th April 2012, 15:06
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,872
Thanks: 689
Thanked 4,184 Times in 3,202 Posts
|
|
Take a look at the mail_domain table in the ispconfig database with phpmyadmin to ensure that it is really empty.
Last edited by till; 18th April 2012 at 15:17.
|

18th April 2012, 15:07
|
|
Senior Member
|
|
Join Date: Jul 2007
Location: Italy
Posts: 654
Thanks: 77
Thanked 12 Times in 7 Posts
|
|
It's not important if there is already a domain saved in the db because I check if the domain exist before.
|

18th April 2012, 15:16
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,872
Thanks: 689
Thanked 4,184 Times in 3,202 Posts
|
|
It is important if there is a domain in the DB as you cant add a duplicate domain and the error that you get tells you that there is already that domain in the mail_domain table. So check with phpmyadmin if the mail_domain table is empty or not.
|

18th April 2012, 16:05
|
|
Senior Member
|
|
Join Date: Jul 2007
Location: Italy
Posts: 654
Thanks: 77
Thanked 12 Times in 7 Posts
|
|
As you can see in the code posted I check if the domain exists in the db using the mail_domain_get_by_domain method.
If the domain exists the creation of the new mail domain is not a problem because the condition check if it exists or not.
So if the problem is not of the mail_domain_add method maybe the problem is mail_domain_get_by_domain that doesn't get the domain from the db.
|

18th April 2012, 16:27
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,872
Thanks: 689
Thanked 4,184 Times in 3,202 Posts
|
|
Try:
$record = $client->mail_domain_get($this->getSession(), array('domain' => $domain['domain']));
if(coun($record) > 0) {
echo 'domain exists';
} else {
echo 'domain does not exist';
}
|

18th April 2012, 17:56
|
|
Senior Member
|
|
Join Date: Jul 2007
Location: Italy
Posts: 654
Thanks: 77
Thanked 12 Times in 7 Posts
|
|
Hi,
done but the problem persists. count(record) = 0 even if there is a mail domain.
regards
|

18th April 2012, 18:00
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,872
Thanks: 689
Thanked 4,184 Times in 3,202 Posts
|
|
Then it might be that the variable $domain['domain'] does not contain the domain, as the query functions for mail domains work properly on my servers.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 15:31.
|
Recent comments
1 day 6 hours ago
1 day 15 hours ago
1 day 18 hours ago
1 day 19 hours ago
1 day 20 hours ago
1 day 22 hours ago
1 day 23 hours ago
2 days 1 hour ago
2 days 17 hours ago
2 days 17 hours ago