php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #78293 Raw DNS resolving of MX records not supported
Submitted: 2019-07-15 11:03 UTC Modified: 2019-07-15 12:27 UTC
From: daniil at daniil dot it Assigned: nikic (profile)
Status: Closed Package: Network related
PHP Version: 7.3.7 OS: Arch linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: daniil at daniil dot it
New email:
PHP Version: OS:

 

 [2019-07-15 11:03 UTC] daniil at daniil dot it
Description:
------------
When resolving MX records with the dns_get_record function, getting the raw record data isn't supported for some reason.

Test script:
---------------
<?php
echo ("Normal:\n");
var_dump(dns_get_record('daniil.it', DNS_MX, $auth, $add, false));
var_dump($auth, $add);

echo ("\nRaw:\n");
var_dump(dns_get_record('daniil.it', DNS_MX, $auth, $add, true));
var_dump($auth, $add)

Expected result:
----------------
Normal:
array(1) {
  [0]=>
  array(6) {
    ["host"]=>
    string(9) "daniil.it"
    ["class"]=>
    string(2) "IN"
    ["ttl"]=>
    int(300)
    ["type"]=>
    string(2) "MX"
    ["pri"]=>
    int(10)
    ["target"]=>
    string(13) "mx.yandex.net"
  }
}
NULL
NULL

Raw:
array(1) {
  [0]=>
  array(6) {
    ["host"]=>
    string(9) "daniil.it"
    ["class"]=>
    string(2) "IN"
    ["ttl"]=>
    int(300)
    ["type"]=>
    int(16384)
    ["data"]=>
    string(X) "binary data representing MX record"
  }
}
NULL
NUL

Actual result:
--------------
Normal:
array(1) {
  [0]=>
  array(6) {
    ["host"]=>
    string(9) "daniil.it"
    ["class"]=>
    string(2) "IN"
    ["ttl"]=>
    int(300)
    ["type"]=>
    string(2) "MX"
    ["pri"]=>
    int(10)
    ["target"]=>
    string(13) "mx.yandex.net"
  }
}
NULL
NULL

Raw:
array(0) {
}
NULL
NUL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-07-15 11:20 UTC] nikic@php.net
-Type: Bug +Type: Documentation Problem
 [2019-07-15 11:20 UTC] nikic@php.net
This is a case of bad docs... if raw mode is used, then you need to pass the raw DNS type ID (15 for MX). The DNS_* constants cannot be used (they are a bitmask, not a single type).

The correct code is:

echo ("\nRaw:\n");
var_dump(dns_get_record('daniil.it', 15, $auth, $add, true));
var_dump($auth, $add);
 [2019-07-15 12:27 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2019-07-15 12:30 UTC] daniil at daniil dot it
I guess I was fooled by the fact that DNS_A is equal to 1, I guess I'll edit the docs then
 [2019-07-15 12:31 UTC] daniil at daniil dot it
Welp too late I saw you already edited that :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC