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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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: Sun Dec 22 01:01:30 2024 UTC