php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62967 执行析构函数时工作目录有问题
Submitted: 2012-08-29 13:25 UTC Modified: 2012-08-29 14:37 UTC
From: 360586201 at qq dot com Assigned: laruence (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.16 OS:
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: 360586201 at qq dot com
New email:
PHP Version: OS:

 

 [2012-08-29 13:25 UTC] 360586201 at qq dot com
Description:
------------
在析构函数的当前工作目录竟然变为了apache目录

更奇怪的是,我不执行普通方法时,析构函数的工作目录是正确的,也是代码的执行目录,当我执行过普
通方法后,就一直为apache目录了


Test script:
---------------
<?php
class get_path {
	function __construct() {
		//获取当前工作路径
		echo getcwd().'<br>';  #输出 D:\www\test(代码执行目录)
	}

	function write() {
		//获取当前工作路径
		echo getcwd().'<br>';  #输出 D:\www\test(代码执行目录)
	}

	function __destruct() {
		//获取当前工作路径
		echo getcwd();  #输出 D:\Program Files\wamp\bin\apache\Apache2.2.21(apache目录)
	}
}

$gl = new get_path();
$gl->write();


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-29 14:09 UTC] laruence@php.net
你的DocumentRoot设置的是?
 [2012-08-29 14:12 UTC] 360586201 at qq dot com
DocumentRoot "D:/www/"
 [2012-08-29 14:19 UTC] laruence@php.net
-Status: Open +Status: Analyzed
 [2012-08-29 14:19 UTC] laruence@php.net
__destruct被调用的时候, 当前脚本已经完成了执行, 进入了request shutdown时期, 所以, 此时的工作
目录变成了apache的工作目录.
while the __destruct was calling, the script had already be executed, and it has 
enter the request shutdown phase. so the current work dir became to the apache's .

我大体看了下, 要修复这个, 我们需要花费比较大的改动. 有些昂贵

I'd like mark this as won't fix.
 [2012-08-29 14:22 UTC] 360586201 at qq dot com
这是算一个bug吧?那是不修复了?
 [2012-08-29 14:25 UTC] laruence@php.net
哦, 这个问题之前已经有人报告过了, 也已经在文档中注明了.  参见 #34206

closed, see #34206

http://php.net/manual/en/language.oop5.decon.php
 [2012-08-29 14:25 UTC] laruence@php.net
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: laruence
 [2012-08-29 14:26 UTC] laruence@php.net
-Package: *Directory/Filesystem functions +Package: Documentation problem
 [2012-08-29 14:37 UTC] 360586201 at qq dot com
我网上上次搜过,有人也遇到过,说在nginx下是正常的,在apache下才有这问题
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 18:01:35 2024 UTC