php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #75751 disabling CURLOPT_DNS_USE_GLOBAL_CACHE reports a warning
Submitted: 2018-01-02 09:23 UTC Modified: 2018-01-02 13:03 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: pavel dot madr at gmail dot com Assigned:
Status: Open Package: cURL related
PHP Version: 7.2.0 OS: All
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-01-02 09:23 UTC] pavel dot madr at gmail dot com
Description:
------------
This line of code produces warning in PHP compiled with ZTS.
$c = curl_init(); 
curl_setopt($c, CURLOPT_DNS_USE_GLOBAL_CACHE, false);

It's perfectly ok to call this method with false argument and no warning should appear. The warning should appear only when true is used for the argument:
curl_setopt($c, CURLOPT_DNS_USE_GLOBAL_CACHE, true);


Also the documentation is not exact - "This option is not thread-safe and is enabled by default."
CURLOPT_DNS_USE_GLOBAL_CACHE is FALSE by default in ZTS mode and TRUE in non-ZTS mode.

According to the cUrl documentation this flag should not be used.
https://curl.haxx.se/libcurl/c/CURLOPT_DNS_USE_GLOBAL_CACHE.html
So it would be better to remove it completely from PHP or set to FALSE be default for both modes.

The attached patch solves just appearance of the warning.



Patches

0001-report-warning-only-if-the-global-cache-mode-should-.patch (last revision 2018-01-02 09:27 UTC by pavel dot madr at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-02 09:35 UTC] spam2 at rhsoft dot net
> So it would be better to remove it completely from 
> PHP or set to FALSE be default for both modes

for sure not remove it!

i even wrote abugreport some months ago because a loop of requests to the same local domain triggered rate-limits of the nameserver with file_get_contents() while curl was fine and the reason is that DNS cache

virtually nobody is using ZTS in production so don't sacrifice PHP because of it's existence
 [2018-01-02 13:03 UTC] cmb@php.net
Considering that the cURL documentation states[1]:

| Subject for removal in the future. Do not use!

I think it would be best to deprecate this option, and point users
to use the following instead:

  curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);

A deprecation would likely require the RFC process[2], though.

[1] <https://curl.haxx.se/libcurl/c/CURLOPT_DNS_USE_GLOBAL_CACHE.html#AVAILABILITY>
[2] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 03:01:27 2024 UTC