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
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: 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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC