php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48845 dl is incorrect disabled in CGI context
Submitted: 2009-07-08 06:51 UTC Modified: 2009-07-08 09:57 UTC
From: pkwan at advsofteng dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.0 OS: All
Private report: No CVE-ID: None
 [2009-07-08 06:51 UTC] pkwan at advsofteng dot net
Description:
------------
According to the PHP documentation, the "dl" function is deprecated, but not disabled. So it should continue to work. However, it is disabled if the PHP is run in CGI context.

The followings are the supporting documentation as published in http://www.php.net/dl

- 5.3.0 This function now throws an E_DEPRECATED notice on all sapi's
except for CLI, CGI and Embed.  

- As of PHP 5, the dl() function is deprecated in every SAPI except CLI.
Use Extension Loading Directives method instead. 

- Since PHP 6 this function is disabled in all SAPIs, except CLI, CGI
and embed. 

The above means "dl" is disabled in some SAPI only starting from PHP 6. Even in PHP 6, "dl" should continue to work in CLI, CGI and embed.

In PHP 5, "dl" is deprecated but not disabled. It should work in CLI,
CGI, Embed, and at most throws a E_DEPRECATED notice in other SAPI.

In practice, "dl" does not work in CGI, and no E_DEPRECATED notice is throw in any case. After some trouble-shooting, the code that causes the problem is (located in cgi_main.c):

if (!cgi && !fastcgi && !bindpath) {
   cgi_sapi_module.additional_functions = additional_functions;
}

The "cgi-main.c" detects that it is actually run as CGI (by detecting the server environmental variables), it will disables the "dl" function in CGI usage, conflicting with the documentation.


Reproduce code:
---------------
<?php dl("any_name.dll"); ?>

**** NOTE ****: You can reproduce the problem by actually using php-cgi in CGI. You cannot reproduce the problem if you just run php-cgi from the command line. The php-cgi will check for the server environmental variables to detect if it is actually running as CGI, and will disable "dl" only if it is actually running as CGI.

Expected result:
----------------
If the above code is executed in CGI, no error message is expected. 


Actual result:
--------------
Fatal error: Call to undefined function dl() in
C:\Inetpub\Scripts\phpinfo.php on line 1



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-08 09:20 UTC] pajoye@php.net
Do not report twice the same bug.
 [2009-07-08 09:57 UTC] pkwan at advsofteng dot net
Sorry about reporting the bug again. But in the previous report, the developer reviewing it is using incorrect test method and cannot reproduce the problem, and then he marked the bug as Bogus, and there is no way I can re-open it. So I submitted again and included the correct test method to reproduce the problem.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 11 02:00:01 2025 UTC