|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52260 Windows implementation of dns_get_record fails with non-existing domain
Submitted: 2010-07-06 02:08 UTC Modified: 2020-05-04 08:24 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: a_jelly_doughnut at phpbb dot com Assigned: cmb (profile)
Status: Closed Package: Network related
PHP Version: 5.3.2 OS: Windows (All)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
25 - 14 = ?
Subscribe to this entry?

 [2010-07-06 02:08 UTC] a_jelly_doughnut at phpbb dot com
Windows implementation of dns_get_record fails with non-existing domain

var_dump(dns_get_record('')); // return false, throw E_WARNING

This is inconsistent with the *NIX implementation, which never (in our testing, see * note at bottom) throws E_WARNING on a non-existing domain, and returns an empty array, as demonstrated below:

afischer@miraculix:~$ php -v
PHP 5.3.2-1ubuntu4.2 with Suhosin-Patch (cli) (built: May 13 2010 20:01:00)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans

afischer@miraculix:~$ php -r "error_reporting(E_ALL); var_dump(dns_get_record(''));"
array(0) {

There is code in dns_win32.c to attempt to catch some cases of non-existing domains, but it does not seem to be complete.

		if (status) {
				if (status == DNS_INFO_NO_RECORDS) {
			if (status) {
				if (status == DNS_INFO_NO_RECORDS || status == DNS_ERROR_RCODE_NAME_ERROR) {

Seems to fix the problems for me.  For reference, all error codes which can be returned by DNSQuery_A are listed by Microsoft:

* I cannot say for sure if reports like are valid.  I do know from reading the PHP source that there are three separate *NIX implementations of php_dns_search(), but Andreas has not investigated which one his Ubuntu server is using.  It seems likely that this inconsistency affects NIX implementations as well.

Test script:
var_dump(dns_get_record('')); // return false, throw E_WARNING

Expected result:
array(0) {

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-10 16:32 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2010-09-06 12:57 UTC]
Automatic comment from SVN on behalf of pajoye
Log: - fix bug #52260, catch all DNS not found error
 [2010-09-06 12:58 UTC]
The not found error has been fixed in svn (5.3/trunk).

However I keep this issue open and assigned to me as I think the DNS function should not be as noisy as they are now (what's the point of raising a warning if all one wants is to actually check a domain...).
 [2017-10-24 07:33 UTC]
-Status: Assigned +Status: Open -Assigned To: pajoye +Assigned To:
 [2020-05-04 08:24 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-05-04 08:24 UTC]
The actual bug has been fixed long ago, so I'm closing this
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Sep 25 01:01:27 2023 UTC