Bug #50696 [Com]: number_format when passed a 0 as first function argument, returns null

2011-08-22 Thread jacob at jacobweber dot com
Edit report at https://bugs.php.net/bug.php?id=50696edit=1

 ID: 50696
 Comment by: jacob at jacobweber dot com
 Reported by:endosquid at endosquid dot com
 Summary:number_format when passed a 0 as first function
 argument, returns null
 Status: Wont fix
 Type:   Bug
 Package:Math related
 Operating System:   Linux 32 bit
 PHP Version:5.3.1
 Block user comment: N
 Private report: N

 New Comment:

Fun thread! Anyway, I was wondering if anyone has a complete list of the 
functions 
that changed as a result of this zend_parse_parameters() fix. I don't see 
anything 
specific in the upgrade instructions:
  http://www.php.net/manual/en/migration53.incompatible.php

Also, will number_format((float) $x) behave under PHP 5.3.x exactly the same 
way 
that number_format($x) behaved under PHP 5.2.x? Are there any subtle 
differences?

Thanks.


Previous Comments:

[2010-01-08 23:47:19] bj...@php.net

Sir.

This issue was recently brought to my attention.
On behalf of PHP I would like to apologize. I see that now that you have been 
treated unfairly.

After carefully reviewing this bug report with our board of directors on 4chan, 
we have come to the conclusion that your rusty C skills should be enough to 
fix the issue.
I would therefore like to remind you that ras...@php.net is 
http://en.wikipedia.org/wiki/Rasmus_lerdorf

Again, I sincerely apologize. We will try to stop fixing bugs in PHP.



[2010-01-08 23:22:52] endosquid at endosquid dot com

Just look in the mirror, pal.

You need classes on how to listen to others.


[2010-01-08 23:20:13] ras...@php.net

Wow, a classic case of how not to treat unpaid volunteers who provide 
critical pieces of your money-making infrastructure.


[2010-01-08 23:05:43] endosquid at endosquid dot com

I get it. Yours is bigger, you've worked better, you are at the cutting edge of 
everything, and you have infinite resources to test every new version of every 
piece of software in your stack. Got it. I'm shamed and have no options. So, 
you're going to give a cover-all answer to make sure that you don't have to do 
anything. Ok, I get it. I hope no one ever does this to you, because it makes 
you lose faith in the product.

We will push forwrd with patching the source. It would appear that the 1194th 
line in math.c is the one that needs changing. returning 0 as opposed to 
returning nothing? I'll edit and compile.


[2010-01-08 22:47:04] ras...@php.net

I have worked in such environments.  Much bigger ones, in fact.  Part 
of your responsibility in your position is to keep track of your tools 
and the changes coming down the pipeline.  5.3 was available to you as 
a release candidate in March of last year, and even earlier directly 
from our revision control system.  Many things have changed and there 
are many many people out there affected by these changes, we recognize 
that.  That is also why we are not likely to reverse a change like this 
that others in your situation have now accounted for, tested and 
deployed in production for many months simply because it is 
inconvenient for you.




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=50696


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


[PHP-BUG] Bug #54147 [NEW]: debug_backtrace increases memory usage

2011-03-02 Thread jacob at jacobweber dot com
From: 
Operating system: Red Hat Linux
PHP version:  5.2.17
Package:  Unknown/Other Function
Bug Type: Bug
Bug description:debug_backtrace increases memory usage

Description:

Calling debug_backtrace(false) can lead to a huge increase in memory usage,
if 

it's called from within a function that was passed a huge string as an
argument. 

This is because the string will be duplicated in the args field of the
result.



It would be nice to have another boolean argument to debug_backtrace, that
would 

tell it to skip the args field. This would be similar to the one that
skips the 

object field.



Or could the arguments be returned as references, so they don't increase
memory 

usage?

Test script:
---
function test($str) {

echo before: .round(memory_get_usage()/1024/1024, 2). MB\n;

debug_backtrace(false);

echo after: .round(memory_get_usage()/1024/1024, 2). MB\n;

}

test(str_repeat('a', 1000));



Expected result:

before: 9.59 MB

after: 9.59 MB



(This is what I get if I remove the debug_backtrace() call.)

Actual result:
--
before: 9.59 MB

after: 19.12 MB

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



Req #34502 [Com]: method chaining on constructor causes parse error

2010-06-15 Thread jacob at jacobweber dot com
Edit report at http://bugs.php.net/bug.php?id=34502edit=1

 ID:   34502
 Comment by:   jacob at jacobweber dot com
 Reported by:  goat at daholygoat dot com
 Summary:  method chaining on constructor causes parse error
 Status:   Open
 Type: Feature/Change Request
 Package:  Feature/Change Request
 Operating System: Linux
 PHP Version:  5.0.5

 New Comment:

Here's a workaround: use a static factory method:

class A {

  public static function create($str) {

return new A($str);

  }

  ...

}

echo A::create(hello)-returnStr();


Previous Comments:

[2010-02-14 23:34:49] jaka at kubje dot org

You're complicating things too much.



You can solve this by simply making 'new' bind stronger than '-'.



And even if it doesn't, this should still work:

(new A('foo'))-someMethod();


[2009-07-18 21:38:04] spidgorny at gmail dot com

Here's the ugly trick how to do object instantiation and chaining in one
line:



$view-loginForm = end($_ = array(

$l = new Login(),

$l-render()-chain()-everything()-you()-like()

));



$_ and $l are two unnecessary variables. I told you - it's ugly.



Anybody can make it better?

Any ETA for implementing it in PHP directly?

Hello visitor. Please vote.


[2005-09-16 10:00:51] goat at daholygoat dot com

@Johannes:

I don't really get your interpretion of the problem. A() is of course
the constructor (A() in A). The constructor returns an object of type A.
returnStr() is a method of A, so when calling returnStr() on a new A(),
it should invoke returnStr() on a new object of A. For example, in Java
it's fine to do this:

System.out.println(new Object().toString());

Which makes sense because when you _can_ do method chaining (which you
can in PHP5), there are many times where you just want to call one chain
on a new object, instead of seperately instantiating the class.

So I have to go with Derick pointing out it's simply not supported right
now.


[2005-09-14 23:25:33] johan...@php.net

By reading the code I'd expect that A is some function

returning an object. returnStr() being a method of that

object returning a class name used for new. (Somehow a

combination of new $a; and a simple   

function_call()-methodCallOnReturnedObject() which is   

possible since PHP 5) I would like some syntax like this,   

too - but thinking about it I see too much confusion and   

didn't find a nice solution which is clear when reading   

code.   

   

I set this to bogus since I think it's too much confusion,  

but if you have a nice and clear syntax feel free to  

re-open it - I'd be happy, but don't see how this is  

possible without logic conflicts :-)  


[2005-09-14 21:26:50] der...@php.net

I think this is simply not supported right now, so marking as a Feature
Request




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=34502


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


#33325 [NEW]: Type hinting and defaults of NULL

2005-06-13 Thread jacob at jacobweber dot com
From: jacob at jacobweber dot com
Operating system: All
PHP version:  5.0.4
PHP Bug Type: Class/Object related
Bug description:  Type hinting and defaults of NULL

Description:

When using type-hinting in a function's arguments, PHP should allow a
default value of NULL. Otherwise you have to manaully check the type with
instanceof. This would make it more convenient, and more consistent with
Java.

Reproduce code:
---
function f (MyClass $o = NULL) {
  echo success;
}

f();

Expected result:

success

Actual result:
--
PHP compiler error.

-- 
Edit bug report at http://bugs.php.net/?id=33325edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33325r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33325r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33325r=trysnapshot51
Fixed in CVS:http://bugs.php.net/fix.php?id=33325r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=33325r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=33325r=needtrace
Need Reproduce Script:   http://bugs.php.net/fix.php?id=33325r=needscript
Try newer version:   http://bugs.php.net/fix.php?id=33325r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33325r=support
Expected behavior:   http://bugs.php.net/fix.php?id=33325r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=33325r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=33325r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=33325r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33325r=php3
Daylight Savings:http://bugs.php.net/fix.php?id=33325r=dst
IIS Stability:   http://bugs.php.net/fix.php?id=33325r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33325r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33325r=float
No Zend Extensions:  http://bugs.php.net/fix.php?id=33325r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33325r=mysqlcfg


#33257 [NEW]: array_splice inconsistent when passed function

2005-06-06 Thread jacob at jacobweber dot com
From: jacob at jacobweber dot com
Operating system: Fedora Core 3
PHP version:  5.0.4
PHP Bug Type: Class/Object related
Bug description:  array_splice inconsistent when passed function

Description:

array_splice expects an array reference for its first argument. But
sometimes you can pass it a function that doesn't return an array
reference, and it will work.

The function has to be a static method inside a class, and it has to
return a static variable of that class. In this case, array_splice will
actually update the class's variable, which it shouldn't be able to do.

Even stranger, this behavior won't happen if you've assigned another
variable to the result of that function.

In the example below, you only get the error message when you uncomment
line 8. As far as I can tell, that should have no effect.

Reproduce code:
---
?
class X {
  protected static $arr = array(a, b, c);
  public static function getArr() {
return self::$arr;
  }
}
#$arr1 = X::getArr();
array_splice(X::getArr(), 1, 1);
print_r(X::getArr());
?

Expected result:

Fatal error: Only variables can be passed by reference in test.php on line
9

Actual result:
--
Array
(
[0] = a
[1] = c
)

-- 
Edit bug report at http://bugs.php.net/?id=33257edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33257r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33257r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33257r=trysnapshot51
Fixed in CVS:http://bugs.php.net/fix.php?id=33257r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=33257r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=33257r=needtrace
Need Reproduce Script:   http://bugs.php.net/fix.php?id=33257r=needscript
Try newer version:   http://bugs.php.net/fix.php?id=33257r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33257r=support
Expected behavior:   http://bugs.php.net/fix.php?id=33257r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=33257r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=33257r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=33257r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33257r=php3
Daylight Savings:http://bugs.php.net/fix.php?id=33257r=dst
IIS Stability:   http://bugs.php.net/fix.php?id=33257r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33257r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33257r=float
No Zend Extensions:  http://bugs.php.net/fix.php?id=33257r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33257r=mysqlcfg


#33240 [NEW]: XML_OPTION_SKIP_WHITE skips important spaces

2005-06-03 Thread jacob at jacobweber dot com
From: jacob at jacobweber dot com
Operating system: Fedora Core 3
PHP version:  5.0.4
PHP Bug Type: XML related
Bug description:  XML_OPTION_SKIP_WHITE skips important spaces

Description:

Turning on XML_OPTION_SKIP_WHITE causes the space in the following XML to
be skipped:
aapos; amp;/a

I believe this is incorrect. It doesn't skip the space in:
aamp; apos;/a

Jacob

Reproduce code:
---
$xmlStr = aapos; amp;/a;
$xmlParser = xml_parser_create();
xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($xmlParser, $xmlStr, $xmlArr);
xml_parser_free($xmlParser);
print_r($xmlArr);

Expected result:

Array
(
[0] = Array
(
[tag] = A
[type] = complete
[level] = 1
[value] = ' 
)

)

Actual result:
--
Array
(
[0] = Array
(
[tag] = A
[type] = complete
[level] = 1
[value] = '
)

)

(note the missing space after the apostrophe

-- 
Edit bug report at http://bugs.php.net/?id=33240edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33240r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33240r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33240r=trysnapshot51
Fixed in CVS:http://bugs.php.net/fix.php?id=33240r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=33240r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=33240r=needtrace
Need Reproduce Script:   http://bugs.php.net/fix.php?id=33240r=needscript
Try newer version:   http://bugs.php.net/fix.php?id=33240r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33240r=support
Expected behavior:   http://bugs.php.net/fix.php?id=33240r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=33240r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=33240r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=33240r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33240r=php3
Daylight Savings:http://bugs.php.net/fix.php?id=33240r=dst
IIS Stability:   http://bugs.php.net/fix.php?id=33240r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33240r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33240r=float
No Zend Extensions:  http://bugs.php.net/fix.php?id=33240r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33240r=mysqlcfg