php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76559 curl_*() fail to fall back to global namespace if called from within a namespac
Submitted: 2018-07-01 15:13 UTC Modified: 2018-07-02 08:26 UTC
From: teo8976 at gmail dot com Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.6.36 OS: debian
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: teo8976 at gmail dot com
New email:
PHP Version: OS:

 

 [2018-07-01 15:13 UTC] teo8976 at gmail dot com
Description:
------------
When you call curl_init() or any other curl_xxx() function from within a namespace, without prepending a "\" (which you are not supposed to have to do), you get this stupid error:

Call to undefined function Whatever\\The\\Current\\NameSpace\\Is\\curl_init()

Test script:
---------------
namespace TestNameSpace;

class TestClass {
  function testMethod() {
    curl_init();
    echo "OK";
  }
}

$t=new TestClass();
$t->testMethod();

Expected result:
----------------
OK

Actual result:
--------------
Call to undefined function TestNameSpace\\curl_reset()

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-01 15:20 UTC] danack@php.net
-Status: Open +Status: Feedback
 [2018-07-01 15:20 UTC] danack@php.net
Please can you check you have curl installed.

I can't reproduce your issue, except when curl is not installed.
 [2018-07-01 17:05 UTC] teo8976 at gmail dot com
-Status: Feedback +Status: Open
 [2018-07-01 17:05 UTC] teo8976 at gmail dot com
Sorry, my report is bullshit because PHP gives confusing error messages.

Actually my issue was that I was calling curl_reset() which only exists starting from 5.5, but I'm on PHP 5.4.

The real issue here is that the error message should read "call to undefined function curl_reset()" rather than "call to undefined function NameSpace\\curl_reset()".
 [2018-07-01 17:07 UTC] teo8976 at gmail dot com
I see that the error message is fixed in PHP 7. Cool.
 [2018-07-01 17:08 UTC] teo8976 at gmail dot com
I meant in 7.3.0alpha1
 [2018-07-01 17:12 UTC] spam2 at rhsoft dot net
looks like versions are not your thing :-)

PHP Version: 5.6.36
Actually my issue was that I was calling curl_reset() which only exists starting from 5.5, but I'm on PHP 5.4

I see that the error message is fixed in PHP 7. Cool
I meant in 7.3.0alpha1
 [2018-07-02 08:26 UTC] danack@php.net
-Status: Open +Status: Not a bug
 [2018-07-02 08:26 UTC] danack@php.net
Closing then.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Sep 20 08:01:27 2019 UTC