[PHP-DEV] PHP 4.0 Bug #8937 Updated: unset() in context with GLOBAL

2001-03-08 Thread stas

ID: 8937
Updated by: stas
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Closed
Bug Type: Scripting Engine problem
Assigned To: 
Comments:

"the program dosn't do, what I expect"
 is not a bug. A bug is "the program doesn't do what the
programmer expected". If 'man' program doesn't create a
little man to help you with your C code, it's not the
program's fault :)

And no, it cannot work the way you proposed, because there's
no way to discover what that "other" variable, that $foo is
linked to, was in the first place. It's located in another
symbol table, which is not available in that function. But
if you don't really need unset (which wipes the variable
completely), you could just use something like $foo=false,
which does work on references perfectly.

Previous Comments:
---

[2001-03-08 11:23:24] [EMAIL PROTECTED]
My problem is, that old PHP3 scripts won´t work with PHP4, if they use such a 
construct.

And it is a bug in the meaning of "the program dosn't do, what I expect". Ok, the bug 
is documented, but look at the ERROR-ID #8972 for a case, that makes a much more 
surprising and unexpected effect.

Why can't PHP just overwrite the value with the value "UNSET" in the case of unsetting 
a reference - instead of removing the reference?

---

[2001-03-06 08:10:47] [EMAIL PROTECTED]
So, what's the problem with your latest code? I do not see any.

---

[2001-01-28 18:53:34] [EMAIL PROTECTED]
Bug or feature. Thats the question. :)

Sorry, it IS a bug. 4 people have mentioned this and I found now a
test case, where no workarround exists.

But I found another problem in this context. Will make a new ticket.


---

[2001-01-26 16:24:50] [EMAIL PROTECTED]
Sorry... forgot to read all the comments

---

[2001-01-26 16:14:57] [EMAIL PROTECTED]
This isn't a bug, but a feature =)

If you use GLOBAL within a function it creates a reference to the orignal variabele, 
this reference is local to the function. SO if you unset() this variabele, you're only 
unsetting the reference (and thus not the GLOBAL variabele). This is documented 
behavior (from the unset() manual page):

   If a globalized variable is unset() inside of a function, only the
   local variable is destroyed. The variable in the calling environment
   will retain the same value as before unset() was called.

---

The remainder of the comments for this report are too long.  To view the rest of the 
comments, please view the bug report online.


ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=8937edit=2


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] PHP 4.0 Bug #8937 Updated: unset() in context with GLOBAL

2001-03-06 Thread stas

ID: 8937
Updated by: stas
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Feedback
Bug Type: Scripting Engine problem
Assigned To: 
Comments:

So, what's the problem with your latest code? I do not see any.

Previous Comments:
---

[2001-01-28 18:53:34] [EMAIL PROTECTED]
Bug or feature. Thats the question. :)

Sorry, it IS a bug. 4 people have mentioned this and I found now a
test case, where no workarround exists.

But I found another problem in this context. Will make a new ticket.


---

[2001-01-26 16:24:50] [EMAIL PROTECTED]
Sorry... forgot to read all the comments

---

[2001-01-26 16:14:57] [EMAIL PROTECTED]
This isn't a bug, but a feature =)

If you use GLOBAL within a function it creates a reference to the orignal variabele, 
this reference is local to the function. SO if you unset() this variabele, you're only 
unsetting the reference (and thus not the GLOBAL variabele). This is documented 
behavior (from the unset() manual page):

   If a globalized variable is unset() inside of a function, only the
   local variable is destroyed. The variable in the calling environment
   will retain the same value as before unset() was called.

---

[2001-01-26 14:19:15] [EMAIL PROTECTED]
The mentioned workarround (unset($GLOBALS['x'])) dosn't work with my testscript.

The result is exactly the same as with the first version of my script. I really have 
GREAT TROUBLES to upgrade this old application to PHP4.

Result:

'/hugo/bla/fasel'
'/hugo/bla'
'/hugo'
DIR called with function test1(): Array ( [/hugo] = 1 [/hugo/bla] = 1 
[/hugo/bla/fasel] = 1 ) 
'/hugo/bla/fasel'
'/hugo/bla'
'/hugo'
DIR called with function test2(): Array ( [/hugo/bla/fasel/test] = 1 [/hugo] = 1 
[/hugo/bla] = 1 [/hugo/bla/fasel] = 1 ) 


Script:
?

function test1 ($dir) {
GLOBAL $x;
unset($GLOBALS["x"]);
$x[$dir]=true;
mydirname($dir);
}


function test2 ($dir) {
GLOBAL $x;
### unset($x);   no unset!
$x[$dir]=true;
mydirname($dir);
}

function mydirname ($dir) {
GLOBAL $x;
$dir=ereg_Replace('/[^/]*$','',$dir);
if (!empty($dir)) {
echo "'$dir'br"; flush();
mydirname($dir);
$x[$dir]=true;
}
}

$dir="/hugo/bla/fasel/test"; # first char must be '/' !

unset($x);
test1($dir);
echo "DIR called with function test1(): "; print_r($x);

echo "br";

unset($x);
test2($dir);
echo "DIR called with function test2(): "; print_r($x);

?


---

[2001-01-26 14:05:26] [EMAIL PROTECTED]
Of course I know that it is already documented. First mentioned in August 1999!

Havn't mentioned this, cause it is not relevant. A bug is bug, and the other tickets 
have been closed, but the bug was remaining.

4 (or more?) other guys had the same trouble with this behaviour. How many others 
havn't reported this bug? I know minimum 2 others, which havn't.

Sorry, but it IS a bug and a workarround is not a bugfix and my opinion is, that you 
make it too easy for yourself to change the state of this ticket to "closed".

But I will not change it for you. I'll respect your decission.


---

The remainder of the comments for this report are too long.  To view the rest of the 
comments, please view the bug report online.


ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=8937edit=2


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] PHP 4.0 Bug #8937 Updated: unset() in context with GLOBAL

2001-01-29 Thread aulbach

ID: 8937
User Update by: [EMAIL PROTECTED]
Status: Open
Bug Type: Scripting Engine problem
Description: unset() in context with GLOBAL

Bug or feature. Thats the question. :)

Sorry, it IS a bug. 4 people have mentioned this and I found now a
test case, where no workarround exists.

But I found another problem in this context. Will make a new ticket.


Previous Comments:
---

[2001-01-26 16:24:50] [EMAIL PROTECTED]
Sorry... forgot to read all the comments

---

[2001-01-26 16:14:57] [EMAIL PROTECTED]
This isn't a bug, but a feature =)

If you use GLOBAL within a function it creates a reference to the orignal variabele, 
this reference is local to the function. SO if you unset() this variabele, you're only 
unsetting the reference (and thus not the GLOBAL variabele). This is documented 
behavior (from the unset() manual page):

   If a globalized variable is unset() inside of a function, only the
   local variable is destroyed. The variable in the calling environment
   will retain the same value as before unset() was called.

---

[2001-01-26 14:19:15] [EMAIL PROTECTED]
The mentioned workarround (unset($GLOBALS['x'])) dosn't work with my testscript.

The result is exactly the same as with the first version of my script. I really have 
GREAT TROUBLES to upgrade this old application to PHP4.

Result:

'/hugo/bla/fasel'
'/hugo/bla'
'/hugo'
DIR called with function test1(): Array ( [/hugo] = 1 [/hugo/bla] = 1 
[/hugo/bla/fasel] = 1 ) 
'/hugo/bla/fasel'
'/hugo/bla'
'/hugo'
DIR called with function test2(): Array ( [/hugo/bla/fasel/test] = 1 [/hugo] = 1 
[/hugo/bla] = 1 [/hugo/bla/fasel] = 1 ) 


Script:
?

function test1 ($dir) {
GLOBAL $x;
unset($GLOBALS["x"]);
$x[$dir]=true;
mydirname($dir);
}


function test2 ($dir) {
GLOBAL $x;
### unset($x);   no unset!
$x[$dir]=true;
mydirname($dir);
}

function mydirname ($dir) {
GLOBAL $x;
$dir=ereg_Replace('/[^/]*$','',$dir);
if (!empty($dir)) {
echo "'$dir'br"; flush();
mydirname($dir);
$x[$dir]=true;
}
}

$dir="/hugo/bla/fasel/test"; # first char must be '/' !

unset($x);
test1($dir);
echo "DIR called with function test1(): "; print_r($x);

echo "br";

unset($x);
test2($dir);
echo "DIR called with function test2(): "; print_r($x);

?


---

[2001-01-26 14:05:26] [EMAIL PROTECTED]
Of course I know that it is already documented. First mentioned in August 1999!

Havn't mentioned this, cause it is not relevant. A bug is bug, and the other tickets 
have been closed, but the bug was remaining.

4 (or more?) other guys had the same trouble with this behaviour. How many others 
havn't reported this bug? I know minimum 2 others, which havn't.

Sorry, but it IS a bug and a workarround is not a bugfix and my opinion is, that you 
make it too easy for yourself to change the state of this ticket to "closed".

But I will not change it for you. I'll respect your decission.


---

[2001-01-26 11:54:16] [EMAIL PROTECTED]
Thats thanks to Bjorn ;) Not my sig..

---

The remainder of the comments for this report are too long.  To view the rest of the 
comments, please view the bug report online.

Full Bug description available at: http://bugs.php.net/?id=8937


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] PHP 4.0 Bug #8937 Updated: unset() in context with GLOBAL

2001-01-26 Thread jmoore

ID: 8937
Updated by: jmoore
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Closed
Bug Type: Scripting Engine problem
Assigned To: 
Comments:

Have a closer look at

   http://bugs.php.net/bugs.php?id=1971

and the commentary of Zeev. You have to
use unset($GLOBALS["x"]);

-- 
Björn Schotte[EMAIL PROTECTED]
http://rent-a-phpwizard.de/  [EMAIL PROTECTED]



Previous Comments:
---

[2001-01-26 10:25:19] [EMAIL PROTECTED]
unset() in context with GLOBAL has a serious bug. This bug appeard,
when I changed a PHP3-program to PHP4. The problem is now,
that constructs like the following are several times in this old program.

Sorry, I haven't checked, if this problem is fixed in 4.0.4. If so, perhaps someone 
can tell me? TIA.

Think this problem depends Zend, cause ZEND_CHANGES tells me:

"unset() is no longer a function, but a statement.  It was never
documented as a function so the impact should be no bigger than nada."

I have made a test-case:

?

function test1 ($dir) {
GLOBAL $x;
unset($x);
$x[$dir]=true;
mydirname($dir);
}


function test2 ($dir) {
GLOBAL $x;
### unset($x);   no unset!
$x[$dir]=true;
mydirname($dir);
}

function mydirname ($dir) {
GLOBAL $x;
$dir=ereg_Replace('/[^/]*$','',$dir);
if (!empty($dir)) {
echo "'$dir'br"; flush();
mydirname($dir);
$x[$dir]=true;
}
}

$dir="/hugo/bla/fasel/test"; # first char must be '/' !

unset($x);
test1($dir);
echo "DIRS called with function test1(): "; print_r($x);

echo "br";

unset($x);
test2($dir);
echo "DIRS called with function test2(): "; print_r($x);

?

---


Full Bug description available at: http://bugs.php.net/?id=8937


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] PHP 4.0 Bug #8937 Updated: unset() in context with GLOBAL

2001-01-26 Thread aulbach

ID: 8937
User Update by: [EMAIL PROTECTED]
Status: Closed
Bug Type: Scripting Engine problem
Description: unset() in context with GLOBAL

Of course I know that it is already documented. First mentioned in August 1999!

Havn't mentioned this, cause it is not relevant. A bug is bug, and the other tickets 
have been closed, but the bug was remaining.

4 (or more?) other guys had the same trouble with this behaviour. How many others 
havn't reported this bug? I know minimum 2 others, which havn't.

Sorry, but it IS a bug and a workarround is not a bugfix and my opinion is, that you 
make it too easy for yourself to change the state of this ticket to "closed".

But I will not change it for you. I'll respect your decission.


Previous Comments:
---

[2001-01-26 11:54:16] [EMAIL PROTECTED]
Thats thanks to Bjorn ;) Not my sig..

---

[2001-01-26 11:52:29] [EMAIL PROTECTED]
Have a closer look at

   http://bugs.php.net/bugs.php?id=1971

and the commentary of Zeev. You have to
use unset($GLOBALS["x"]);

-- 
Björn Schotte[EMAIL PROTECTED]
http://rent-a-phpwizard.de/  [EMAIL PROTECTED]



---

[2001-01-26 10:25:19] [EMAIL PROTECTED]
unset() in context with GLOBAL has a serious bug. This bug appeard,
when I changed a PHP3-program to PHP4. The problem is now,
that constructs like the following are several times in this old program.

Sorry, I haven't checked, if this problem is fixed in 4.0.4. If so, perhaps someone 
can tell me? TIA.

Think this problem depends Zend, cause ZEND_CHANGES tells me:

"unset() is no longer a function, but a statement.  It was never
documented as a function so the impact should be no bigger than nada."

I have made a test-case:

?

function test1 ($dir) {
GLOBAL $x;
unset($x);
$x[$dir]=true;
mydirname($dir);
}


function test2 ($dir) {
GLOBAL $x;
### unset($x);   no unset!
$x[$dir]=true;
mydirname($dir);
}

function mydirname ($dir) {
GLOBAL $x;
$dir=ereg_Replace('/[^/]*$','',$dir);
if (!empty($dir)) {
echo "'$dir'br"; flush();
mydirname($dir);
$x[$dir]=true;
}
}

$dir="/hugo/bla/fasel/test"; # first char must be '/' !

unset($x);
test1($dir);
echo "DIRS called with function test1(): "; print_r($x);

echo "br";

unset($x);
test2($dir);
echo "DIRS called with function test2(): "; print_r($x);

?

---


Full Bug description available at: http://bugs.php.net/?id=8937


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] PHP 4.0 Bug #8937 Updated: unset() in context with GLOBAL

2001-01-26 Thread derick

ID: 8937
Updated by: derick
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Closed
Bug Type: Scripting Engine problem
Assigned To: 
Comments:

This isn't a bug, but a feature =)

If you use GLOBAL within a function it creates a reference to the orignal variabele, 
this reference is local to the function. SO if you unset() this variabele, you're only 
unsetting the reference (and thus not the GLOBAL variabele). This is documented 
behavior (from the unset() manual page):

   If a globalized variable is unset() inside of a function, only the
   local variable is destroyed. The variable in the calling environment
   will retain the same value as before unset() was called.

Previous Comments:
---

[2001-01-26 14:19:15] [EMAIL PROTECTED]
The mentioned workarround (unset($GLOBALS['x'])) dosn't work with my testscript.

The result is exactly the same as with the first version of my script. I really have 
GREAT TROUBLES to upgrade this old application to PHP4.

Result:

'/hugo/bla/fasel'
'/hugo/bla'
'/hugo'
DIR called with function test1(): Array ( [/hugo] = 1 [/hugo/bla] = 1 
[/hugo/bla/fasel] = 1 ) 
'/hugo/bla/fasel'
'/hugo/bla'
'/hugo'
DIR called with function test2(): Array ( [/hugo/bla/fasel/test] = 1 [/hugo] = 1 
[/hugo/bla] = 1 [/hugo/bla/fasel] = 1 ) 


Script:
?

function test1 ($dir) {
GLOBAL $x;
unset($GLOBALS["x"]);
$x[$dir]=true;
mydirname($dir);
}


function test2 ($dir) {
GLOBAL $x;
### unset($x);   no unset!
$x[$dir]=true;
mydirname($dir);
}

function mydirname ($dir) {
GLOBAL $x;
$dir=ereg_Replace('/[^/]*$','',$dir);
if (!empty($dir)) {
echo "'$dir'br"; flush();
mydirname($dir);
$x[$dir]=true;
}
}

$dir="/hugo/bla/fasel/test"; # first char must be '/' !

unset($x);
test1($dir);
echo "DIR called with function test1(): "; print_r($x);

echo "br";

unset($x);
test2($dir);
echo "DIR called with function test2(): "; print_r($x);

?


---

[2001-01-26 14:05:26] [EMAIL PROTECTED]
Of course I know that it is already documented. First mentioned in August 1999!

Havn't mentioned this, cause it is not relevant. A bug is bug, and the other tickets 
have been closed, but the bug was remaining.

4 (or more?) other guys had the same trouble with this behaviour. How many others 
havn't reported this bug? I know minimum 2 others, which havn't.

Sorry, but it IS a bug and a workarround is not a bugfix and my opinion is, that you 
make it too easy for yourself to change the state of this ticket to "closed".

But I will not change it for you. I'll respect your decission.


---

[2001-01-26 11:54:16] [EMAIL PROTECTED]
Thats thanks to Bjorn ;) Not my sig..

---

[2001-01-26 11:52:29] [EMAIL PROTECTED]
Have a closer look at

   http://bugs.php.net/bugs.php?id=1971

and the commentary of Zeev. You have to
use unset($GLOBALS["x"]);

-- 
Björn Schotte[EMAIL PROTECTED]
http://rent-a-phpwizard.de/  [EMAIL PROTECTED]



---

[2001-01-26 10:25:19] [EMAIL PROTECTED]
unset() in context with GLOBAL has a serious bug. This bug appeard,
when I changed a PHP3-program to PHP4. The problem is now,
that constructs like the following are several times in this old program.

Sorry, I haven't checked, if this problem is fixed in 4.0.4. If so, perhaps someone 
can tell me? TIA.

Think this problem depends Zend, cause ZEND_CHANGES tells me:

"unset() is no longer a function, but a statement.  It was never
documented as a function so the impact should be no bigger than nada."

I have made a test-case:

?

function test1 ($dir) {
GLOBAL $x;
unset($x);
$x[$dir]=true;
mydirname($dir);
}


function test2 ($dir) {
GLOBAL $x;
### unset($x);   no unset!
$x[$dir]=true;
mydirname($dir);
}

function mydirname ($dir) {
GLOBAL $x;
$dir=ereg_Replace('/[^/]*$','',$dir);
if (!empty($dir)) {
echo "'$dir'br"; flush();
mydirname($dir);
$x[$dir]=true;
}
}

$dir="/hugo/bla/fasel/test"; # first char must be '/' !

unset($x);
test1($dir);
echo "DIRS called with function test1(): "; print_r($x);

echo "br";

unset($x);
test2($dir);
echo "DIRS called with function test2(): "; print_r($x);

?

---

The remainder of the comments for this report are too long.  To view the rest of the 
comments, please view the bug report online.

Full Bug