|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74866 extension_dir = "./ext" now use current directory for base
Submitted: 2017-07-06 12:27 UTC Modified: 2017-07-08 20:59 UTC
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: sailormax at inbox dot lv Assigned: francois (profile)
Status: Closed Package: Dynamic loading
PHP Version: 7.2.0alpha3 OS: Windows 10
Private report: No CVE-ID: None
 [2017-07-06 12:27 UTC] sailormax at inbox dot lv
Early builds works with "./" in `extension_dir` setting as with directory of php.exe

Start from 7.2alpha3 "./" in `extension_dir` setting PHP start to understand as `current directory`.
In result if start php.exe from any other directory, it try to load extensions from `current directory`.

Test script:

extension_dir = ".\ext"

exec php from parent directory:
> php\php.exe --version

Expected result:
PHP 7.2.0alpha3 (cli) ...

Actual result:
Warning: Cannot access dynamic library 'php_bz2.dll' (tried : ext\php_bz2.dll, ext\php_php_bz2.dll.dll) in Unknown on line 0

PHP 7.2.0alpha3 (cli) ...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-06 15:10 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: francois
 [2017-07-06 15:10 UTC]
Caused by the extension loading changes added in alpha3.

alpha2 constructed a DLL filename and went straight to DL_LOAD/LoadLibrary, which looks relative to the process.
alpha3 also constructs a filename but first tests the path with VCWD_ACCESS/tsrm_win32_access, which itself tests access to the parent directory.
 [2017-07-06 15:11 UTC]
(...and tsrm_win32_access looks relative to the current working directory.)
 [2017-07-06 18:27 UTC]
@sailormax at inbox dot lv are you sure your php dir is not on PATH?

@requinix the explanation is not correct. It never worked the way it'd search relative to the binary image directory, and unlikely ever will. See this docs

In particular, this quote

The first directory searched is the directory containing the image file used to create the calling process (for more information, see the CreateProcess function). Doing this allows private dynamic-link library (DLL) files associated with a process to be found without adding the process's installed directory to the PATH environment variable. If a relative path is specified, the entire relative path is appended to every token in the DLL search path list. 

Disregarding that, the patch is a really breaching change. The name like "php_php_bz2.dll.dll" tells, it doesn't even check the ext filename already has a suffix. More breaches are to expect on Windows

 [2017-07-06 18:38 UTC] spam2 at rhsoft dot net
frankly people should *really* stop using relative paths at all for configurations - subscribe to and it don't take that long to realize how stupid such configurations are
 [2017-07-06 19:08 UTC]
@spam2 at rhsoft dot net sure, but it should not happen as a side effect of another patch. For now I'd say, the behavior should be fixed.

 [2017-07-06 21:26 UTC] Sure, this is a BC break. It must be fixed before the release.

I'll take time tomorrow to work on it.
 [2017-07-06 23:11 UTC]
@francois nice. Please let me know, if you need something to be tested.

 [2017-07-07 07:00 UTC] sailormax at inbox dot lv
@ab at php dot net I did not have php dir on PATH.

@spam2 at rhsoft dot net
About "people should *really* stop using relative paths at all for configurations"
I use php.exe and few dlls as portable launcher of code verifier in my portable text editor => I can't use absolute paths and I want not setup php on each computer before use it; I want just copy directory or just plug in USB flash card with my editor and php verifier before use it. Please, don't break this possibility.
 [2017-07-08 20:59 UTC]
-Status: Verified +Status: Feedback
 [2017-07-08 20:59 UTC]
There's now a snapshot based on the Francois PR . Please check.

 [2017-07-10 08:36 UTC] sailormax at inbox dot lv
@ab at php dot net

Dix of Francois work fine. My problem solved. Thanks!
 [2017-07-10 08:37 UTC] sailormax at inbox dot lv
@ab at php dot net

Fix of Francois work fine. My problem solved. Thanks!
 [2017-07-13 12:34 UTC]
Automatic comment on behalf of francois
Log: Fixed bug #74866 extension_dir = "./ext" now use current directory for base
 [2017-07-13 12:34 UTC]
-Status: Feedback +Status: Closed
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Feb 22 02:01:26 2020 UTC