Bug #63136 [Opn->Nab]: pow() returns NaN where base is negative and exponent is an odd number root

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=63136&edit=1

 ID: 63136
 Updated by: ni...@php.net
 Reported by:tstobbe at sacbee dot com
 Summary:pow() returns NaN where base is negative and
 exponent is an odd number root
-Status: Open
+Status: Not a bug
 Type:   Bug
 Package:Math related
 Operating System:   Linux (fc17, 32-bit)
 PHP Version:5.4.7
 Block user comment: N
 Private report: N

 New Comment:

Real-exponent powers are not defined for negative numbers, see 
http://en.wikipedia.org/wiki/Exponentiation#Real_exponents_with_negative_bases.

You can see this very easily if you remember that a^b is defined as 
exp(b*ln(a)) and the logarithm is only defined in the range ]0,inf[.


Previous Comments:

[2012-09-22 02:47:21] tstobbe at sacbee dot com

It should be noted that all subsequent fractional pow() issues are related to 
this. For example: pow(-[any number], 1/5) vs pow(-[any number], 2/5). Likewise 
I suspect that most other exponent based functions (such as log with an 
arbitrary base) are probably suspect, but this hasn't been verified.


[2012-09-21 22:38:15] tstobbe at sacbee dot com

Description:

Odd roots (3, 5, etc) of negative numbers passed to pow() result in NaN rather 
than the actual result. While this makes sense for even numbered roots (sqrt 
and 
what-not), it wrecks havoc on any system that actually uses arbitrary roots of 
negative numbers.

Example: -2*-2*-2 = -8; pow(-8, 1/3) should return -2

Test script:
---
var_dump(pow(-8, 1/3));


Expected result:

float(-2)


Actual result:
--
float(NAN)







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63136&edit=1


[PHP-BUG] Req #63137 [NEW]: Allow custom GLOBAL variables

2012-09-22 Thread valentiny510 at yahoo dot es
From: valentiny510 at yahoo dot es
Operating system: XP
PHP version:  5.4.7
Package:  Variables related
Bug Type: Feature/Change Request
Bug description:Allow custom GLOBAL variables

Description:

I think can be very usefull, sometimes, to be able to make a custom global
variable, like languages, configs, etc.. and working just like $GLOBALS but
only with the value/values assigned. I'm sure more than 75%-80% of the Php
users will be agreed with this change.
Imagine and array with some translation strings:

$lang = array(
'bla' => 'some nonsense talk',
'blabla' => 'More nonsense talks');

and now the 'trick'.. some function to make 'global' the $lang:
make_global( $lang );

or even set in the php.ini some configuration like:
custom_globals = "lang, config, more, etc, bla, bla"

and now we can use it on global scope
function test() { return $lang['bla']; }

is a 'nicer' way than
function test() { return $GLOBALS['lang']['bla']; }
or
function test() { global $lang; return $lang['bla']; }


Test script:
---
-- none --

Expected result:

-- none --

Actual result:
--
-- none --

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63137&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63137&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63137&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=63137&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=63137&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=63137&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63137&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=63137&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=63137&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=63137&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=63137&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=63137&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=63137&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=63137&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63137&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=63137&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=63137&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=63137&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63137&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63137&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63137&r=mysqlcfg



Req #39150 [Opn->Nab]: PHP allows invalid names for constants and variables

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=39150&edit=1

 ID: 39150
 Updated by: ni...@php.net
 Reported by:z_rules55 at hotmail dot com
 Summary:PHP allows invalid names for constants and variables
-Status: Open
+Status: Not a bug
 Type:   Feature/Change Request
-Package:Feature/Change Request
+Package:*General Issues
 Operating System:   WinXP
 PHP Version:5.1.6
 Block user comment: N
 Private report: N

 New Comment:

PHP allows arbitrary variable names using the ${'string'} syntax. The 
restrictions only apply to the $name syntax. The same applies to constants and 
various other names in PHP, which have a "plain" access method and an access 
method based on a string.


Previous Comments:

[2006-10-16 19:40:20] z_rules55 at hotmail dot com

Changing the status of this back to Open because I think it deserves further 
consideration.


[2006-10-13 19:12:22] z_rules55 at hotmail dot com

I checked the docs, and I don't see anyone else having submitted the same bug 
to the bug database.

If this is not a bug, maybe I should change it to feature request? Why would 
PHP allow the creation of variables and constants that can only be accessed 
with a work-around instead of directly, as is most natural and intuitive? You 
say "read the variable", not "access the superglobal array with the associative 
index equal to the variable's name". Likewise, why would you have to call a 
function to read a constant that you already know the name of?

Or, change the docs so they make this fact more clear: that you *can* in fact 
create variables and constants with supposedly invalid names, but you'll have a 
harder time using them later on.


[2006-10-13 15:52:01] tony2...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php




[2006-10-13 15:47:02] z_rules55 at hotmail dot com

Description:

The PHP manual states that:
A valid variable name starts with a letter or
underscore, followed by any number of letters,
numbers, or underscores.
And that constants must follow the same naming rules as variables. However, PHP 
allows me to define variables and constants with an invalid character like a 
hyphen or a dollar sign, as well as starting with a number. Those are the only 
three invalid names I tested; I assume others could also be used.

Reproduce code:
---


Expected result:

Some kind of error upon defining the constant or variable with the invalid name.

Actual result:
--
PHP happily accepts the define() with the invalid name, as well as the 
assignment to the variable variable with the invalid name. Using constant() and 
$GLOBALS to read the value of the invalid constant and variable work fine. 
Echoing the value of my-definition gives the usual warning of:
Notice: Use of undefined constant my - assumed 'my' in
C:\path\to\script.php on line 14

Notice: Use of undefined constant definition - 
assumed 'definition' in C:\path\to\script.php
on line 14

Only when you try to access the invalid constant or variable directly does PHP 
throw parse errors.






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=39150&edit=1


Req #16979 [Opn->Csd]: nested function in functions within a class

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=16979&edit=1

 ID: 16979
 Updated by: ni...@php.net
 Reported by:lazybrain at rcn dot com
 Summary:nested function in functions within a class
-Status: Open
+Status: Closed
 Type:   Feature/Change Request
-Package:Feature/Change Request
+Package:*General Issues
 Operating System:   bsd
 PHP Version:4.1.2
-Assigned To:
+Assigned To:nikic
 Block user comment: N
 Private report: N

 New Comment:

Closing as this already works.


Previous Comments:

[2002-08-12 13:57:31] ahristov at icygen dot com

AFAIK this code could work. I've written some code this way but the user has to 
guard the definition of the function somehow or on the second call os test1 
there will be fatal error.


[2002-05-02 18:29:41] lazybrain at rcn dot com

It would be helpfull to be able to 
use nested functions inside a function thats in a class.

For example...

clase something {

 function test1() {
  do something here

  // quick function to make code smaller
  function test2() {
   do more here
  }
 }

 
}






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=16979&edit=1


Req #18187 [Opn->Csd]: Consequent implementation of array referencing to user method

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=18187&edit=1

 ID: 18187
 Updated by: ni...@php.net
 Reported by:bram at totalgsm dot net
 Summary:Consequent implementation of array referencing to
 user method
-Status: Open
+Status: Closed
 Type:   Feature/Change Request
-Package:Feature/Change Request
+Package:*General Issues
 Operating System:   any
 PHP Version:4.2.1
-Assigned To:
+Assigned To:nikic
 Block user comment: N
 Private report: N

 New Comment:

Closing as the $callable() syntax now works for array-callbacks too (as of PHP 
5.4). Instead of function_exists the function is_callable can be used.


Previous Comments:

[2002-07-05 11:46:28] bram at totalgsm dot net

You support calling user methods using an array in the call_user_func() 
function. But related functions of call_user_func() don't support the syntax. I 
would like to see that function_exists could check if the user method exists. 

The following example code should work:

class Foo {
  function bar($what = 'world') {
print 'Hello ' . $what;
  }
}

$a_foo = new Foo();

$user_method = array($a_foo, 'bar');

if (!function_exists($user_method)) 
  die('You shouldn\'t see this :)');

$user_method('PHP'); // Should print "Hello PHP" ofcourse.

Furthermore the implementation of the user_method calling in call_user_func is 
incorrect for referencing variabeles, which might be pretty usefull. (see 
http://bugs.php.net/bug.php?id=17309)





-- 
Edit this bug report at https://bugs.php.net/bug.php?id=18187&edit=1


Req #18407 [Opn->Csd]: Request of new configuration directive for safe_mode

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=18407&edit=1

 ID: 18407
 Updated by: ni...@php.net
 Reported by:msteinacher at websource dot ch
 Summary:Request of new configuration directive for safe_mode
-Status: Open
+Status: Closed
 Type:   Feature/Change Request
-Package:Feature/Change Request
+Package:*General Issues
 Operating System:   Linux
 PHP Version:4.2.1
-Assigned To:
+Assigned To:nikic
 Block user comment: N
 Private report: N

 New Comment:

Closing this as safe mode is no longer supported as of PHP 5.4


Previous Comments:

[2002-07-18 05:54:21] msteinacher at websource dot ch

I suggest to add a new configuration directive for safe mode to solve the 
common problem, that a user can't change uploaded files because they have the 
UID of the user owning the webserver process and not the UID of the user owning 
the script.
I know that I could turn safe_mode off and use only open_basedir instead. 
Another 'solution' sould be to use safe_mode_gid and put the webserver-user in 
the same group as the script-owners. But I don't want to do this.
Thus my suggestion to add a new directive that could for example be called 
'safe_mode_allow_proc_uid'. If this is set to TRUE then PHP should allow the 
access to files which are owned by the user that owns the script (as it does 
now) _OR_ files which are owned by the user that owns the webserver process.

In other words: Try to implement the patch at 
http://www.zend.com/lists/php-dev/200201/msg01149.html with the option to 
enable or disable it.


Thanks for listening.
Marco





-- 
Edit this bug report at https://bugs.php.net/bug.php?id=18407&edit=1


Req #19236 [Opn->Csd]: Need $php_errorLineNumber $php_errorScript in addition to $php_errormsg

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=19236&edit=1

 ID: 19236
 Updated by: ni...@php.net
 Reported by:php-bugs at ketan dot org
 Summary:Need $php_errorLineNumber $php_errorScript in
 addition to $php_errormsg
-Status: Open
+Status: Closed
 Type:   Feature/Change Request
-Package:Feature/Change Request
+Package:*General Issues
 Operating System:   FreeBSD
 PHP Version:4.2.2
-Assigned To:
+Assigned To:nikic
 Block user comment: N
 Private report: N

 New Comment:

Closing as error_get_last() provides this information as of PHP 5.2.


Previous Comments:

[2006-04-25 13:10:02] jason_priebe at yahoo dot com

I get the point of an error_handler, but this doesn't help
when you're eval-ing code that contains a parse error.
The parse error doesn't trigger the error_handler.
$php_errormsg contains the actual error string, but doesn't
tell you what line of the eval-ed code contained the error.
The httpd error log contains the offending line number, but
AFAICT, I can't get to it inside my PHP code.


[2002-09-04 18:13:35] php-bugs at ketan dot org

It is half done the way it is now.  If we have $php_errormsg, then we should 
have the other components of the standard php error, the line number and the 
script name.  An error message in isolation is not very useful.


[2002-09-04 17:11:50] w...@php.net

That's too much magic; you can do this yourself using
set_error_handler and having your error handler set up
these global vars yourself.


[2002-09-04 16:49:35] php-bugs at ketan dot org

When using ini configuration directive track_errors = On, $php_errormsg 
contains the last error message.  We need a corresponding variable 
$php_errorLineNumber (or whatever) that keeps track of where in the file the 
error occurred, and $php_errorScriptName to tell in which file the error 
occurred (in case of include()).





-- 
Edit this bug report at https://bugs.php.net/bug.php?id=19236&edit=1


Req #18407 [Csd->Wfx]: Request of new configuration directive for safe_mode

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=18407&edit=1

 ID: 18407
 Updated by: ni...@php.net
 Reported by:msteinacher at websource dot ch
 Summary:Request of new configuration directive for safe_mode
-Status: Closed
+Status: Wont fix
 Type:   Feature/Change Request
 Package:*General Issues
 Operating System:   Linux
 PHP Version:4.2.1
 Assigned To:nikic
 Block user comment: N
 Private report: N



Previous Comments:

[2012-09-22 09:18:58] ni...@php.net

Closing this as safe mode is no longer supported as of PHP 5.4


[2002-07-18 05:54:21] msteinacher at websource dot ch

I suggest to add a new configuration directive for safe mode to solve the 
common problem, that a user can't change uploaded files because they have the 
UID of the user owning the webserver process and not the UID of the user owning 
the script.
I know that I could turn safe_mode off and use only open_basedir instead. 
Another 'solution' sould be to use safe_mode_gid and put the webserver-user in 
the same group as the script-owners. But I don't want to do this.
Thus my suggestion to add a new directive that could for example be called 
'safe_mode_allow_proc_uid'. If this is set to TRUE then PHP should allow the 
access to files which are owned by the user that owns the script (as it does 
now) _OR_ files which are owned by the user that owns the webserver process.

In other words: Try to implement the patch at 
http://www.zend.com/lists/php-dev/200201/msg01149.html with the option to 
enable or disable it.


Thanks for listening.
Marco





-- 
Edit this bug report at https://bugs.php.net/bug.php?id=18407&edit=1


Req #61222 [Opn->Dup]: For... else construct

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=61222&edit=1

 ID: 61222
 Updated by: ni...@php.net
 Reported by:jeroenvandenenden at gmail dot com
 Summary:For... else construct
-Status: Open
+Status: Duplicate
 Type:   Feature/Change Request
 Package:Arrays related
 PHP Version:Irrelevant
 Block user comment: N
 Private report: N

 New Comment:

Closing as duplicate of https://bugs.php.net/bug.php?id=26411.


Previous Comments:

[2012-03-25 17:57:54] phristen at yahoo dot com

There are already bugs for foreach { } else { } and while { } else { }, both 
highly rated.
I think this should be all consolidated into a single bug or an RFC, or it will 
never get done.


[2012-03-01 15:42:43] jeroenvandenenden at gmail dot com

Of course instead of

for ($val in $array) {

I meant

foreach ($array as $val) {


[2012-03-01 15:27:36] jeroenvandenenden at gmail dot com

Description:

It would be nice to have a for...else construct like you see in other 
languages. 
This makes the code more compact and readable and it avoids the necessity to 
combine an if and a for loop.

Test script:
---
for ($val in $array) {
  echo $val.'';
} else {
  echo 'No values found';
}

Expected result:

In the case of an empty array, the else part would be called. Without this 
construct the code would be as follows.

if (count($array) > 0) {
  for ($val in $array) {
echo $val.'';
  }
} else {
  echo 'No values found';
}







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61222&edit=1


Req #21555 [Opn->Dup]: Possible extensions to alternative control syntax

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=21555&edit=1

 ID: 21555
 Updated by: ni...@php.net
 Reported by:gabe at bravenet dot com
 Summary:Possible extensions to alternative control syntax
-Status: Open
+Status: Duplicate
 Type:   Feature/Change Request
-Package:Feature/Change Request
+Package:*General Issues
 Operating System:   All
 PHP Version:4.3.0
 Block user comment: N
 Private report: N

 New Comment:

Closing as duplicate of https://bugs.php.net/bug.php?id=26411. (This bug is 
older, but the other one has more discussion.)


Previous Comments:

[2003-01-09 15:48:14] gabe at bravenet dot com

The alternative control structure syntax (see 
http://php.benscom.com/manual/en/control-structures.alternative-syntax.php)  is 
very useful for templating purposes. However, I miss the smarty-style 'else' 
clauses: foreachelse, whileelse etc.

I would like to be able to do this:


// if array has items, this is repeated once per item


// we get here if $array has no items, then exit



...or this...


// repeated while condition is met


// if condition is never met we go here once and exit.



I think these additions would be fairly useful.





-- 
Edit this bug report at https://bugs.php.net/bug.php?id=21555&edit=1


Req #40218 [Opn->Dup]: Add Else clause to while

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=40218&edit=1

 ID: 40218
 Updated by: ni...@php.net
 Reported by:jbailey at raspberryginger dot com
 Summary:Add Else clause to while
-Status: Open
+Status: Duplicate
 Type:   Feature/Change Request
-Package:Feature/Change Request
+Package:*General Issues
 Operating System:   Linux
 PHP Version:5.2.0
 Block user comment: N
 Private report: N

 New Comment:

Closing as duplicate of https://bugs.php.net/bug.php?id=26411.


Previous Comments:

[2007-01-24 15:08:50] didou at keliglia dot com

I like the idea, but using the "else" keyword would break a lot of apps using 
something like this:

if (X)
  while (foo) {

  }
else
  no X

whileelse ?


[2007-01-24 14:31:11] jbailey at raspberryginger dot com

Grr..  This bug tracking system ate my comment.  So here's a much shorter 
version of what I wrote:

Use cases:

Retrieving from a database (especially since PDO doesn't have a numrows 
options):

while ($foo = $db->sql_fetchrow($result)) {
// Do something
} else {
// No rows found
}

This could also be useful for ArrayObjects and foreach:

$i = $myArray->getIterator();

foreach ($i as $item) {
// Do something
} else {
// Empty array
}


[2007-01-24 14:18:57] jbailey at raspberryginger dot com

Description:

Right now checks have to be done separately for when a while will execute zero 
times, which means code duplication and constructs that have to be kept in 
sync.  I would like to see an else clause to while that is executed when the 
while loop goes zero times.

Reproduce code:
---
while (0) {
  echo "I ran";
} else {
  echo "I didn't run.";
}



Expected result:

I didn't run.


Actual result:
--
Parse error: syntax error, unexpected T_ELSE in /tmp/test.php on line 5







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=40218&edit=1


Req #27612 [Opn->Dup]: "else" statement for "foreach" construct

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=27612&edit=1

 ID: 27612
 Updated by: ni...@php.net
 Reported by:camka at email dot ee
 Summary:"else" statement for "foreach" construct
-Status: Open
+Status: Duplicate
 Type:   Feature/Change Request
-Package:Feature/Change Request
+Package:*General Issues
 Operating System:   Any
 PHP Version:Irrelevant
 Block user comment: N
 Private report: N

 New Comment:

Closing as duplicate of https://bugs.php.net/bug.php?id=26411.


Previous Comments:

[2004-03-16 04:05:39] camka at email dot ee

Description:

"else" statement would be very useful and comfortable when the array_expression 
in foreach construct is empty. There'd be no need to calculate count(array) 
every time you need to execute some code in case of empty array. 
Smarty has such syntax and it really helps.

Reproduce code:
---
$count = count($array);

foreach($array as $arr)
{
...
}

if(!$count)
{
...
}

===

foreach($array as $arr)
{
...
}
else //may be [foreachelse] or [elseforeach]
{
...
}







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=27612&edit=1


Req #46240 [Opn->Dup]: Build in foreach else support

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=46240&edit=1

 ID: 46240
 Updated by: ni...@php.net
 Reported by:kjarli at gmail dot com
 Summary:Build in foreach else support
-Status: Open
+Status: Duplicate
 Type:   Feature/Change Request
 Package:Scripting Engine problem
 Operating System:   *
 PHP Version:5.2.6
 Block user comment: N
 Private report: N

 New Comment:

Closing as duplicate of https://bugs.php.net/bug.php?id=26411.


Previous Comments:

[2011-12-22 20:41:46] jason at valdron dot ca

I completely disagree about the onFail section.

The foreach else would be useful if there is no item. As a shortcut to 
if(count($elements) == 0).


[2011-07-12 12:13:44] dinumarina at yahoo dot com

Opposing general consensus, I think adding such feature would be semantically 
ambiguous. The foreach function does not fail, it has types it can handle 
(assoc 
array, object) and that it can't handle (scalar). A function can always return 
a 
result that may be valid for foreach but not the expected format, so I think 
data sanitizing is best done dilligently. This is just a lazy-man's hack for a 
non-issue. For the function completion status (onFail), there is already such a 
construct: try {throw()} catch(){} which already supersets the imagined onFail 
implementation. Only thing I would hindsight: it would have been SOOO nice if 
php had a false/null/na result convention, as well as an error/exception 
convention and it would actually stick by it. Each module signals completion, 
computability, singular cases and errors as it well pleases.


[2011-02-18 01:20:24] ijrbiz at gmail dot com

Highly agreed with adding a foreach :: else statement, this request would be 
very 
practical for improved coding structure and follows logical language syntax 
nicely.

foreach ($items as $item) {
echo $item; // Manage each item, ...
} else {
echo 'No items present.'; // Manage no items found, ...
}


[2011-02-04 02:30:00] pedro at worcel dot com

foreachelse seems ok to me. Onfail is... weird. :)


[2010-12-20 13:40:54] rick dot sketchy at gmail dot com

I have to agree with the OP. foreachelse (or something similar) is really 
needed. I do like the suggestion posted by cerlestes at googlemail dot com:

foreach($arr as $var)
{
doCode();
}
onFail
{
failHandling();
}

A fail handler would prove useful,however I can see it may have some 
limitations, in which case an else option on the foreach would be satisfactory. 
Whilst we're at it, it may as well be added to while statements too.




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

https://bugs.php.net/bug.php?id=46240


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=46240&edit=1


Req #21913 [Opn->Csd]: formatting for sci notation

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=21913&edit=1

 ID: 21913
 Updated by: ni...@php.net
 Reported by:sprice at wisc dot edu
 Summary:formatting for sci notation
-Status: Open
+Status: Closed
 Type:   Feature/Change Request
-Package:Feature/Change Request
+Package:*General Issues
 Operating System:   Mac OS X.2.3
 PHP Version:4.3.0
-Assigned To:
+Assigned To:nikic
 Block user comment: N
 Private report: N

 New Comment:

Closing as scientific notation is already available via %e, %E (and %g, %G for 
mixed).


Previous Comments:

[2003-01-27 19:30:52] sprice at wisc dot edu

I humbly request that scientific notation formatting (ex. 7.16e-11) is added to 
the function sprintf(). Currently I am using a function supplied by another 
user:

function sci($x, $d=-1) { 
$e=floor(log10($x)); 
$x*=pow(10,-$e); 
$fmt=($d>=0)?".".$d:""; 
$e=($e>=0)?"+".sprintf("%02d",$e):"-".sprintf("%02d",-$e); 
return sprintf("%".$fmt."fe%s",$x,$e); 
}


and can be found in the comments of this page:
http://www.php.net/manual/en/function.sprintf.php

This function seems to be working fine for the time being, but this seems like 
somethine many other people would use and an addition to PHP itself would be 
better.





-- 
Edit this bug report at https://bugs.php.net/bug.php?id=21913&edit=1


Bug #61141 [Com]: curl_multi_select returns -1

2012-09-22 Thread amoo_miki at yahoo dot com
Edit report at https://bugs.php.net/bug.php?id=61141&edit=1

 ID: 61141
 Comment by: amoo_miki at yahoo dot com
 Reported by:amoo_miki at yahoo dot com
 Summary:curl_multi_select returns -1
 Status: Assigned
 Type:   Bug
 Package:cURL related
 Operating System:   Windows 7 x64
 PHP Version:5.3.10
 Assigned To:pierrick
 Block user comment: N
 Private report: N

 New Comment:

PHP 5.3.17 and 5.4.7 too suffer from this bug.


Previous Comments:

[2012-06-06 20:57:57] ihate at spam dot com

Always returns -1 on Windows 7 64bit. Tried on 5.4 and 5.4.3. It worked a 
couple 
of months ago, perhaps some Win7 update changed something.


[2012-05-30 02:48:04] larue...@php.net

Pierrick, could you please look at this? :)


[2012-05-29 11:52:09] amoo_miki at yahoo dot com

I can confirm that PHP 5.4.3 (cli) (built: May  8 2012 00:23:27) suffers from 
the same bug.


[2012-05-25 12:08:45] kulminaator at gmail dot com

Running PHP 5.4.0 on Windows 7 has the same issue,  curl_multi_select always  
returns -1 


PHP Version => 5.4.0
System => Windows NT MSA-3644048 6.1 build 7601 (Windows 7 Enterprise Edition 
Service Pack 1) i586

cURL support => enabled
cURL Information => 7.24.0
Age => 3
Features
AsynchDNS => Yes
Debug => No
GSS-Negotiate => Yes
IDN => No
IPv6 => Yes
Largefile => Yes
NTLM => Yes
SPNEGO => No
SSL => Yes
SSPI => Yes
krb4 => No
libz => Yes
CharConv => No
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, 
pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host => i386-pc-win32
SSL Version => OpenSSL/0.9.8t
ZLib Version => 1.2.5
libSSH Version => libssh2/1.3.0


[2012-04-03 16:26:35] bompus at gmail dot com

Related to 60790 and 61240




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

https://bugs.php.net/bug.php?id=61141


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61141&edit=1


Req #63137 [Com]: Allow custom GLOBAL variables

2012-09-22 Thread valentiny510 at yahoo dot es
Edit report at https://bugs.php.net/bug.php?id=63137&edit=1

 ID: 63137
 Comment by: valentiny510 at yahoo dot es
 Reported by:valentiny510 at yahoo dot es
 Summary:Allow custom GLOBAL variables
 Status: Open
 Type:   Feature/Change Request
 Package:Variables related
 Operating System:   XP
 PHP Version:5.4.7
 Block user comment: N
 Private report: N

 New Comment:

I "flashed" the source code and founded the "zend_register_auto_global" and Im 
sure it can be done in the "php_startup_auto_globals" function or some other 
place, php_variables.c or zend.c just like:

zend_register_auto_global("GLOBALS", sizeof("GLOBALS") - 1, 1, 
php_auto_globals_create_globals TSRMLS_CC);

but with our custom variable from php.ini for example.. just use 
ZEND_INI_ENTRY("custom_globals" ... and done ! :D
I know it can be done easy but now depend of you guys if you want to implement 
it or not.


Previous Comments:

[2012-09-22 08:23:36] valentiny510 at yahoo dot es

Description:

I think can be very usefull, sometimes, to be able to make a custom global 
variable, like languages, configs, etc.. and working just like $GLOBALS but 
only with the value/values assigned. I'm sure more than 75%-80% of the Php 
users will be agreed with this change.
Imagine and array with some translation strings:

$lang = array(
'bla' => 'some nonsense talk',
'blabla' => 'More nonsense talks');

and now the 'trick'.. some function to make 'global' the $lang:
make_global( $lang );

or even set in the php.ini some configuration like:
custom_globals = "lang, config, more, etc, bla, bla"

and now we can use it on global scope
function test() { return $lang['bla']; }

is a 'nicer' way than
function test() { return $GLOBALS['lang']['bla']; }
or
function test() { global $lang; return $lang['bla']; }


Test script:
---
-- none --

Expected result:

-- none --

Actual result:
--
-- none --






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63137&edit=1


Req #22958 [Opn->Wfx]: more returned elements from debug_backtrace() function

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=22958&edit=1

 ID: 22958
 Updated by: ni...@php.net
 Reported by:ondrej at kmit dot sk
 Summary:more returned elements from debug_backtrace()
 function
-Status: Open
+Status: Wont fix
 Type:   Feature/Change Request
-Package:Feature/Change Request
+Package:*General Issues
 Operating System:   any
 PHP Version:4.3.0
 Block user comment: N
 Private report: N

 New Comment:

Adding such information would add significant overhead to function calls. If 
you want to have profiling information, use a profiling extension (e.g. XDebug 
or xhprof).


Previous Comments:

[2003-03-30 05:12:39] ondrej at kmit dot sk

Add enter/exit high resolution timestamp for function, memmory usage to 
debug_buacktrace output.









-- 
Edit this bug report at https://bugs.php.net/bug.php?id=22958&edit=1


Req #23346 [Opn->Wfx]: stripslashes extention

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=23346&edit=1

 ID: 23346
 Updated by: ni...@php.net
 Reported by:php at dries dot net
 Summary:stripslashes extention
-Status: Open
+Status: Wont fix
 Type:   Feature/Change Request
-Package:Feature/Change Request
+Package:*General Issues
 Operating System:   all
 PHP Version:4.3.0
 Block user comment: N
 Private report: N

 New Comment:

Closing as magic quotes were dropped in PHP 5.4.


Previous Comments:

[2003-04-25 10:38:20] php at dries dot net

I think it would be usefull to extend the stripslashes function so it would 
check for magic_quotes on or of. So, for example:

stripslashes($string) would always strip slashes

while

stripslashes($string, 1) would only strip slashes when magic_quotes is on





-- 
Edit this bug report at https://bugs.php.net/bug.php?id=23346&edit=1


[PHP-BUG] Bug #63138 [NEW]: dozens of implicit declarations in custom configure tests

2012-09-22 Thread lullol at yopmail dot com
From: lullol at yopmail dot com
Operating system: Linux
PHP version:  5.4Git-2012-09-22 (Git)
Package:  Compile Failure
Bug Type: Bug
Bug description:dozens of implicit declarations in custom configure tests

Description:

basically all custom (i.e. written by php coders rather than autoconf
authors) 
configure checks use exit() but fail to include  which defines
this 
function.
they use strcmp without including 

etc etc

so if your distro toolchain has -Werror-implicit-function-declaration baked
in 
(which is basically a very sane feature to use, because it will prevent
broken 
code generation on platforms where sizeof(int) != sizeof(void*), like
amd64), 
all these tests will fail, and either cause total build failure, cause 
duplicated code to get pulled in, or build without some optional packages
which 
are misdetected as not existing.

examples include: (using the cache variable names of those tests)

  _cv_have_broken_glibc_fopen_append
  ac_cv_what_readdir_r
  ac_cv_crypt_blowfish
  ac_cv_crypt_md5
  ac_cv_crypt_SHA256
  ac_cv_crypt_SHA512
  ac_cv_crypt_des
  ac_cv_crypt_ext_des
  ac_cv_pwrite
  ac_cv_pread

the broken "what readdir_r" check will cause "old readdir_r" support code
get 
compiled, which fails to build because it is using an invalid prototype for

POSIX readdir_r.

to find all such issues automatically, it is recommended to use "CC=gcc
-Werror-
implicit-function-declaration" ./configure, then grep config.log for
"error: 
implicit declaration"

additionally, musl libc should be used for this instead of glibc, because
the 
latter has numerous namespace issues. for example on glibc, including
 
will automatically cause  to get pulled in, thus hiding the issue
with 
exit().

another approach is to manually go through all the custom tests, analyse
which 
functions are used and add the headers that define it according to the
POSIX or 
C spec.




-- 
Edit bug report at https://bugs.php.net/bug.php?id=63138&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63138&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63138&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=63138&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=63138&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=63138&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63138&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=63138&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=63138&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=63138&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=63138&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=63138&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=63138&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=63138&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63138&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=63138&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=63138&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=63138&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63138&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63138&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63138&r=mysqlcfg



Bug #61240 [Opn->Nab]: curl_multi_select cause cpu load 100%

2012-09-22 Thread pierrick
Edit report at https://bugs.php.net/bug.php?id=61240&edit=1

 ID: 61240
 Updated by: pierr...@php.net
 Reported by:niniwzw at qq dot com
 Summary:curl_multi_select cause cpu load 100%
-Status: Open
+Status: Not a bug
 Type:   Bug
 Package:cURL related
 Operating System:   window xp
 PHP Version:5.3.10
-Assigned To:
+Assigned To:pierrick
 Block user comment: N
 Private report: N

 New Comment:

This is not a bug. This behaviour is due to the same reason as bug #61141 (cf 
my 
comment on this bug).


Previous Comments:

[2012-04-05 02:01:06] niniwzw at qq dot com

the best solution work without the curl_multi_select may be this:
http://lxr.php.net/";);
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/";);
curl_setopt($ch2, CURLOPT_HEADER, 0);

//create the multiple cURL handle
$mh = curl_multi_init();

//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$active = null;
$exec_count = 0;
do {
$mrc = curl_multi_exec($mh, $active);
usleep(1);
$exec_count++;
} while ($mrc == CURLM_CALL_MULTI_PERFORM || ($active && $mrc == CURLM_OK));

//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);

var_dump($exec_count);
?>
I scan the source code of curl_multi_select, there was no change from php 
5.2.17 to 5.3.10, may be it's the problem of libcurl(curl_multi_fdset, fuction)


[2012-04-03 16:27:47] bompus at gmail dot com

Related to 60790 and 61141


[2012-03-02 08:51:47] niniwzw at qq dot com

Description:

---
>From manual page: http://www.php.net/function.curl-multi-exec
---
In the document of curl_multi_exec, has a example in the document.
it can run in php 5.2, but php 5.3 and php 5.4 cause cpu load 100%.

the example is:
http://lxr.php.net/";);
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/";);
curl_setopt($ch2, CURLOPT_HEADER, 0);

//create the multiple cURL handle
$mh = curl_multi_init();

//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$active = null;
//execute the handles
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}

//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);

?>







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61240&edit=1


Bug #60790 [Opn->Fbk]: "curl_multi_select" executed first time always one second

2012-09-22 Thread pierrick
Edit report at https://bugs.php.net/bug.php?id=60790&edit=1

 ID: 60790
 Updated by: pierr...@php.net
 Reported by:leonchuk at gmail dot com
 Summary:"curl_multi_select" executed first time always one
 second
-Status: Open
+Status: Feedback
 Type:   Bug
 Package:cURL related
 Operating System:   windows (XP,7)
 PHP Version:5.3.9
 Block user comment: N
 Private report: N

 New Comment:

This behavior is probably related to Bug #61141. Can you try this script 

$ch1 = curl_init();
curl_setopt_array($ch1, array(CURLOPT_URL=>"http://lxr.php.net/";, 
CURLOPT_HEADER=>0, CURLOPT_RETURNTRANSFER=>1));
$mh = curl_multi_init();
curl_multi_add_handle($mh,$ch1);

$active = null;
do $mrc = curl_multi_exec($mh, $active);
while ($mrc == CURLM_CALL_MULTI_PERFORM);

$start_time = microtime(true);

while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) == -1) { 
usleep(100);
}
do $mrc = curl_multi_exec($mh, $active);
while ($mrc == CURLM_CALL_MULTI_PERFORM);
}

curl_multi_remove_handle($mh, $ch1); curl_multi_close($mh);

And let me know if you still have your problem ?


Previous Comments:

[2012-04-03 16:27:11] bompus at gmail dot com

Possibly related to 61141 and 61240


[2012-03-24 07:28:59] qiwei dot mo at gmail dot com

I have the same problem white them.
Env: win7 + php5.4.0

Use the code as curl_multi-exec
http://cn2.php.net/manual/zh/function.curl-multi-exec.php
cause the final error: Fatal error: Maximum execution time of 30 seconds 
exceeded. But it be runing well in php5.3.6

In PHP5.4 , when i replace the under code
---
$active = null;
// 执行批处理句柄
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
--
With

do {
curl_multi_exec($hMultiCurl, $iRunning);
} while ($iRunning > 0);
-

the programe run ok

So the question is the curl_multi_select bug , cause the while infinite loop.


[2012-02-28 17:04:37] bompus at gmail dot com

I've noticed this as well. The function should return as soon as it is finished 
I 
believe. This could be a CURL issue or a PHP issue. I'm interested to hear what 
the dev's say since I've had all kinds of issues with curl_multi_select in 
newer 
PHP versions. I keep having to revert to 5.3.6.. I've tried 5.3.10 and using 
curl_multi_select within a loop checking for != -1 and it causes an infinite 
loop 
since it always returns -1 on Windows 7 x64/x86, PHP 5.3.10


[2012-01-18 13:18:08] leonchuk at gmail dot com

Description:

In Windows (tested XP and w7) function "curl_multi_select" executed first time 
always one second (equal to default parameter - $timeout)

---
>From manual page: 
>http://www.php.net/function.curl-multi-init#refsect1-function.curl-multi-init-examples
---


Test script:
---
$ch1 = curl_init();
curl_setopt_array($ch1, array(CURLOPT_URL=>"http://lxr.php.net/";, 
CURLOPT_HEADER=>0, CURLOPT_RETURNTRANSFER=>1));
$mh = curl_multi_init();
curl_multi_add_handle($mh,$ch1);

$active = null;
do $mrc = curl_multi_exec($mh, $active);
while ($mrc == CURLM_CALL_MULTI_PERFORM);

$start_time = microtime(true);

while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) { #after first run = 1 sec
echo (microtime(true)-$start_time)."".PHP_EOL; 
do $mrc = curl_multi_exec($mh, $active);
while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}

curl_multi_remove_handle($mh, $ch1); curl_multi_close($mh);







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60790&edit=1


Bug #62641 [Opn->Nab]: curl_multi times out

2012-09-22 Thread pierrick
Edit report at https://bugs.php.net/bug.php?id=62641&edit=1

 ID: 62641
 Updated by: pierr...@php.net
 Reported by:jimi_barka at yahoo dot com
 Summary:curl_multi times out
-Status: Open
+Status: Not a bug
 Type:   Bug
 Package:cURL related
 Operating System:   Windows 7
 PHP Version:5.4.5
 Block user comment: N
 Private report: N

 New Comment:

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

This bug is a duplicate of Bug #61141


Previous Comments:

[2012-07-23 15:08:11] jimi_barka at yahoo dot com

Description:

Running the sample script provided here: 
http://php.net/manual/en/function.curl-multi-init.php results in a timeout. 
This bug is not present in version 5.3.8, but does appear in 5.4.0 and in later 
versions, including version 5.4.5.

PHP info (excerpt):
System  Windows NT 6.1 build 7601 (Windows 7 Business Edition Service Pack 1) 
i586
Build Date  Jul 18 2012 22:21:56
CompilerMSVC9 (Visual C++ 2008)
Architecturex86
Configure Command   cscript /nologo configure.js "--enable-snapshot-build" 
"--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" 
"--without-pi3web" 
"--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" 
"--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" 
"--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" 
"--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" 
"--with-mcrypt=static" "--disable-static-analyze" "--with-pgo" 

Apache Version  Apache/2.2.22 (Win32) PHP/5.4.5 


Binaries from 
http://windows.php.net/downloads/releases/php-5.4.5-Win32-VC9-x86.zip

Test script:
---
http://php.net/manual/en/function.curl-multi-init.php
Example #1 curl_multi_init() example

Expected result:

Display contents of http://lxr.php.net/ and http://www.php.net/

Actual result:
--
Script times out with a message:
Fatal error: Maximum execution time of 30 seconds exceeded in E:\www\curl.php 
on line 26






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62641&edit=1


Bug #62036 [Opn->Fbk]: CURLOPT_RETURNTRANSFER returns both boolean and response

2012-09-22 Thread pierrick
Edit report at https://bugs.php.net/bug.php?id=62036&edit=1

 ID: 62036
 Updated by: pierr...@php.net
 Reported by:ken dot depelchin at gmail dot com
 Summary:CURLOPT_RETURNTRANSFER returns both boolean and
 response
-Status: Open
+Status: Feedback
 Type:   Bug
 Package:cURL related
 Operating System:   N/A
 PHP Version:5.3.13
 Block user comment: N
 Private report: N

 New Comment:

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with ,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

The script work for me if I do a json_decode of $result. Can you give me the 
exact script you're using to get your problem (if it's not this one) but also 
the 
expected and actual result.


Previous Comments:

[2012-05-15 11:18:33] ken dot depelchin at gmail dot com

Description:

When calling a API and converting the response to an associative array, the 
returned response can not be converted because of the extra boolean in the 
response. Only viewable when exit($response)

The options of the cURL operation are set using the @curl_setopt_array($ch, 
$array).

When checked for the header, it does not indicate any problem and it outputs 
the correct content (with content length)

When dumped the boolean is dumped with the correct response.



Test script:
---
// check if curl is available
if(!function_exists('curl_init')) throw new Exception('This method requires 
cURL (http://php.net/curl), it seems like the extension isn\'t installed.');
$url = 
'http://ws.audioscrobbler.com/2.0/?method=album.getbuylinks&artist=radiohead&album=in%20rainbows&country=united%20kingdom&api_key=b25b959554ed76058ac220b7b2e0a026&format=json';

// set options
//  $options[CURLOPT_URL] = (string) $url;
//  $options[CURLOPT_USERAGENT] = 'PlonkHTTP '. self::version;
//  $options[CURLOPT_FOLLOWLOCATION] = true;
//  $options[CURLOPT_RETURNTRANSFER] = true;
//  $options[CURLOPT_TIMEOUT] = 20;
//  $options[CURLOPT_HEADER] = true;
// init
$curl = @curl_init();
//  @curl_setopt_array($curl, $options);
curl_setopt($curl,CURLOPT_URL, (string) $url);
curl_setopt($curl,CURLOPT_USERAGENT,'PlonkHTTP');
curl_setopt($curl,CURLOPT_RETURNTRANSFER, true);
// execute
$response = @curl_exec($curl);
// fetch errors
$errorNumber = @curl_errno($curl);
$errorMessage = @curl_error($curl);
// close
@curl_close($curl);

Expected result:

The script will result in a decent response on a local webserver. In a 
production environment, it gives the extra boolean when outputted.

Actual result:
--
http://ws.audioscrobbler.com/2.0/?method=album.getbuylinks&artist=radiohead&album=in%20rainbows&country=united%20kingdom&api_key=b25b959554ed76058ac220b7b2e0a026&format=json






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62036&edit=1


Bug #63132 [Opn->Csd]: Generators do not back up argument type stack

2012-09-22 Thread nikic
Edit report at https://bugs.php.net/bug.php?id=63132&edit=1

 ID: 63132
 Updated by: ni...@php.net
 Reported by:ni...@php.net
 Summary:Generators do not back up argument type stack
-Status: Open
+Status: Closed
 Type:   Bug
 Package:Scripting Engine problem
 PHP Version:5.4Git-2012-09-21 (Git)
 Block user comment: N
 Private report: N

 New Comment:

Automatic comment on behalf of nikic
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=a31fa55b44bcb342c00e9ab2f4a851d054897a39
Log: Fixed bug #63132


Previous Comments:

[2012-09-21 14:53:18] ni...@php.net

Description:

As reported by dmitry in https://bugs.php.net/bug.php?id=63066 there currently 
are issues with yield interruptions in nested method calls.

The following code:

foo($obj->foo(yield));
}

$g1 = gen(new A);
$g1->current();

$g2 = gen(new B);
$g2->current();

$g1->next();

Will output:

Called A::foo
Called B::foo
[Fri Sep 21 16:49:14 2012]  Script:  '/home/nikic/dev/php-src/t26.php'
/home/nikic/dev/php-src/Zend/zend_vm_execute.h(949) :  Freeing 0xB77579F0 (20 
bytes), script=/home/nikic/dev/php-src/t26.php
=== Total 1 memory leaks detected ===

The issue is that generators currently only back up the argument stack (the 
main VM stack), but don't back up the argument type stack EG(arg_types_stack). 
This stack contains object and fbc.

So when two generators with nested method calls are intermixed the VM mixes up 
the different objects/fbcs (and if a generator is closed during the nested 
method call the object leaks).







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63132&edit=1


Bug #63138 [Com]: dozens of implicit declarations in custom configure tests

2012-09-22 Thread lullol at yopmail dot com
Edit report at https://bugs.php.net/bug.php?id=63138&edit=1

 ID: 63138
 Comment by: lullol at yopmail dot com
 Reported by:lullol at yopmail dot com
 Summary:dozens of implicit declarations in custom configure
 tests
 Status: Open
 Type:   Bug
 Package:Compile Failure
 Operating System:   Linux
 PHP Version:5.4Git-2012-09-22 (Git)
 Block user comment: N
 Private report: N

 New Comment:

oops, _cv_have_broken_glibc_fopen_append doesn't belong to this group, it is 
broken in its own special way, in that it is triggered whenever you don't use 
glibc.


Previous Comments:

[2012-09-22 13:26:28] lullol at yopmail dot com

Description:

basically all custom (i.e. written by php coders rather than autoconf authors) 
configure checks use exit() but fail to include  which defines this 
function.
they use strcmp without including 

etc etc

so if your distro toolchain has -Werror-implicit-function-declaration baked in 
(which is basically a very sane feature to use, because it will prevent broken 
code generation on platforms where sizeof(int) != sizeof(void*), like amd64), 
all these tests will fail, and either cause total build failure, cause 
duplicated code to get pulled in, or build without some optional packages which 
are misdetected as not existing.

examples include: (using the cache variable names of those tests)

  _cv_have_broken_glibc_fopen_append
  ac_cv_what_readdir_r
  ac_cv_crypt_blowfish
  ac_cv_crypt_md5
  ac_cv_crypt_SHA256
  ac_cv_crypt_SHA512
  ac_cv_crypt_des
  ac_cv_crypt_ext_des
  ac_cv_pwrite
  ac_cv_pread

the broken "what readdir_r" check will cause "old readdir_r" support code get 
compiled, which fails to build because it is using an invalid prototype for 
POSIX readdir_r.

to find all such issues automatically, it is recommended to use "CC=gcc -Werror-
implicit-function-declaration" ./configure, then grep config.log for "error: 
implicit declaration"

additionally, musl libc should be used for this instead of glibc, because the 
latter has numerous namespace issues. for example on glibc, including  
will automatically cause  to get pulled in, thus hiding the issue 
with 
exit().

another approach is to manually go through all the custom tests, analyse which 
functions are used and add the headers that define it according to the POSIX or 
C spec.









-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63138&edit=1