Bug #47623 [Com]: array_shift() fails with @ operator

2010-05-31 Thread laruence at yahoo dot com dot cn
Edit report at http://bugs.php.net/bug.php?id=47623edit=1

 ID:   47623
 Comment by:   laruence at yahoo dot com dot cn
 Reported by:  Henry at huis-stijl dot nl
 Summary:  array_shift() fails with @ operator
 Status:   Verified
 Type: Bug
 Package:  Scripting Engine problem
 Operating System: *
 PHP Version:  5.*, 6CVS (2009-04-30)

 New Comment:

errata:



//then in zend_do_pass_param:

ZEND_SEND_VAR gen opcode:SEND_REF, ZEND_SEND_VAL gen
opcode:SEND_VAR_NO_REF


Previous Comments:

[2010-05-28 16:35:20] laruence at yahoo dot com dot cn

Hi, I found the same bug in php 5.2.8(linux)

and I also find out why:



in php complie phase,

@$var - expr_without_variable;

//code

expr_without_variable:

...

   |   '@' { zend_do_begin_silence($1 TSRMLS_CC); }

   expr { zend_do_end_silence($1 TSRMLS_CC); $$ = $3; }



while:

$var  - variable

then this different cause the znode's difference

//

non_empty_function_call_parameter_list:

expr_without_variable   { Z_LVAL($$.u.constant) = 1;  

zend_do_pass_param($1, ZEND_SEND_VAL, Z_LVAL($$.u.constant) TSRMLS_CC);
}

|   variable{ Z_LVAL($$.u.constant) = 1;  

zend_do_pass_param($1, ZEND_SEND_VAR, Z_LVAL($$.u.constant) TSRMLS_CC);
}



then in zend_so_pass_param:

ZEND_SEND_VAR gen opcode:SEND_REF, ZEND_SEND_VAR gen
opcode:SEND_VAR_NO_REF



so when use @, cause param send without ref.



you can find more info on : http://www.laruence.com/2010/05/28/1565.html


[2010-05-05 20:56:31] whatrevolution at yahoo dot com

?php



$_SESSION['villas'] = array

(

1 = array(1,2,3),

2 = array(2,3,4),

3 = array(3,4,5),

4 = array(4,5,6),

);

/*

 *  ONE:

*/

/*

While(@$_SESSION['villas'] != array())

{

$row = array_shift(@$_SESSION['villas']);

print_r($row);

}// einde while

*/



/*

 *  TWO:

*/

/*

while($foo['villas'] != array())

{

  $row = array_shift(@$foo['villas']); // Removing @ makes it work..

  var_dump($foo);

}

*/



/*

 *  THREE:

*/

//I cann bypass this failure by using:

$arr_temp = @$_SESSION['villas'];

$row = array_shift($arr_temp);

$_SESSION['villas'] = $arr_temp;

unset($arr_temp);

var_dump($_SESSION['villas']); 



?



Result:



One and Two, same as described before.



Three:



array

  0 = 

array

  0 = int 2

  1 = int 3

  2 = int 4

  1 = 

array

  0 = int 3

  1 = int 4

  2 = int 5

  2 = 

array

  0 = int 4

  1 = int 5

  2 = int 6





PHP Version 5.2.10-2ubuntu6.4



System  Linux 2.6.31-20-generic x86_64

Build Date  Jan 6 2010 22:36:47

Server API  Apache 2.0 Handler 

PHP API 20041225

PHP Extension   20060613

Zend Extension  220060519

Debug Build no

Thread Safety   disabled

Zend Memory Manager enabled 



Apache/2.2.12 (Ubuntu)


[2009-04-13 18:23:01] j...@php.net

This has nothing to do with sessions. Simplified script:



?php



$foo['villas'] = array('a','b','c');



while($foo['villas'] != array())

{

  $row = array_shift(@$foo['villas']); // Removing @ makes it work..

  var_dump($foo);

}

?






[2009-03-16 22:11:28] Henry at huis-stijl dot nl

Tried with and without the @ same output.


[2009-03-16 16:26:07] j...@php.net

If you remove those @'s, what does it output..?




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

http://bugs.php.net/bug.php?id=47623


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=47623edit=1


Bug #47623 [Com]: array_shift() fails with @ operator

2010-05-28 Thread laruence at yahoo dot com dot cn
Edit report at http://bugs.php.net/bug.php?id=47623edit=1

 ID:   47623
 Comment by:   laruence at yahoo dot com dot cn
 Reported by:  Henry at huis-stijl dot nl
 Summary:  array_shift() fails with @ operator
 Status:   Verified
 Type: Bug
 Package:  Scripting Engine problem
 Operating System: *
 PHP Version:  5.*, 6CVS (2009-04-30)

 New Comment:

Hi, I found the same bug in php 5.2.8(linux)

and I also find out why:



in php complie phase,

@$var - expr_without_variable;

//code

expr_without_variable:

...

   |   '@' { zend_do_begin_silence($1 TSRMLS_CC); }

   expr { zend_do_end_silence($1 TSRMLS_CC); $$ = $3; }



while:

$var  - variable

then this different cause the znode's difference

//

non_empty_function_call_parameter_list:

expr_without_variable   { Z_LVAL($$.u.constant) = 1;  

zend_do_pass_param($1, ZEND_SEND_VAL, Z_LVAL($$.u.constant) TSRMLS_CC);
}

|   variable{ Z_LVAL($$.u.constant) = 1;  

zend_do_pass_param($1, ZEND_SEND_VAR, Z_LVAL($$.u.constant) TSRMLS_CC);
}



then in zend_so_pass_param:

ZEND_SEND_VAR gen opcode:SEND_REF, ZEND_SEND_VAR gen
opcode:SEND_VAR_NO_REF



so when use @, cause param send without ref.



you can find more info on : http://www.laruence.com/2010/05/28/1565.html


Previous Comments:

[2010-05-05 20:56:31] whatrevolution at yahoo dot com

?php



$_SESSION['villas'] = array

(

1 = array(1,2,3),

2 = array(2,3,4),

3 = array(3,4,5),

4 = array(4,5,6),

);

/*

 *  ONE:

*/

/*

While(@$_SESSION['villas'] != array())

{

$row = array_shift(@$_SESSION['villas']);

print_r($row);

}// einde while

*/



/*

 *  TWO:

*/

/*

while($foo['villas'] != array())

{

  $row = array_shift(@$foo['villas']); // Removing @ makes it work..

  var_dump($foo);

}

*/



/*

 *  THREE:

*/

//I cann bypass this failure by using:

$arr_temp = @$_SESSION['villas'];

$row = array_shift($arr_temp);

$_SESSION['villas'] = $arr_temp;

unset($arr_temp);

var_dump($_SESSION['villas']); 



?



Result:



One and Two, same as described before.



Three:



array

  0 = 

array

  0 = int 2

  1 = int 3

  2 = int 4

  1 = 

array

  0 = int 3

  1 = int 4

  2 = int 5

  2 = 

array

  0 = int 4

  1 = int 5

  2 = int 6





PHP Version 5.2.10-2ubuntu6.4



System  Linux 2.6.31-20-generic x86_64

Build Date  Jan 6 2010 22:36:47

Server API  Apache 2.0 Handler 

PHP API 20041225

PHP Extension   20060613

Zend Extension  220060519

Debug Build no

Thread Safety   disabled

Zend Memory Manager enabled 



Apache/2.2.12 (Ubuntu)


[2009-04-13 18:23:01] j...@php.net

This has nothing to do with sessions. Simplified script:



?php



$foo['villas'] = array('a','b','c');



while($foo['villas'] != array())

{

  $row = array_shift(@$foo['villas']); // Removing @ makes it work..

  var_dump($foo);

}

?






[2009-03-16 22:11:28] Henry at huis-stijl dot nl

Tried with and without the @ same output.


[2009-03-16 16:26:07] j...@php.net

If you remove those @'s, what does it output..?


[2009-03-11 14:07:22] Henry at huis-stijl dot nl

?php

session_start();

ini_set('session.cache_limiter', 'private');

// © 2009 Huis-stijl, Henry Hekman



$_SESSION['villas'] = array

(

1 = array(1,2,3),

2 = array(2,3,4),

3 = array(3,4,5),

4 = array(4,5,6),

);



While(@$_SESSION['villas'] != array())

{

$row = array_shift(@$_SESSION['villas']);

print_r($row);

}// einde while



?



on php 4 i get

Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 2 [1] = 3 [2] = 4
) Array ( [0] = 3 [1] = 4 [2] = 5 ) Array ( [0] = 4 [1] = 5 [2] =
6 )



on phph 5.2.9 i get a loop that doesnt end

Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1] = 2 [2] = 3
) Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1] = 2 [2] =
3 ) Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1] = 2 [2]
= 3 ) Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1] = 2
[2] = 3 ) Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1] =
2 [2] = 3 ) Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1]
= 2 [2] = 3 ) Array ( [0] = 1 [1] = 2 [2] = 3 )




The remainder of the comments for this 

Bug #47623 [Com]: array_shift() fails with @ operator

2010-05-05 Thread whatrevolution at yahoo dot com
Edit report at http://bugs.php.net/bug.php?id=47623edit=1

 ID:   47623
 Comment by:   whatrevolution at yahoo dot com
 Reported by:  Henry at huis-stijl dot nl
 Summary:  array_shift() fails with @ operator
 Status:   Verified
 Type: Bug
 Package:  Scripting Engine problem
 Operating System: *
 PHP Version:  5.*, 6CVS (2009-04-30)

 New Comment:

?php



$_SESSION['villas'] = array

(

1 = array(1,2,3),

2 = array(2,3,4),

3 = array(3,4,5),

4 = array(4,5,6),

);

/*

 *  ONE:

*/

/*

While(@$_SESSION['villas'] != array())

{

$row = array_shift(@$_SESSION['villas']);

print_r($row);

}// einde while

*/



/*

 *  TWO:

*/

/*

while($foo['villas'] != array())

{

  $row = array_shift(@$foo['villas']); // Removing @ makes it work..

  var_dump($foo);

}

*/



/*

 *  THREE:

*/

//I cann bypass this failure by using:

$arr_temp = @$_SESSION['villas'];

$row = array_shift($arr_temp);

$_SESSION['villas'] = $arr_temp;

unset($arr_temp);

var_dump($_SESSION['villas']); 



?



Result:



One and Two, same as described before.



Three:



array

  0 = 

array

  0 = int 2

  1 = int 3

  2 = int 4

  1 = 

array

  0 = int 3

  1 = int 4

  2 = int 5

  2 = 

array

  0 = int 4

  1 = int 5

  2 = int 6





PHP Version 5.2.10-2ubuntu6.4



System  Linux 2.6.31-20-generic x86_64

Build Date  Jan 6 2010 22:36:47

Server API  Apache 2.0 Handler 

PHP API 20041225

PHP Extension   20060613

Zend Extension  220060519

Debug Build no

Thread Safety   disabled

Zend Memory Manager enabled 



Apache/2.2.12 (Ubuntu)


Previous Comments:

[2009-04-13 18:23:01] j...@php.net

This has nothing to do with sessions. Simplified script:



?php



$foo['villas'] = array('a','b','c');



while($foo['villas'] != array())

{

  $row = array_shift(@$foo['villas']); // Removing @ makes it work..

  var_dump($foo);

}

?






[2009-03-16 22:11:28] Henry at huis-stijl dot nl

Tried with and without the @ same output.


[2009-03-16 16:26:07] j...@php.net

If you remove those @'s, what does it output..?


[2009-03-11 14:07:22] Henry at huis-stijl dot nl

?php

session_start();

ini_set('session.cache_limiter', 'private');

// © 2009 Huis-stijl, Henry Hekman



$_SESSION['villas'] = array

(

1 = array(1,2,3),

2 = array(2,3,4),

3 = array(3,4,5),

4 = array(4,5,6),

);



While(@$_SESSION['villas'] != array())

{

$row = array_shift(@$_SESSION['villas']);

print_r($row);

}// einde while



?



on php 4 i get

Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 2 [1] = 3 [2] = 4
) Array ( [0] = 3 [1] = 4 [2] = 5 ) Array ( [0] = 4 [1] = 5 [2] =
6 )



on phph 5.2.9 i get a loop that doesnt end

Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1] = 2 [2] = 3
) Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1] = 2 [2] =
3 ) Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1] = 2 [2]
= 3 ) Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1] = 2
[2] = 3 ) Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1] =
2 [2] = 3 ) Array ( [0] = 1 [1] = 2 [2] = 3 ) Array ( [0] = 1 [1]
= 2 [2] = 3 ) Array ( [0] = 1 [1] = 2 [2] = 3 )


[2009-03-11 12:56:34] Henry at huis-stijl dot nl

Description:

Script was working perfectly on PHP 4 when updated to PHP5.2.9 I found
an error. I was filling a array in the session and looped it with
array_shift until the arry was empty. 

This loop kept giving me the first value but did not erased it from te
original arry.

Reproduce code:
---
$row = array_shift(@$_SESSION['villas']);

Expected result:

1. $row getting the first element from $_SESSION['villas']

2. $_SESSION['villas'] to get lost the first element.



Actual result:
--
1. $row getting the first element from $_SESSION['villas']

2. $_SESSION['villas'] did not lost the first element and was unchanged





I cann bypass this failure by using:

$arr_temp = @$_SESSION['villas'];

$row = array_shift($arr_temp);

$_SESSION['villas'] = $arr_temp;

unset($arr_temp);










-- 
Edit this bug report at http://bugs.php.net/bug.php?id=47623edit=1