Req #52583 [Opn]: Improved casting and hinting, new magic method __cast()

2010-08-11 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52583edit=1

 ID: 52583
 Updated by: degeb...@php.net
 Reported by:martin dot leucht at gmail dot com
 Summary:Improved casting and hinting, new magic method
 __cast()
 Status: Open
 Type:   Feature/Change Request
 Package:Class/Object related
 Operating System:   Irrelevant
 PHP Version:Irrelevant
 Block user comment: N

 New Comment:

See: http://wiki.php.net/rfc/class_casting_to_scalar


Previous Comments:

[2010-08-11 16:30:02] martin dot leucht at gmail dot com

Description:

Type casting in PHP is currently limited to the builtin types. It would
be very useful (IMO) if one could cast a value/variable to a class. And
also type hinting could be improved by casting instead of type checking
only.



I suggest to solve this by introducing a new magic method for classes,
called __cast(), that accepts the value to cast as parameter.



I see two possible solutions for its functionality:



(1) __cast() replaces the constructor method

This will force the developer to move logics from the constructor into a
separate function/method (which isn't even so bad) or to copy his code
(which is indeed bad). If the function returns with the boolean value
false, the default error mechanism is started saying something like
cast to XYZ not allowed.



(2) __cast() acts like a static constructor

The code must return the casted result itself. That means one would
implement some logics to transform the given value to the needed
constructor parameters and create a new instance on his own. To handle
an unsupported value the method would throw an exception or an error.
The negative (or let's say curious) thing about this solution is, that
this cast method could also return a value of a totally different type
(see example).

Test script:
---
// see patch file

Expected result:

// working cast

Actual result:
--
// parse errors






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


Bug #52580 [Opn-Bgs]: I like see string test

2010-08-10 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52580edit=1

 ID: 52580
 Updated by: degeb...@php.net
 Reported by:dijincorp at mail dot ru
 Summary:I like see string test
-Status: Open
+Status: Bogus
 Type:   Bug
 Package:Unknown/Other Function
 Operating System:   Windows,Linux
 PHP Version:5.2.14
 Block user comment: N

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:

[2010-08-10 22:57:09] dijincorp at mail dot ru

Description:

I like see string test



$variable = test;

$var_1 = variable;

echo ${$var_1}; //work



$var_2['x2'] = test;

$var_2['x'] = var_2;

echo ${$var_2['x']}['x2']; //work



$var_3['x2'] = test;

$var_3['x'] = var_3['x2'];

echo ${$var_3['x']}; //dont work



Sorry for my English.

Test script:
---
$var_3['x2'] = test;

$var_3['x'] = var_3['x2'];

echo ${$var_3['x']};

Expected result:

Notice: Undefined variable: var_3['x2']

Actual result:
--
string test






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


Bug #52495 [Opn-Bgs]: -d not parsed when invoked via shebang

2010-07-30 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52495edit=1

 ID: 52495
 Updated by: degeb...@php.net
 Reported by:php-bugs at thequod dot de
 Summary:-d not parsed when invoked via shebang
-Status: Open
+Status: Bogus
 Type:   Bug
 Package:PHP options/info functions
 Operating System:   Linux
 PHP Version:5.3.3
 Block user comment: N

 New Comment:

.


Previous Comments:

[2010-07-30 09:45:59] php-bugs at thequod dot de

Sorry, this is apparently a limitation of the shebang handling, where no
argument splitting is performed.



Therefore, this bug is invalid.



But please get bug 52496 fixed, so this does not fail silently.


[2010-07-30 08:47:48] php-bugs at thequod dot de

Well, it's actually worse than that: -d cannot be used in a shebang
line altogether.



This fails also:

#!/usr/bin/php -n -d date.timezone=Europe/Lisbon



Workaround:

# cat /usr/local/bin/php-noini

/usr/bin/php -n -d Europe/Lisbon $@


[2010-07-30 08:30:33] php-bugs at thequod dot de

Description:

The behavior of PHP when used via shebang line in a script is different
from using it directly:



# cat  ~/test.php

#!/usr/bin/php -n -ddate.timezone=Europe/Lisbon

?php

exit(42);



# chmod +x ~/test.php



# ~/test.php ; echo $?

Usage: php [options] [-f] file [--] [args...]

[...]

  -d foo[=bar] Define INI entry foo with value 'bar'

[...]

0



However, when used directly from the command line, the space after -d
appears to be optional:



# php -n -ddate.timezone=Europe/Lisbon -r 'echo date(H:i);'

07:15

# php -n -d date.timezone=Europe/Lisbon -r 'echo date(H:i);'

07:15





Please make the invocation via shebang behave the same in this regard
(accept -dfoo=bar)







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


Bug #52480 [Fbk-Opn]: Incorrect difference using DateInterval

2010-07-29 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52480edit=1

 ID: 52480
 Updated by: degeb...@php.net
 Reported by:alex dot joyce at staff dot comcen dot com dot au
 Summary:Incorrect difference using DateInterval
-Status: Feedback
+Status: Open
 Type:   Bug
 Package:Date/time related
 Operating System:   Debian 5.0.3
 PHP Version:5.3.3
 Block user comment: N

 New Comment:

With the timezone set to Europe/Copenhagen, I get the same results as
submitter. When set to UTC, I get the same results on Rasmus. This is on
Ubuntu 10.04.



dan...@daniel-laptop:~$ php -v

PHP 5.3.4-dev (cli) (built: Jul 29 2010 09:30:24) 

Copyright (c) 1997-2010 The PHP Group

Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


Previous Comments:

[2010-07-29 09:15:41] ras...@php.net

I don't see why I can't reproduce it then.  Try adding a call to 

date_default_timezone_set() to the top of your script and work in UTC to


eliminate local timezone issues.  



  date_default_timezone_set('UTC');

  $date_start = new DateTime('2010-03-01');

  $date_end   = new DateTime('2010-07-29');

  $interval = $date_start-diff($date_end);

  print_r($interval);


[2010-07-29 08:52:20] alex dot joyce at staff dot comcen dot com dot au

28/29, it doesn't matter. I'm only interested in the months.



I've tried:



1) FreeBSD 6, PHP 5.3.2

2) Debian 4, PHP 5.3.2

3) Debian 6, PHP 5.3.2/PHP 5.3.3



I upgraded that last one to submit this bug report, same fault.



All compiled from source.


[2010-07-29 08:27:50] ras...@php.net

Don't you mean 4 months and 28 days in the expected results?  7-3=4,
29-1=28

And that is exactly what I get on my Debian box with PHP 5.3.3:





php$date_start = new DateTime('2010-03-01');

php$date_end   = new DateTime('2010-07-29');

php  

php$interval = $date_start-diff($date_end);

php  

phpprint_r($interval);

DateInterval Object

(

[y] = 0

[m] = 4

[d] = 28

[h] = 0

[i] = 0

[s] = 0

[invert] = 0

[days] = 150

)



Are you using 5.3.3 built from our sources or are you using a
Debian-packaged 

version?


[2010-07-29 04:49:26] alex dot joyce at staff dot comcen dot com dot au

Description:

Trying to calculate the month difference between two dates accurately.

Test script:
---
?php



  $date_start = new DateTime('2010-03-01');

  $date_end   = new DateTime('2010-07-29');



  $interval = $date_start-diff($date_end);



  print_r($interval);

Expected result:

DateInterval Object

(

[y] = 0

[m] = 4

[d] = 29

[h] = 0

[i] = 0

[s] = 0

[invert] = 0

[days] = 150

)

Actual result:
--
DateInterval Object

(

[y] = 0

[m] = 5

[d] = 0

[h] = 0

[i] = 0

[s] = 0

[invert] = 0

[days] = 150

)






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


Req #52488 [Opn-Bgs]: Date problem

2010-07-29 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52488edit=1

 ID: 52488
 Updated by: degeb...@php.net
 Reported by:pssubashps at gmail dot com
 Summary:Date problem
-Status: Open
+Status: Bogus
 Type:   Feature/Change Request
 Package:Date/time related
 PHP Version:5.3.3
 Block user comment: N

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

It overflows the range of integers on your system. Seeing as you're
using 5.3, you can use the DateTime class instead.


Previous Comments:

[2010-07-29 17:23:28] pssubashps at gmail dot com

Description:

Hai,

While i excuting the below script i got unexpected result.



?php

print date(d-m-Y, mktime(0, 0, 0, 7, 1, 2038));

?



i got the output is 01-01-1970.

i know the problem in php core.

php date funnction changelog:

The valid range of a timestamp is typically from Fri, 13 Dec 1901
20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that
correspond to the minimum and maximum values for a 32-bit signed
integer). However, before PHP 5.1.0 this range was limited from
01-01-1970 to 19-01-2038 on some systems (e.g. Windows).



how we resolve this problem.









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


Bug #52489 [Opn-Bgs]: PDOStatement::execute() errors when querying for backslash and question mark

2010-07-29 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52489edit=1

 ID: 52489
 Updated by: degeb...@php.net
 Reported by:untold69 at hotmail dot com
 Summary:PDOStatement::execute() errors when querying for
 backslash and question mark
-Status: Open
+Status: Bogus
 Type:   Bug
 Package:PDO related
 Operating System:   Windows 7
 PHP Version:5.2.14
 Block user comment: N

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Question marks are parameter placeholders.


Previous Comments:

[2010-07-29 17:48:29] untold69 at hotmail dot com

Description:

Using PDO to prepare and then execute a statement that queries for a
backslash and 

then a question mark sequentially in two columns generates a warning.

Test script:
---
$pdo = new PDO(mssql:dbname=mydb;host=myhost, myuser,
mypassword);

$stmt = $pdo-prepare(SELECT * FROM table WHERE column1 = '\' AND
column2 = '?');

$result = $stmt-execute();

Expected result:

Array or false.

Actual result:
--
Warning: PDOStatement::execute() [pdostatement.execute]:
SQLSTATE[HY093]: Invalid 

parameter number: no parameters were bound in ...






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


Bug #52466 [Opn]: PHP cannot see filenames with spaces

2010-07-28 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52466edit=1

 ID: 52466
 Updated by: degeb...@php.net
 Reported by:d dot reade at ReadesGroupServices dot com
 Summary:PHP cannot see filenames with spaces
 Status: Open
 Type:   Bug
 Package:Filesystem function related
 Operating System:   CentOS 5.5
 PHP Version:5.3.3
 Block user comment: N

 New Comment:

Works fine for me using latest SVN 5.3 build:



dan...@daniel-laptop:~/tmp$ ls -l

total 24

-rw-r--r-- 1 daniel daniel 0 2010-07-28 10:30 foo bar.txt

-rw-r--r-- 1 daniel daniel 0 2010-07-28 10:30 helloworld.txt

dan...@daniel-laptop:~/tmp$ php -r 'var_dump(scandir(.));'

array(4) {

  [0]=

  string(1) .

  [1]=

  string(2) ..

  [2]=

  string(11) foo bar.txt

  [3]=

  string(14) helloworld.txt

}


Previous Comments:

[2010-07-28 10:27:35] d dot reade at ReadesGroupServices dot com

Description:

Using the scandir() method to fetch a list of filenames in a folder.
Some filenames contain a space (via SSH this appears as \ , i.e.
test\ file.txt). However PHP sees this file as test_file.txt. This
causes additional file operations such as file_exists() to return false.

Test script:
---
?php

\\ path/to/folder/ contents:

\\ file.txt

\\ test\ file.txt



$scan = scandir('path/to/folder/');



foreach ($scan as $file)

{

echo $file.'

';

}

?

Expected result:

file.txt

test\ file.txt

Actual result:
--
file.txt

test_file.txt






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


Bug #52469 [Opn-Fbk]: Datetime affect the division

2010-07-28 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52469edit=1

 ID: 52469
 Updated by: degeb...@php.net
 Reported by:info at mirgorod dot ru
 Summary:Datetime affect the division
-Status: Open
+Status: Feedback
 Type:   Bug
 Package:Date/time related
 PHP Version:Irrelevant
 Block user comment: N

 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Can't reproduce using 5.3-dev from SVN.


Previous Comments:

[2010-07-28 12:09:12] info at mirgorod dot ru

Sorry, this true description: Several launches of diff affects the
operation of division in php 5.3.2:


[2010-07-28 12:05:54] info at mirgorod dot ru

Description:

Several launches of 1911 affects the operation of division in php
5.3.2:



error_reporting(E_ALL); 



$now  = new Datetime();



for ($i = 0; $i  4; $i++) 

{ 

$a = $now-diff($now); 

} 



$t = 100/5.5; 



var_dump($t);



// first running: float(18.181818181818)

// after update page: Warning:  Division by zero in G:\www\test.php on
line 10

bool(false)

?









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


Bug #52471 [Opn-Bgs]: Folders being treated as files when scandir() is used

2010-07-28 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52471edit=1

 ID: 52471
 Updated by: degeb...@php.net
 Reported by:d dot reade at ReadesGroupServices dot com
 Summary:Folders being treated as files when scandir() is
 used
-Status: Open
+Status: Bogus
 Type:   Bug
 Package:Directory function related
 Operating System:   CentOS 5.5
 PHP Version:5.3.3
 Block user comment: N

 New Comment:

It just returns a string. The output should tell you why it's failing.
In Example 

1, neither of those exist in the current directory, and things that
don't exist 

are naturally not directories.


Previous Comments:

[2010-07-28 15:33:03] d dot reade at ReadesGroupServices dot com

Description:

Using scandir() to fetch a list of folders/files in a folder. When I use
foreach() and is_dir() to filter out folders from files, folders and
files are being grouped together, almost like PHP thinks the folders are
files. However if we use . as the argument in the scandir() method, we
get the desired results.



The below test script assumes you've created the following
folders/files:



folderName/

folderName/testFolder1/

folderName/testFolder2/

folderName/testFile1

folderName/testFile2



These results occur using both the CLI and via a PHP page in the
browser.

Test script:
---
?php

// Example 1

$scan = scandir(folderName);

foreach ($scan as $file)

{

if (is_dir($file))

{

echo Folder: .$file.\n;

}

else

{

echo File: .$file.\n;

}

}

?

?php

// Example 2

$scan = scandir(.);

foreach ($scan as $file)

{

if (is_dir($file))

{

echo Folder: .$file.\n;

}

else

{

echo File: .$file.\n;

}

}

?

Expected result:

Example 2 gives the expected result:



Folder: .

Folder: ..

File: testFile1

File: testFile2

Folder: testFolder1

Folder: testFolder2

Actual result:
--
Example 1 gives the actual result:



Folder: .

Folder: ..

File: testFile1

File: testFile2

File: testFolder1

File: testFolder2






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


Bug #52471 [Bgs]: Folders being treated as files when scandir() is used

2010-07-28 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52471edit=1

 ID: 52471
 Updated by: degeb...@php.net
 Reported by:d dot reade at ReadesGroupServices dot com
 Summary:Folders being treated as files when scandir() is
 used
 Status: Bogus
 Type:   Bug
 Package:Directory function related
 Operating System:   CentOS 5.5
 PHP Version:5.3.3
 Block user comment: N

 New Comment:

Yes, I did. The bug is in your code, not in scandir() nor is_dir().


Previous Comments:

[2010-07-28 16:07:23] d dot reade at ReadesGroupServices dot com

Did you try the test script?


[2010-07-28 16:03:09] degeb...@php.net

It just returns a string. The output should tell you why it's failing.
In Example 

1, neither of those exist in the current directory, and things that
don't exist 

are naturally not directories.


[2010-07-28 15:33:03] d dot reade at ReadesGroupServices dot com

Description:

Using scandir() to fetch a list of folders/files in a folder. When I use
foreach() and is_dir() to filter out folders from files, folders and
files are being grouped together, almost like PHP thinks the folders are
files. However if we use . as the argument in the scandir() method, we
get the desired results.



The below test script assumes you've created the following
folders/files:



folderName/

folderName/testFolder1/

folderName/testFolder2/

folderName/testFile1

folderName/testFile2



These results occur using both the CLI and via a PHP page in the
browser.

Test script:
---
?php

// Example 1

$scan = scandir(folderName);

foreach ($scan as $file)

{

if (is_dir($file))

{

echo Folder: .$file.\n;

}

else

{

echo File: .$file.\n;

}

}

?

?php

// Example 2

$scan = scandir(.);

foreach ($scan as $file)

{

if (is_dir($file))

{

echo Folder: .$file.\n;

}

else

{

echo File: .$file.\n;

}

}

?

Expected result:

Example 2 gives the expected result:



Folder: .

Folder: ..

File: testFile1

File: testFile2

Folder: testFolder1

Folder: testFolder2

Actual result:
--
Example 1 gives the actual result:



Folder: .

Folder: ..

File: testFile1

File: testFile2

File: testFolder1

File: testFolder2






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


Bug #52471 [Bgs]: Folders being treated as files when scandir() is used

2010-07-28 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52471edit=1

 ID: 52471
 Updated by: degeb...@php.net
 Reported by:d dot reade at ReadesGroupServices dot com
 Summary:Folders being treated as files when scandir() is
 used
 Status: Bogus
 Type:   Bug
 Package:Directory function related
 Operating System:   CentOS 5.5
 PHP Version:5.3.3
 Block user comment: N

 New Comment:

You are *never* checking if something is a file. You are only checking
if it's a 

directory. You are making the conclusion that if something is not a
directory, 

then it must be a file. This conclusion is *incorrect*. For instance,
there is 

the possibility that it doesn't even exist, which is the case here.


Previous Comments:

[2010-07-28 16:14:22] d dot reade at ReadesGroupServices dot com

I don't understand how it's my code?



If you run the first example from the CWD, where folderName is located
along with the test files/folders under folderName, the results are
that the test folders are actually files. The second example should be
run from within the folderName folder, and this returns the correct
results.



The code in both examples is the same, the only difference is the
folders we're scanning.


[2010-07-28 16:09:20] degeb...@php.net

Yes, I did. The bug is in your code, not in scandir() nor is_dir().


[2010-07-28 16:07:23] d dot reade at ReadesGroupServices dot com

Did you try the test script?


[2010-07-28 16:03:09] degeb...@php.net

It just returns a string. The output should tell you why it's failing.
In Example 

1, neither of those exist in the current directory, and things that
don't exist 

are naturally not directories.


[2010-07-28 15:33:03] d dot reade at ReadesGroupServices dot com

Description:

Using scandir() to fetch a list of folders/files in a folder. When I use
foreach() and is_dir() to filter out folders from files, folders and
files are being grouped together, almost like PHP thinks the folders are
files. However if we use . as the argument in the scandir() method, we
get the desired results.



The below test script assumes you've created the following
folders/files:



folderName/

folderName/testFolder1/

folderName/testFolder2/

folderName/testFile1

folderName/testFile2



These results occur using both the CLI and via a PHP page in the
browser.

Test script:
---
?php

// Example 1

$scan = scandir(folderName);

foreach ($scan as $file)

{

if (is_dir($file))

{

echo Folder: .$file.\n;

}

else

{

echo File: .$file.\n;

}

}

?

?php

// Example 2

$scan = scandir(.);

foreach ($scan as $file)

{

if (is_dir($file))

{

echo Folder: .$file.\n;

}

else

{

echo File: .$file.\n;

}

}

?

Expected result:

Example 2 gives the expected result:



Folder: .

Folder: ..

File: testFile1

File: testFile2

Folder: testFolder1

Folder: testFolder2

Actual result:
--
Example 1 gives the actual result:



Folder: .

Folder: ..

File: testFile1

File: testFile2

File: testFolder1

File: testFolder2






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


Bug #52428 [Bgs]: $this isn't immutable

2010-07-26 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52428edit=1

 ID: 52428
 Updated by: degeb...@php.net
 Reported by:tyra3l at gmail dot com
 Summary:$this isn't immutable
 Status: Bogus
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   all
 PHP Version:5.3.3
 Block user comment: N

 New Comment:

@dagdamor10: This has nothing to do with exploits at all. It poses no
security risk being able to modify the $this variable by circumventing
the simple check that is implemented.


Previous Comments:

[2010-07-26 10:51:25] tyra3l at gmail dot com

what about abolishing everything related to safe_mode

safe_mode has been DEPRECATED as of PHP 5.3.0. and will be removed with
the next 

major php version.



Tyrael


[2010-07-26 10:32:24] dagdamor10 at mail dot ru

 If you want you can shoot yourself in your head.



Okay, that was plain rude.



PHP *should* protect websites from possible exploits, what about
abolishing everything related to safe_mode, allowed paths and such? To
make a good site, people need good programming language... and good
programming language should be accurate in range-checking,
resource-protecting etc, instead of leaving all that to every programmer
who decide to use it.


[2010-07-25 18:50:52] tyra3l at gmail dot com

Thanks for the clarification.



Did I something wrong in the report, or you just copypasted the Thank
you for 

taking the time to write to us... part of your comment?



Maybe it would be a good thing to add this conclusion to the
documentation 

(reassigning this isn't allowed, because ..., if you try it, it will
give you an 

error Cannot re-assign this... [if you really need this, you can
do...])



Tyrael


[2010-07-25 18:39:17] johan...@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

We prevent from mistakes, we don't prevent people from hurting them
purposely. If you want you can shoot yourself in your head.


[2010-07-24 11:36:17] tyra3l at gmail dot com

Description:

As some closed bug-reports and the PHP Fatal error:  Cannot re-assign
$this 

states, the $this should be read-only/inmutable  in PHP5.

but with some tricks(variable variables mostly), you can walk-around
this 

constraint.

See the Test script.

I don't know the importance of this restriction, and with reflection you
can shoot 

you in the leg anyway, so maybe this can be left as is.

Test script:
---
?php



error_reporting(E_ALL);



$var = new StdClass();

$var-foo = 'bar';



//$this = $var; // PHP Fatal error:  Cannot re-assign $this



$GLOBALS['this'] = $var;



var_dump($this);



$var-foo = 'baz';



$foo = 'this';

$$foo = $var;



var_dump($this);



foo($this);



function foo($this){

  //global $this; // PHP Fatal error:  Cannot re-assign $this

  // $this = $GLOBALS['var']; // PHP Fatal error:  Cannot re-assign
$this

  var_dump($this);

  $GLOBALS['this']-foo = 'baw';

  $$GLOBALS['foo'] = $GLOBALS['this'];

  var_dump($this);

}



Expected result:

PHP Fatal error:  Cannot re-assign $this

for every attempt to overwrite $this

Actual result:
--
you can set $this in the global scope through $GLOBALS, with argument in


functions, and with variable variables in everywhere.






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


Bug #52433 [Bgs-Ver]: Call to undefined method mysqli::poll()

2010-07-26 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52433edit=1

 ID: 52433
 Updated by: degeb...@php.net
 Reported by:admin at webdesignforall dot net
 Summary:Call to undefined method mysqli::poll()
-Status: Bogus
+Status: Verified
 Type:   Bug
 Package:MySQLi related
 Operating System:   Debian 5
 PHP Version:5.3.3
 Block user comment: N

 New Comment:

I can reproduce this using the latest revision in the 5.3 branch.



Procedural mode works, but OO mode gives a fatal error.


Previous Comments:

[2010-07-26 04:11:56] admin at webdesignforall dot net

It is compiled with mysqlnd here is the configure line.





Configure Command =  './configure'  '--prefix=/custom/php-5.3.3'
'--with-

mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd'





Like I said mysqli_poll works fine just mysqli::poll doesn't, so there's


something wrong with the mysqli class.


[2010-07-25 18:34:58] johan...@php.net

MySQLi asynchronous queries only exist if PHP was compiled using mysqlnd
(--with-mysqli=myslqnd)


[2010-07-25 02:32:43] admin at webdesignforall dot net

Description:

The static method mysqli::poll doesn't exist. Using it creates a Fatal
error: Call 

to undefined method mysqli::poll() .



mysqli_poll works fine.

Test script:
---
?php

$link1 = new mysqli(localhost,root,,dba);

$link1-query(SELECT 'test', MYSQLI_ASYNC);

$done=false;

do

{

  $links = $errors = $reject = array();

  $links[] = $errors[] = $reject[] = $link1;

  if (!mysqli::poll($links, $errors, $reject, 1)) {

continue;

}

if ($result = $links[0]-reap_async_query()) {

$done=true;

}

}

while(!$done);



Expected result:

No output.

Actual result:
--
Fatal error: Call to undefined method mysqli::poll() 






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


Bug #52367 [Fbk]: file() return nothing for a file over than 10000 lines

2010-07-18 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52367edit=1

 ID:   52367
 Updated by:   degeb...@php.net
 Reported by:  menz12x at gmail dot com
 Summary:  file() return nothing for a file over than 1 lines
 Status:   Feedback
 Type: Bug
 Package:  Performance problem
 Operating System: windows xp
 PHP Version:  5.2.13

 New Comment:

Is it possible that you hit the memory_limit and that you've turned
display_errors off so you get a blank page?


Previous Comments:

[2010-07-17 21:00:45] ras...@php.net

You will need to provide some more info here.  Works perfectly on Linux
on files 

10x that.  eg.





11:58am new:~ wc test.txt

  13   33 26033650 test.txt

11:58am new:~ php -a 

Interactive shell



php  error_reporting(-1);

php  $a = file('./test.txt');

php  echo count($a);

13

php  echo $a[];

[9997] = 

99989998999899989998999899989998999899989998999899989998999899989998999899989998

99989998999899989998999899989998999899989998999899989998999899989998999899989998

9998999899989998999899989998999899989998


[2010-07-17 20:21:47] menz12x at gmail dot com

Description:

?php

 if (is_file($Fichier)) {

if ($TabFich = file($Fichier))

{

 $numTotal=count($TabFich);

 echo count($TabFich);

}



?

Test script:
---
file() function return FALSE for a file over than 1 lines

Expected result:

i'd like to see the number of lines the file() function returns

Actual result:
--
the file () function returns nothing






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


Bug #52235 [Csd-Bgs]: can't use implode() as inline attribute in empty()

2010-07-02 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52235edit=1

 ID:   52235
 Updated by:   degeb...@php.net
 Reported by:  valcool at pisem dot net
 Summary:  can't use implode() as inline attribute in empty()
-Status:   Closed
+Status:   Bogus
 Type: Bug
 Package:  Unknown/Other Function
 Operating System: windows 7 x64
 PHP Version:  5.3.2



Previous Comments:

[2010-07-02 14:12:31] valcool at pisem dot net

documented, my fault


[2010-07-02 14:01:07] valcool at pisem dot net

Description:

using return value of implode() as empty() param causes Fatal error:
Can't use function return value in write context

empty(implode($arr))

Test script:
---
?php

$foo = array('b','a','r');

if (empty(implode('', $foo)

{

echo 'ok';

}

else

{

echo 'not ok';

}

? 

Expected result:

'ok' or 'not ok' string, not fatal error :)

Actual result:
--
Fatal error: Can't use function return value in write context






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


Bug #52223 [Opn-Bgs]: switch case shows unexpected behaviour in particular case

2010-07-01 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52223edit=1

 ID:   52223
 Updated by:   degeb...@php.net
 Reported by:  webmaster at cephario dot com
 Summary:  switch case shows unexpected behaviour in particular
   case
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  Unknown/Other Function
 Operating System: Win32Server2003SE
 PHP Version:  5.3.2

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

0 == 'N', so the case passes.


Previous Comments:

[2010-07-01 16:01:54] webmaster at cephario dot com

Description:

if the given value is a numeric 0 (AND YES APPLIES ONLY FOR THE 0
negative or positive int values are working as expected) the first
string expression (case) is matched.



Test script:
---
pre?php

$data = 0;

echo $data.\n\n;

switch ($data) {

case 1:

$data = 'UNA';

break;

case 'N':

$data = 'NOW()';

break;

case 'NOWB()':

$data = 'NOWB()';

break;

default:

$data = 'DATANEW';

}

echo $data;



?/pre

Expected result:

DATANEW

Actual result:
--
NOW()






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


Bug #52171 [Opn-Bgs]: session_start() problem

2010-06-24 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52171edit=1

 ID:   52171
 Updated by:   degeb...@php.net
 Reported by:  senthil dot klnit at gmail dot com
 Summary:  session_start() problem
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  *General Issues
 Operating System: windows 7
 PHP Version:  5.3.2

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:

[2010-06-24 13:30:59] senthil dot klnit at gmail dot com

Description:

i run the php code in local host. it works fine. But when i put into the
server it shows the following warning message.

Test script:
---
?php



ob_start();

session_start();







?

Expected result:

it should be show

Actual result:
--
Warning: session_start() [function.session-start]: Cannot send session
cache limiter - headers already sent (output started at
/home/cubroso1/public_html/test/car_wash/tutorial.php:1) in
/home/cubroso1/public_html/test/car_wash/includes/common.php on line 4






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


Req #42029 [Opn-Dup]: MBSTRING: missing strpad() implementation

2010-06-23 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=42029edit=1

 ID:   42029
 Updated by:   degeb...@php.net
 Reported by:  fabrizio dot balliano at crealabs dot it
 Summary:  MBSTRING: missing strpad() implementation
-Status:   Open
+Status:   Duplicate
 Type: Feature/Change Request
-Package:  Feature/Change Request
+Package:  *General Issues
 Operating System: all
 PHP Version:  5.2.3



Previous Comments:

[2010-06-23 09:47:12] PhoneixSegovia at gmail dot com

This bug is a duplicated of #21317


[2007-07-18 12:32:28] fabrizio dot balliano at crealabs dot it

Description:

mbstring module is missing the str_pad function, thus if you pad some
text cointaining a 2 byte char, the result string length will be wrong.







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


Bug #52123 [Bgs]: strtotim() returns date for one year ago

2010-06-19 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52123edit=1

 ID:   52123
 Updated by:   degeb...@php.net
 Reported by:  alipendashteh at gmail dot com
 Summary:  strtotim() returns date for one year ago
 Status:   Bogus
 Type: Bug
 Package:  Date/time related
 Operating System: Windows
 PHP Version:  5.3.2

 New Comment:

You already have DateTime::createFromFormat() if you wish to parse other
formats.


Previous Comments:

[2010-06-19 12:59:36] alipendashteh at gmail dot com

you right; this is not a bug.

but i think the Y, F j is much more common than Hi, F j.

and many application like Drupal use Y, F j as a default date format.
so parsing date as Hi, F j rather than Y, F j would cause confiusing
errors in applications.

I suggest replace the priorities of two format mentioned.


[2010-06-19 11:41:47] der...@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

This is not a bug. 2011 is seen as time instead:



php -r 'var_dump(date_parse(2011, February 8));'

array(12) {

  [year]=

  bool(false)

  [month]=

  int(2)

  [day]=

  int(8)

  [hour]=

  int(20)

  [minute]=

  int(11)

  [second]=

  int(0)

  [fraction]=

  bool(false)

  [warning_count]=

  int(0)

  [warnings]=

  array(0) {

  }

  [error_count]=

  int(0)

  [errors]=

  array(0) {

  }

  [is_localtime]=

  bool(false)

}


[2010-06-19 11:22:14] alipendashteh at gmail dot com

Description:

Hi,

strtotime returns wrong date (one year ago) with some formats like:

2011, February 8



Test script:
---
echo (date('Y-m-d', strtotime(2011, February 8)));

Expected result:

2011-02-08

Actual result:
--
2010-02-08






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


Bug #52044 [Opn-Bgs]: Access protected method violation

2010-06-11 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52044edit=1

 ID:   52044
 Updated by:   degeb...@php.net
 Reported by:  public at proside dot fr
 Summary:  Access protected method violation
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  Class/Object related
 Operating System: WIN XP SP3+
 PHP Version:  5.3.2

 New Comment:

Yes, you are wrong. One MyParent object knows the private/protected
interface of all other MyParent objects, so it is allowed to access it.
Other classes don't, so they're not allowed.



Thanks for your interest though.


Previous Comments:

[2010-06-11 10:20:25] public at proside dot fr

Description:

In one case, the PHP engine allows access to the protected methods of an
instanciated class



As the documentation says : protected methods are only available inside
the class that declares it and inside the tree of derivated classes. If
you look at the code, we are in none of these case : $a is a standalone
instance of MyParent so the protected methods of class MyParent should
be hidden.



Am i wrong ?

Test script:
---
?php

class MyParent {

   protected function getProtectedParent() { return 'Parent_Protected';
}

}



class MyChild extends MyParent {

   function getPublicChild() {

  # -- new standalone instance of MyParent

  $a = new MyParent();

  # -- here it's possible to access to the protected method of $a
!

  return $a-getProtectedParent();

   }

}



$cls = new MyChild();

$test = $cls-getPublicChild();

Expected result:

Fatal error : access level violation

Actual result:
--
$test = 'Parent_Protected'






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


Bug #52044 [Bgs]: Access protected method violation

2010-06-11 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52044edit=1

 ID:   52044
 Updated by:   degeb...@php.net
 Reported by:  public at proside dot fr
 Summary:  Access protected method violation
 Status:   Bogus
 Type: Bug
 Package:  Class/Object related
 Operating System: WIN XP SP3+
 PHP Version:  5.3.2

 New Comment:

Hi,



Please see my answer here: http://news.php.net/php.doc.cvs/6808



$a is standalone, but it is MyParent instance used within another
MyParent instance. It's not leaking any information to other classes, so
it isn't violating any contracts.


Previous Comments:

[2010-06-11 11:12:22] public at proside dot fr

I almost do agree about your comment, but in my example, $a is a
standalone instance of the parent class. Where $a can be used doesn't
really matter, it's still a standalone instance of class like any
general instance of class. And in the general case the PHP engine
logically prevent the access to the protected methods. Here, it seems
that the context of execution of a standalone object impacts the
contract defined by the OOP rules !


[2010-06-11 10:28:44] degeb...@php.net

Yes, you are wrong. One MyParent object knows the private/protected
interface of all other MyParent objects, so it is allowed to access it.
Other classes don't, so they're not allowed.



Thanks for your interest though.


[2010-06-11 10:20:25] public at proside dot fr

Description:

In one case, the PHP engine allows access to the protected methods of an
instanciated class



As the documentation says : protected methods are only available inside
the class that declares it and inside the tree of derivated classes. If
you look at the code, we are in none of these case : $a is a standalone
instance of MyParent so the protected methods of class MyParent should
be hidden.



Am i wrong ?

Test script:
---
?php

class MyParent {

   protected function getProtectedParent() { return 'Parent_Protected';
}

}



class MyChild extends MyParent {

   function getPublicChild() {

  # -- new standalone instance of MyParent

  $a = new MyParent();

  # -- here it's possible to access to the protected method of $a
!

  return $a-getProtectedParent();

   }

}



$cls = new MyChild();

$test = $cls-getPublicChild();

Expected result:

Fatal error : access level violation

Actual result:
--
$test = 'Parent_Protected'






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


Bug #52039 [Opn-Fbk]: Closure problem with 5.3.2

2010-06-10 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52039edit=1

 ID:   52039
 Updated by:   degeb...@php.net
 Reported by:  neto dot joaobatista at gmail dot com
 Summary:  Closure problem with 5.3.2
-Status:   Open
+Status:   Feedback
 Type: Bug
 Package:  Scripting Engine problem
 Operating System: Linux, Fedora 13 64 bits
 PHP Version:  5.3.2

 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

I get the following output:



string(9) 5.3.3-dev

object(Closure)#1 (1) {

  [static]=

  array(1) {

[test]=

string(12) Closure test

  }

}


Previous Comments:

[2010-06-10 13:53:26] neto dot joaobatista at gmail dot com

Description:

NULL when using Closures with use keyword in PHP 5.3.2

Test script:
---
?php

$test = 'Closure test';

$closure = function() use ( $test ) { return $test; };



var_dump( phpversion() , $closure );

Expected result:

PHP 5.3.0 output:



string(5) 5.3.0

object(Closure)#1 (1) {

  [static]=

  array(1) {

[test]=

string(12) Closure test

  }

}

Actual result:
--
PHP 5.3.2 output:



string(5) 5.3.2

NULL






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


Bug #52031 [Opn-Bgs]: Passing 0 as a parameter through a custom method

2010-06-09 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52031edit=1

 ID:   52031
 Updated by:   degeb...@php.net
 Reported by:  d dot reade at ReadesGroupServices dot com
 Summary:  Passing 0 as a parameter through a custom method
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  Unknown/Other Function
 Operating System: CentOS 5.5
 PHP Version:  5.3.2

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

See: http://php.net/manual/en/language.types.type-juggling.php


Previous Comments:

[2010-06-09 14:41:32] d dot reade at ReadesGroupServices dot com

Description:

Sorry but I didn't know how to best word the summary.



I have a custom method with an if statement inside. If the parameter
passed through matches Test, a string is echo'ed. However if I pass
0 through as the parameter, PHP thinks this is Test and echoes the
string.



Passing a blank parameter through, i.e. , does not have the same
effect as 0.



Inserting if (empty($str)) before the if statement in the example
works as expected, catches the 0 parameter and I get the expected
result. However without this, I get the actual result.



All plugins have been disabled and Apache restarted.

Test script:
---
?php

function testMethod($str = 0)

{

if ($str == 'Test')

{

echo 'Test String!br';

}

}



testMethod('Test');



testMethod(0);

testMethod();

testMethod(1);

testMethod('Something');

?

Expected result:

Test String!

Actual result:
--
Test String!

Test String!

Test String!






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


Bug #52031 [Bgs]: Passing 0 as a parameter through a custom method

2010-06-09 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52031edit=1

 ID:   52031
 Updated by:   degeb...@php.net
 Reported by:  d dot reade at ReadesGroupServices dot com
 Summary:  Passing 0 as a parameter through a custom method
 Status:   Bogus
 Type: Bug
 Package:  Unknown/Other Function
 Operating System: CentOS 5.5
 PHP Version:  5.3.2

 New Comment:

You are comparing an integer with a string, so the string gets converted
to an int. Because (int)Test is (int)0 and 0==0, the condition
passes.



It's not a bug, and it's documented behavior. If you want it to check
the type as well, you need to use the === operator as documented.


Previous Comments:

[2010-06-09 14:57:52] d dot reade at ReadesGroupServices dot com

Sorry but that makes no sense. How is this not a bug?



If I pass 0 as the parameter and the first if statement is empty(),
PHP knows the paramater is empty and the if statement is triggered.
Whereas without empty() PHP executes the first statement regardless even
though the same value would trigger empty()!



It shouldn't do that - if the first if statement is ($str == 'Test'),
PHP should skip it just as it would with any other string that doesn't
match.


[2010-06-09 14:51:46] degeb...@php.net

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

See: http://php.net/manual/en/language.types.type-juggling.php


[2010-06-09 14:41:32] d dot reade at ReadesGroupServices dot com

Description:

Sorry but I didn't know how to best word the summary.



I have a custom method with an if statement inside. If the parameter
passed through matches Test, a string is echo'ed. However if I pass
0 through as the parameter, PHP thinks this is Test and echoes the
string.



Passing a blank parameter through, i.e. , does not have the same
effect as 0.



Inserting if (empty($str)) before the if statement in the example
works as expected, catches the 0 parameter and I get the expected
result. However without this, I get the actual result.



All plugins have been disabled and Apache restarted.

Test script:
---
?php

function testMethod($str = 0)

{

if ($str == 'Test')

{

echo 'Test String!br';

}

}



testMethod('Test');



testMethod(0);

testMethod();

testMethod(1);

testMethod('Something');

?

Expected result:

Test String!

Actual result:
--
Test String!

Test String!

Test String!






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


Bug #52020 [Opn-Bgs]: date function error

2010-06-08 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52020edit=1

 ID:  52020
 Updated by:  degeb...@php.net
 Reported by: 117712 at gmail dot com
 Summary: date function error
-Status:  Open
+Status:  Bogus
 Type:Bug
-Package: Website problem
+Package: Date/time related
 PHP Version: 5.2.13

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Valid formats are explained here:

http://php.net/datetime.formats


Previous Comments:

[2010-06-08 10:51:47] 117712 at gmail dot com

Description:

I think this will return 2010-04-31 but no show it for me!

Test script:
---
echo date('Y-m-d', strtotime(-1 month 2010-05-31));

Expected result:

echo date('Y-m-d', strtotime(-1 month 2010-05-31));

Actual result:
--
echo date('Y-m-d', strtotime(-1 month 2010-05-31));






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


Bug #52015 [Opn]: Ending date is ignored while iterating DatePeriod

2010-06-07 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52015edit=1

 ID:   52015
 Updated by:   degeb...@php.net
 Reported by:  ko dot fivestar at gmail dot com
 Summary:  Ending date is ignored while iterating DatePeriod
 Status:   Open
 Type: Bug
 Package:  Date/time related
 Operating System: Ubuntu 10.04
 PHP Version:  5.3.2

 New Comment:

Whether or not it's a bug is debatable. It could be considered a
half-open interval (which would then make it a documentation issue).



Changing it to a closed interval would break backwards compatibility. It
would probably be better adding one more option to DatePeriod that
allows the inclusion of the end date. The attached patch implements
that.


Previous Comments:

[2010-06-07 13:56:17] ko dot fivestar at gmail dot com

Description:

When passing DateTime objects to first and third argument of DatePeriod
constructor, the specified date on the third argument is not being
interated when both DateTime object contains same time value.



After looking through ext/date/php_date.c, date_period_it_has_more()
function (line 1831) had following code:



---

return object-start-sse  object-end-sse ? SUCCESS : FAILURE;

---



While the operator  is currently used to compare values, operator
= is more appropriate for this content.

Test script:
---
$period = new \DatePeriod(

new \DateTime('2010-06-01'),

new \DateInterval('P1D'),

new \DateTime('2010-06-03')

);



foreach ($period as $day) {

echo $day-format('Y-m-d') . \n;

}



Expected result:

2010-06-01

2010-06-02

2010-06-03

Actual result:
--
2010-06-01

2010-06-02






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


Bug #52016 [Opn-Bgs]: cast a float variable rounds the value

2010-06-07 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52016edit=1

 ID:   52016
 Updated by:   degeb...@php.net
 Reported by:  nbourdial at x-prime dot com
 Summary:  cast a float variable rounds the value
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  Scripting Engine problem
 Operating System: Linux 2.6.26-2-686
 PHP Version:  5.2.13

 New Comment:

Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.

If you would like to know more about floats and what IEEE
754 is, read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Thank you for your interest in PHP.




Previous Comments:

[2010-06-07 16:43:51] nbourdial at x-prime dot com

Description:

Hi,



when I cast a float variable to int, the final value is not correct for
some values.

Test script:
---
var_dump((int)(37.91*100));



Expected result:

int(3791)

Actual result:
--
int(3790)






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


Bug #52007 [Opn-Bgs]: Split function

2010-06-06 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=52007edit=1

 ID:   52007
 Updated by:   degeb...@php.net
 Reported by:  kannthenpalam at gmail dot com
 Summary:  Split function
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  *General Issues
 Operating System: windows
 PHP Version:  Irrelevant

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:

[2010-06-06 15:55:41] kannthenpalam at gmail dot com

Description:

Now i am using 5.3.0 version of php.When i am using the split function
it will show the error as follows

Deprecated: Function split() is deprecated 



the code like this



$custdate = '06-06-2010';

split(-,$custdate,3);

Test script:
---
$custdate = '06-06-2010';

split(-,$custdate,3);

Expected result:

i just want to know why this error is occor.







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


Bug #51998 [Opn-Bgs]: call_user_func_array can't use private methods on the $this pointer

2010-06-05 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51998edit=1

 ID:   51998
 Updated by:   degeb...@php.net
 Reported by:  php at paulisageek dot com
 Summary:  call_user_func_array can't use private methods on the
   $this pointer
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  *General Issues
 Operating System: All
 PHP Version:  5.2.13

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Of course you cannot call private instance methods outside of the
object. That's the entire point of private methods.


Previous Comments:

[2010-06-05 09:05:27] php at paulisageek dot com

Description:

I'd like to make a helper library that can use call_user_func outside of
the 

object context, but still use private methods (obviously only when
called from 

inside the object).



Example attached:

Test script:
---
?php



class A { 

  private function test1() {

print 'side effect 1';

return false;

  }

  private function test2() {

print 'side effect 2';

return 'yay';

  }

  private function test3() {

print 'side effect 3';

return 'nope';

  }

  public function first() {

return nonempty_lazy(

  array(array($this, 'test1')),

  array(array($this, 'test2')),

  array(array($this, 'test3')));

  }

}



function nonempty_lazy() {

  $args = func_get_args();

  foreach ($args as $arg) {

$cb = array_shift($arg);

$val = call_user_func_array($cb, $arg);

if (!empty($val))

  return $val;

  }

}



$a = new A;

print $a-first();



Expected result:

side effect 1side effect 2yay

Actual result:
--
Warning: call_user_func_array() expects parameter 1 to be a valid
callback, cannot 

access private method A::test1() in /Users/ptarjan/tmp/cufa.php on line
28



Warning: call_user_func_array() expects parameter 1 to be a valid
callback, cannot 

access private method A::test2() in /Users/ptarjan/tmp/cufa.php on line
28



Warning: call_user_func_array() expects parameter 1 to be a valid
callback, cannot 

access private method A::test3() in /Users/ptarjan/tmp/cufa.php on line
28








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


Bug #51592 [Tbd-Csd]: file_get_contents('php://input') - empty string if called more than once

2010-05-31 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51592edit=1

 ID:   51592
 Updated by:   degeb...@php.net
 Reported by:  theshop at inbox dot ru
 Summary:  file_get_contents('php://input') - empty string if
   called more than once
-Status:   To be documented
+Status:   Closed
 Type: Bug
 Package:  Streams related
 Operating System: any
 PHP Version:  5.3.2
-Assigned To:  
+Assigned To:  degeberg

 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.




Previous Comments:

[2010-05-31 16:37:41] degeb...@php.net

Automatic comment from SVN on behalf of degeberg
Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=23
Log: Fixed PHP bug #51592 (file_get_contents('php://input') - empty
string if called more than once)


[2010-05-31 15:12:18] m...@php.net

Reclassified.



php://input can only be read once.


[2010-05-14 14:12:23] theshop at inbox dot ru

Nope, I was wrong, does not work under CentOS with methods different
from GET or POST. So it is not OS specific after all.


[2010-05-14 13:55:50] theshop at inbox dot ru

Some more test results:



Windows 7 Pro x64, Apache 2.2.15, PHP 5.3.2 - not working.

CentOS (don't know exact version number), Apache 2.2.3, PHP 5.3.2 -
works correctly.



So this is probably Windows-only bug.


[2010-04-18 23:04:16] theshop at inbox dot ru

Description:

Second and consecutive calls of file_get_contents('php://input') return
empty string if client issued an HTTP command other than 'GET' or 'POST'
(see example code). If 'GET' or 'POST' HTTP command was issued
file_get_contents('php://input') works correctly.



Not sure if this is cURL related bug, maybe some other PHP package is
responsible.



I am using Apache 2.2 and IE8.

Test script:
---
#bug_curl.php

$hcurl = curl_init();

curl_setopt($hcurl, CURLOPT_URL, 'http://test/bug.php');

curl_setopt($hcurl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($hcurl, CURLOPT_HTTPHEADER, array('Content-Type:
text/plain'));

curl_setopt($hcurl, CURLOPT_POSTFIELDS, 'some request text');

curl_setopt($hcurl, CURLOPT_CUSTOMREQUEST, 'DELETE');

//curl_setopt($hcurl, CURLOPT_HTTPGET, true); - this works ok

//curl_setopt($hcurl, CURLOPT_POST, true); - this works ok

$out = curl_exec($hcurl);

curl_close($hcurl);

echo 'pre'.htmlspecialchars($out).'/pre';



# bug.php

var_dump(file_get_contents('php://input'));

var_dump(file_get_contents('php://input')); // returns empty string if
HTTP command is not 'GET' or POST'

var_dump(apache_request_headers());



Expected result:

string(17) some request text

string(17) some request text

array(4) {

  [Host]=

  string(4) test

  [Accept]=

  string(3) */*

  [Content-Type]=

  string(10) text/plain

  [Content-Length]=

  string(2) 17

}





Actual result:
--
string(17) some request text

string(0) 

array(4) {

  [Host]=

  string(4) test

  [Accept]=

  string(3) */*

  [Content-Type]=

  string(10) text/plain

  [Content-Length]=

  string(2) 17

}










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


Bug #51926 [Opn-Bgs]: Module mod_auth_kerb not work with libphp5 (5.3.2)

2010-05-27 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51926edit=1

 ID:   51926
 Updated by:   degeb...@php.net
 Reported by:  metaip at mail dot ru
 Summary:  Module mod_auth_kerb not work with libphp5 (5.3.2)
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  Apache2 related
 Operating System: Fedora 8
 PHP Version:  5.3.2

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:

[2010-05-27 09:47:41] metaip at mail dot ru

Description:

This question may be intended not for you, but nevertheless...



php(5.1.2) compiled as module for apache(2.2.11) with 

--with-mysql=/u02/mysql --with-apxs2=/usr/local/apache2/bin/apxs
--with-pgsql=/usr/local/pgsql --with-zlib --with-gd --with-freetype-dir
--with-ttf --with-jpeg-dir --with-png-dir --with-xpm-dir.

Mod_auth_kerb(http://modauthkerb.sourceforge.net) compiled as module for
apache too.

Mod_auth_kerb and libphp5(5.1.2) in combined work fine.



--

I have upgrade php to 5.3.2.

php(5.3.2) compiled for apache with 

--with-mysql=/u02/mysql --with-apxs2=/usr/local/apache2/bin/apxs
--with-pgsql=/usr/local/pgsql --with-zlib --with-gd --with-freetype-dir
--enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-xpm-dir
--with-readline --with-oci8 --with-mssql=/usr/local
--with-openssl-dir=/usr/local/ssl --with-bz2 --with-mcrypt
--enable-mbstring.

Use same mod_auth_kerb. 

Mod_auth_kerb and libphp5(5.3.2) in combined not work. In apache`s log
this error - 

gss_import_name() failed: Miscellaneous failure (, Can't open/find
Kerberos configuration file). 

In this case httpd try to use file /krb5/krb.conf (!?!?!?).

File /etc/krb5.conf exist and its correct.

Kerberos utils from command line work fine.



With php(5.1.2) httpd uses correct file /etc/krb5.conf. 

Now i must use php(5.1.2) but i need php(5.3.2). 



Please help. Thank you.







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


Bug #51921 [Opn-Bgs]: CURLOPT_USERPWD bogus when use without username

2010-05-26 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51921edit=1

 ID:   51921
 Updated by:   degeb...@php.net
 Reported by:  over at silversurfer7 dot de
 Summary:  CURLOPT_USERPWD bogus when use without username
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  cURL related
 Operating System: Debian 5.0 64bit
 PHP Version:  5.2.13

 New Comment:

That would be an issue with libcurl then. PHP's curl extension just
passes the options to libcurl.



See:
http://svn.php.net/viewvc/php/php-src/trunk/ext/curl/interface.c?view=markup#l1707


Previous Comments:

[2010-05-26 13:51:57] over at silversurfer7 dot de

Description:

When using CURLOPT_USERPWD within a cURL request u have to provide both
username AND password to work properly.



I had a problem with accessing pages with Basicauth and NO username,
just a Password.



curl then calculates the base64 wrong.



As workaround i have to calculate the base64 manually and provide it to
curl via the headers option

Test script:
---
$curl = curl_init('http://localhost');

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_USERPWD, ':password'); // no username

curl_setopt($curl, CURLOPT_VERBOSE, true);

$response = curl_exec($curl);

curl_close($curl);

Expected result:

something like this in the request headers:



Authorization: Basic OnRlc3Q=

Actual result:
--
Authorization: Basic Og==



(only the :)






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


Bug #51892 [Opn-Bgs]: preg_match_all forces the use of a $matches variable

2010-05-23 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51892edit=1

 ID:   51892
 Updated by:   degeb...@php.net
 Reported by:  hugo at ankarloo dot nu
 Summary:  preg_match_all forces the use of a $matches variable
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  *General Issues
 Operating System: Linux
 PHP Version:  5.2.13

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Use preg_match().



http://php.net/preg_match


Previous Comments:

[2010-05-23 17:42:34] hugo at ankarloo dot nu

Description:

If you use preg_match_all and are only interested in the return value
(i.e. you are not interested in the data stored in $matches) you are
still forced to declare a variable for $matches.



I'm not sure if this is a bug in preg_match_all or in php's
passed_by_reference.



My first thought was to pipe $matches to a php-equivalent of /dev/null,
but something like that doesn't exist to my knowledge.









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


Req #51797 [Opn-Fbk]: valid arguments for foreach

2010-05-11 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51797edit=1

 ID:  51797
 Updated by:  degeb...@php.net
 Reported by: rc at opelgt dot org
 Summary: valid arguments for foreach
-Status:  Open
+Status:  Feedback
 Type:Feature/Change Request
 Package: *General Issues
 PHP Version: 5.2.13

 New Comment:

The following script works fine for me:



?php

$array = array(

array('foo','bar'),

array('test','hello'),

);



$i = 0;

foreach ($array[$i] as $key = $val) {

echo $key . $val;

}

?



You'll have to provide a complete script that gives unexpected/incorrect


warnings.


Previous Comments:

[2010-05-11 18:25:31] rc at opelgt dot org

Description:

When I give an array to loop through the name of the array and if the
array given 

is with a key, in this case $i, should make no difference.



PHP4 didnt make a warning, PHP5 instead does.

Test script:
---
foreach($array[$i] as $key = $val) results in an warning message.











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


Bug #51747 [Opn-Bgs]: nothing

2010-05-05 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51747edit=1

 ID:   51747
 Updated by:   degeb...@php.net
 Reported by:  debasishbasak132 at gmail dot com
 Summary:  nothing
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  Output Control
 Operating System: windows
 PHP Version:  5.3.2

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:

[2010-05-05 15:18:48] debasishbasak132 at gmail dot com

Description:

?php

include 'mysql-connect.php';

$username = $_POST['username'];

$password = $_POST['password'];

$firstname = $_POST['firstname'];

$lastname = $_POST['lastname'];

$age = $_POST['age'];

$ip = $_SERVER['REMOTE_ADDR'];



$result = mysql_num_rows(mysql_query(SELECT * FROM te2 WHERE
username='$username'));

if($result == 1)

{

echo username already exist;

}

else

{

mysql_query(INSERT INTO te2 (username, password, firstname,
lastname, age, ip)

VALUES ('$username', '$password', '$firstname', '$lastname', '$age',
'$ip'));



echo u are successfully registered;

  

  pClick a href=login.phphere/a to login./p;}

?

Expected result:

?php

include 'mysql-connect.php';

$username = $_POST['username'];

$password = $_POST['password'];

$firstname = $_POST['firstname'];

$lastname = $_POST['lastname'];

$age = $_POST['age'];

$ip = $_SERVER['REMOTE_ADDR'];



$result = mysql_num_rows(mysql_query(SELECT * FROM te2 WHERE
username='$username'));

if($result == 1)

{

echo username already exist;

}

else

{

mysql_query(INSERT INTO te2 (username, password, firstname,
lastname, age, ip)

VALUES ('$username', '$password', '$firstname', '$lastname', '$age',
'$ip'));



echo u are successfully registered;

  

  pClick a href=login.phphere/a to login./p;}

?

Actual result:
--
in my code insert into values code dont work .pls help me






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


Bug #51686 [Opn-Bgs]: Problem with global scoping

2010-04-28 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51686edit=1

 ID:   51686
 Updated by:   degeb...@php.net
 Reported by:  quaspam at yahoo dot com
 Summary:  Problem with global scoping
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  Scripting Engine problem
 Operating System: Windows
 PHP Version:  5.3.2

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:

[2010-04-28 20:17:47] quaspam at yahoo dot com

Description:

I had trouble running the following using php 5.3.2: 

?php

 $username = 'dummy value';

 function fetchUsername(){

   global $username;

  //Imitate retrieval

  $username ='Sample Value';

}



fetchUsername();

echo $username;



?



The above printed the dummy value (dummy value). Am i missing something?
Pliz help



Test script:
---
?php

 $username = 'dummy value';

 function fetchUsername(){

   global $username;

  //Imitate retrieval

  $username ='Sample Value';

}



fetchUsername();

echo $username; //Prints 'dummy value'



?









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


Bug #51657 [Opn-Bgs]: switch() construction works wrong with empty arrays

2010-04-27 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51657edit=1

 ID:  51657
 Updated by:  degeb...@php.net
 Reported by: 1234ru at gmail dot com
 Summary: switch() construction works wrong with empty arrays
-Status:  Open
+Status:  Bogus
 Type:Bug
 Package: Scripting Engine problem
 PHP Version: 5.2.13

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

While perhaps not immediately clear, this is correct behavior.



An empty array evaluates to false and in your snippet, isset($a['a'])
evaluates to false. In other words, $a == isset($a['a']), and so the
first case in your switch will be used.


Previous Comments:

[2010-04-25 00:11:41] 1234ru at gmail dot com

Description:

When building switch() structure using arrays, if array is empty, first
case always fires (while it should not)



(version 5.2.12)

Test script:
---
$a = array();

switch($a) {

case (isset($a['a']) ): echo 'If $a is empty, you should not see it';
break;

default: echo 'Hello.'; break;

}







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


Bug #51672 [Opn-Bgs]: Parse error when a subscript operator is used after a function call operator

2010-04-27 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51672edit=1

 ID:   51672
 Updated by:   degeb...@php.net
 Reported by:  miklcct at gmail dot com
 Summary:  Parse error when a subscript operator is used after a
   function call operator
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  Compile Failure
 Operating System: Ubuntu 9.04
 PHP Version:  5.3.2

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:

[2010-04-27 12:11:21] miklcct at gmail dot com

Description:

syntax error when a subscript operator is used with a function call
operator

Test script:
---
#!/usr/bin/php



?php

function test() {

return foo;

}



echo test()[0];



Expected result:

f



Actual result:
--
Parse error: syntax error, unexpected '[', expecting ',' or ';' in
/home/www/bus/test.php on line 8








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


Bug #51632 [Opn-Fbk]: filter_var fails to validate correct URL

2010-04-22 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51632edit=1

 ID:   51632
 Updated by:   degeb...@php.net
 Reported by:  zharkikh at i dot com dot ua
 Summary:  filter_var fails to validate correct URL
-Status:   Open
+Status:   Feedback
 Type: Bug
 Package:  Unknown/Other Function
 Operating System: FreeBSD
 PHP Version:  5.3.2

 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

PHP 5.3.2 was released on March 4, and the #51305 was fixed on March 3.
It probably didn't make it into the release. It works for me on
5.3.3-dev built a few days ago.


Previous Comments:

[2010-04-22 11:52:00] zharkikh at i dot com dot ua

Description:

Function filter_var seems to change it behavior when PHP upgraded from
5.2.4 to 5.3.2.

The next example work fine in 5.24 but fail in 5.3.2.

This problem was described in Bug #51305 (filter_var fails if domain
name contain -) and reported to be fixed in 5.2.13, but it is bubble
again in 5.3.2 :

Test script:
---
?php

$P = 'http://m-zharkikh.livejournal.com/26556.html';

echo filter_var($P, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED);



Expected result:

http://m-zharkikh.livejournal.com/26556.html, so URL is valid

Actual result:
--
false, so URL provided evaluated as invalid






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


Bug #51604 [Opn]: newline in end of header is shown in start of message

2010-04-21 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51604edit=1

 ID:   51604
 Updated by:   degeb...@php.net
 Reported by:  pavol at klacansky dot com
 Summary:  newline in end of header is shown in start of message
 Status:   Open
 Type: Bug
 Package:  Mail related
 Operating System: Ubuntu
 PHP Version:  5.3.2

 New Comment:

The attached patch will fix this issue. I don't have php-src karma, so I
can't commit it myself.


Previous Comments:

[2010-04-21 16:00:42] degeb...@php.net

The following patch has been added/updated:

Patch Name: php_bug51604.diff
Revision:   1271858442
URL:   
http://bugs.php.net/patch-display.php?bug=51604patch=php_bug51604.diffrevision=1271858442


[2010-04-19 20:50:47] pavol at klacansky dot com

Actual result:

--

\nHallo


[2010-04-19 20:49:55] pavol at klacansky dot com

Description:

if I have a newline (\n) at the end of last header, it will show to
start of message of mail

Test script:
---
?php

$email = 'u...@ufo.net';

$headers = 'From: ' . $email . \n;

$headers .= 'Cc: ' . $email . \n;

$headers .= 'X-Mailer: PHP/' . phpversion() . \n;

$headers .= 'Content-Type: text/plain; charset=utf-8' . \n;

$headers .= 'Content-Transfer-Encoding: 8bit' . \n;

mail('t...@test.tt', 'test', 'Hallo', $headers);

?

Expected result:

Hallo

Actual result:
--
Hallo






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


Doc #51585 [Opn-Csd]: wrong description for is_prefix in SimpleXMLElement::children

2010-04-17 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51585edit=1

 ID:   51585
 Updated by:   degeb...@php.net
 Reported by:  himajin10 at gmail dot com
 Summary:  wrong description for is_prefix in
   SimpleXMLElement::children
-Status:   Open
+Status:   Closed
 Type: Documentation Problem
 Package:  SimpleXML related
 Operating System: Irrelevant
 PHP Version:  Irrelevant
-Assigned To:  
+Assigned To:  degeberg

 New Comment:

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:

[2010-04-17 23:13:22] degeb...@php.net

Automatic comment from SVN on behalf of degeberg
Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=298133
Log: Fixed PHP bug #51585 (wrong description for is_prefix in
SimpleXMLElement::children)


[2010-04-17 23:03:29] himajin10 at gmail dot com

Description:

see

http://jp.php.net/manual/en/simplexmlelement.children.php

Test script:
---
?php

$a = ab:c xmlns:b='http://www.example.com/'xyz/b:c/a;

$xml = simplexml_load_string($a);



print_r(1: . (string)($xml-children(b,false)-c). \n);



print_r(2: . (string)($xml-children(b,true)-c) . \n);





?



this correctly outputs:

1: 2:xyz 



Expected result:

Description of is_prefix should be as follows:



If is_prefix is TRUE, ns will be regarded as a prefix. If FALSE, ns will
be regarded as a namespace URL.

Actual result:
--
Description of is_prefix is as follows:



If is_prefix is TRUE, ns will be regarded as a namespace URL. If FALSE,
ns will be regarded as a prefix.






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


Req #51554 [Opn-Wfx]: Identifies if a call is static ou 'objective'

2010-04-14 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51554edit=1

 ID:  51554
 Updated by:  degeb...@php.net
 Reported by: david71rj at gmail dot com
 Summary: Identifies if a call is static ou 'objective'
-Status:  Open
+Status:  Wont fix
 Type:Feature/Change Request
 Package: Class/Object related
 PHP Version: Irrelevant

 New Comment:

You shouldn't interchange static and non-static methods. If you need to
call a method statically, mark it as static. Your code below will give
an E_STRICT error.


Previous Comments:

[2010-04-14 03:07:55] david71rj at gmail dot com

Description:

If a call a method as static, how I can test if is a static call or
objective?



Well, I think about is_static_call(), example:



class A {

  public function test(){

if(is_static_call()){

  echo 'Static method';

}

else {

  echo 'Objective method';

}

  }

}



A::test(); // Static method

$a = new A;

$a-test(); // Objective method



Currently I use a 'workarround' for this problem:



if($this  get_class($this) === get_class()){

  // Objective method

}



This is my sugestion.

Bye.







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


Bug #51547 [Opn-Bgs]: Type casting from int to int after log changes value

2010-04-13 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51547edit=1

 ID:  51547
 Updated by:  degeb...@php.net
 Reported by: acollins at liv dot ac dot uk
 Summary: Type casting from int to int after log changes value
-Status:  Open
+Status:  Bogus
 Type:Bug
 Package: *Math Functions
 PHP Version: 5.2.13

 New Comment:

Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.

If you would like to know more about floats and what IEEE
754 is, read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Thank you for your interest in PHP.

Try having a look at this:

echo serialize(log(1000, 10));



When you cast to int you just truncate the fractional part.


Previous Comments:

[2010-04-13 11:04:47] acollins at liv dot ac dot uk

Note: I assume this is because log() returns a floating point value.
I.e. it's a precision issue?


[2010-04-13 11:03:32] acollins at liv dot ac dot uk

Description:

When performing a log(), and immediately type casting afterwards, the
value changes.

Test script:
---
?php

$val = 1000;

echo log($val, 10) .' == '. (int) log($val, 10);

?

Expected result:

3 == 3

Actual result:
--
3 == 2






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


Bug #51548 [Opn-Bgs]: setting the php_auth_user using login form

2010-04-13 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51548edit=1

 ID:   51548
 Updated by:   degeb...@php.net
 Reported by:  ram at wiredhat dot com
 Summary:  setting the php_auth_user using login form
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  PHP options/info functions
 Operating System: windows xpsp2
 PHP Version:  5.2.13

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:

[2010-04-13 12:27:42] ram at wiredhat dot com

Description:

for auth-login, i don't like to have pop-up box to enter the
username/password. i like to enter the username/password in login-form. 


Test script:
---
?

$username = usa;

$password = newyork;



if(($_POST['PHP_AUTH_USER'] == $username) ($_POST['PHP_AUTH_PW'] ==
$password))

  { 



 echo apache_setenv(PHP_AUTH_USER,$_POST['PHP_AUTH_USER']);

 echo apache_setenv(PHP_AUTH_PW,$_POST['PHP_AUTH_PW']);   

echo putenv(PHP_AUTH_USER =$_POST['PHP_AUTH_USER']);

echo putenv(PHP_AUTH_PW = $_POST['PHP_AUTH_PW']);



  }  

?



form method=post

pUsername : input type=textbox name=PHP_AUTH_USER
id=PHP_AUTH_USER /br /

pPassword : input type=password name=PHP_AUTH_PW id=PHP_AUTH_PW
/br /

p input type=submit name=submit /

/form

Expected result:

by using the phpinfo(), we need to see the _SERVER['PHP_AUTH_USER'] =
usa. 

Actual result:
--
by using the phpinfo(), '_SERVER['PHP_AUTH_USER'] ' is totally missed.. 







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


Bug #51550 [Opn-Csd]: 'Open php' tag at end of file causes 'syntax error, unexpected $end'

2010-04-13 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51550edit=1

 ID:   51550
 Updated by:   degeb...@php.net
 Reported by:  daan at react dot com
 Summary:  'Open php' tag at end of file causes 'syntax error,
   unexpected $end'
-Status:   Open
+Status:   Closed
 Type: Bug
-Package:  Documentation problem
+Package:  Scripting Engine problem
 Operating System: Debian Etch
 PHP Version:  5.2.13
-Assigned To:  
+Assigned To:  degeberg

 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.




Previous Comments:

[2010-04-13 16:23:31] degeb...@php.net

Automatic comment from SVN on behalf of degeberg
Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=297962
Log: Fixed PHP bug #51550 ('Open php' tag at end of file causes 'syntax
error, unexpected ')


[2010-04-13 16:10:08] johan...@php.net

This is fixed in 5.3 with a new parser. This won't be fixed in 5.2.
Maybe the doc team wants to add it to the documentation.


[2010-04-13 15:40:13] daan at react dot com

Description:

This probably is a known effect, but I will just open a bug so it can be
documented as such:



When you end a file with a PHP open tag '?php', and there is no
character beyond the tag the parser chokes with an 'unexpected $end'
parse error.



Curiously, a short tag '?' (if enabled) used in such a way raises no
error.



This effect is of course also seen when you eval a string containing an
PHP open tag at the end of the string. (from there I originally stumbled
on this behaviour)



In PHP 5.3 the code behaves as expected, so someone probably already
spotted this one, or fixed the parser to be less nitty.

Test script:
---
?php

Expected result:

Nothin

Actual result:
--
Parse error: syntax error, unexpected $end in test.php on line 1






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


Bug #51542 [Opn-Bgs]: Overriding method type hint with child interface raises strict standards

2010-04-13 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51542edit=1

 ID:   51542
 Updated by:   degeb...@php.net
 Reported by:  mike at mikegerwitz dot com
 Summary:  Overriding method type hint with child interface
   raises strict standards
-Status:   Open
+Status:   Bogus
 Type: Bug
 Package:  Scripting Engine problem
 Operating System: GNU/Linux
 PHP Version:  5.3.2

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

When someone receives an instance of a One object, the method signature
of foo() tells them that it needs an IOne instance. In Two you further
restrict that to an ITwo. Seeing as a Two instance is a One instance, a
Two instance will be accepted by people who want a One instance. They
cannot know that the parameter requirements have been changed and that
is why you get an E_STRICT.



Also, this is not just for interfaces, but for classes as well.


Previous Comments:

[2010-04-12 15:43:13] mike at mikegerwitz dot com

Description:

When using an interface for type hinting, PHP raises a strict standards
warning 

if an overriding method uses an interface that implements the type hint.
In the 

example below, ITwo implements IOne and method One::foo expects the
first 

argument to implement IOne. Two extends One and expects the first
argument to 

implement ITwo, which implements IOne. This should be allowed, much like
it is 

allowed if the interfaces were simply classes.

Test script:
---
interface IOne {}



interface ITwo extends IOne {}





class One

{

public function foo( IOne $bla ) {}

}



class Two extends One

{

public function foo( ITwo $bla ) {}

}





class Test implements ITwo {}



// yet, this does work

var_dump( new Test instanceof IOne );

Expected result:

bool(true)

Actual result:
--
PHP Strict Standards:  Declaration of Two::foo() should be compatible
with that 

of One::foo() in test.php on line 25



Strict Standards: Declaration of Two::foo() should be compatible with
that of 

One::foo() in test.php on line 25

bool(true)






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


Doc #51553 [Opn-Bgs]: bug in simplexmlelement count example

2010-04-13 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51553edit=1

 ID:  51553
 Updated by:  degeb...@php.net
 Reported by: sarahnorthway at gmail dot com
 Summary: bug in simplexmlelement count example
-Status:  Open
+Status:  Bogus
 Type:Documentation Problem
 Package: SimpleXML related
 PHP Version: Irrelevant

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

That's not necessary. Did you actually run the code? :)



When you iterate over a SimpleXML element, it's its children you'll get.
What else should it be?



dan...@daniel-laptop:~$ php -v; php test.php

PHP 5.3.3-dev (cli) (built: Mar 29 2010 15:35:44) 

Copyright (c) 1997-2010 The PHP Group

Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans

Person 1 has got 3 children.

Person 2 has got 5 children.


Previous Comments:

[2010-04-14 00:37:51] sarahnorthway at gmail dot com

Description:

In the examples for simplexmlelement-count at
http://www.php.net/manual/en/simplexmlelement.count.php, the line:



foreach ($elem as $person) {



should be:



foreach ($elem-children() as $person) {







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


Doc #51502 [Opn-Fbk]: imagecreatefromjpeg no image

2010-04-08 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51502edit=1

 ID:  51502
 Updated by:  degeb...@php.net
 Reported by: minirop at hotmail dot com
 Summary: imagecreatefromjpeg no image
-Status:  Open
+Status:  Feedback
 Type:Documentation Problem
 Package: Unknown/Other Function
 PHP Version: Irrelevant

 New Comment:

Where did you find that link? What page and on what mirror? It works
fine for me on the fr2 mirror.


Previous Comments:

[2010-04-07 22:40:29] minirop at hotmail dot com

Description:

the image that show the example doesn't exist : 

http://fr2.php.net/manual/fr/images/21009b70229598c6a80eef8b45bf282b-

image.imagecreatefromjpeg.jpg 







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


Doc #51355 [Opn-Wfx]: suggestion for documentation of session_set_save_handler

2010-03-23 Thread degeberg
Edit report at http://bugs.php.net/bug.php?id=51355edit=1

 ID:   51355
 Updated by:   degeb...@php.net
 Reported by:  zweibieren at yahoo dot com
 Summary:  suggestion for documentation of
   session_set_save_handler
-Status:   Open
+Status:   Wont fix
 Type: Documentation Problem
 Package:  Session related
 Operating System: unix
 PHP Version:  Irrelevant

 New Comment:

That article is too outdated to be referenced in the PHP manual. Many
things in that article are now deprecated.


Previous Comments:

[2010-03-23 02:11:00] zweibieren at yahoo dot com

Description:

Page http://www.php.net/manual/en/function.session-set-save-handler.php

really ought to have a reference to the excellent document at

http://devzone.zend.com/article/1312



It seems to too important to relegate to a small item in that page's
already long list of comments.



Here is a proposed replacement for the See Also section on page Page
http://www.php.net/manual/en/function.session-set-save-handler.php:



 div class=refsect1 seealso

  h3 class=titleSee Also/h3

  p class=para

   ul class=simplelist

li class=member



 The a href=session.configuration.php#ini.session.save-handler
class=linksession.save_handler/a

 configuration directive

/li

li class=member

 Zend offers an excellent tutorial on a
href=http://devzone.zend.com/article/1312; class=linkSession
Handling with PHP 4/a. (It applies to later versions as well.)

/li

   /ul

  /p

 /div









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


#51081 [Opn]: date(g:ia,strtotime(24:00)) returns 1:00am

2010-02-18 Thread degeberg
 ID:   51081
 Updated by:   degeb...@php.net
 Reported By:  mike dot turpin at gmail dot com
 Status:   Open
-Bug Type: Documentation problem
+Bug Type: Date/time related
 Operating System: Windows Vista
 PHP Version:  5.2.12
 New Comment:

Seems to be a bug in the 5.2 branch. Reclassifying.


dan...@daniel-laptop:~$ php -r 'echo
phpversion().PHP_EOL.date(g:ia,strtotime(24:00)).PHP_EOL;'
5.3.1
12:00am

dan...@daniel-laptop:~$ ~/src/php-5.2.12/sapi/cli/php -r 'echo
phpversion().PHP_EOL.date(g:ia,strtotime(24:00)).PHP_EOL;'
5.2.12
1:00am



Previous Comments:


[2010-02-18 13:47:03] mike dot turpin at gmail dot com

Description:

I suspect that this is a documentation problem in strtotime rather than
a bug, but I think it should be pointed out in the doc as it's easy to
fall into the trap.

strtotime(24:00) returns false

If you then have:

  date(g:ia,strtotime(24:00))

You will get 1:00am but might be expecting 12:00am








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



#51050 [Bgs]: FILTER_VALIDATE_URL accepts invalid URLs

2010-02-15 Thread degeberg
 ID:   51050
 Updated by:   degeb...@php.net
 Reported By:  pecoes at gmail dot com
 Status:   Bogus
 Bug Type: Filter related
 Operating System: WinXP
 PHP Version:  5.3.1
 New Comment:

It is hardly within the scope of the manual to cover all possible
attack vectors. http://php.net/security.variables already states a
number of things you should always consider when dealing with user
submitted data.

Whether or not something is safe is entirely circumstantial and
highly dependent on how trustworthy the user is. It's not the manual's
job to figure that out, but your job as a programmer.


Previous Comments:


[2010-02-15 07:58:17] pecoes at gmail dot com

Yes. You're perfectly right. Forget that last suggestion. But I still
think, it would be helpful to clearly state in the documentation, that
valid != safe.



[2010-02-15 07:52:06] ras...@php.net

But that wouldn't make it safe and as such would be worse than the 
current state because people would think it was.  It takes more than 
just filtering out or encoding certain characters to make a user-
supplied URL safe for direct display.  Generally you need to apply some

application-level logic to determine which domains and which primitives

are valid.  For example: javascript:alert(1) is a perfectly valid URL 
that has no special characters in it.  Or file:/// can also cause 
problems.  Even http://localhost/ can cause issues.  There is a long 
list of things that can be problematic if you allow users to supply 
entire URLs.  Usually all you want to accept from users are url 
fragments and you prepend the primitive and base domain and path.



[2010-02-15 07:39:45] pecoes at gmail dot com

Personally, I don't like sanitizing. I prefer to either accept or
reject. I don't think modifying a user's input is a good idea.

How about adding an optional FILTER_FLAG_ALLOW_SPECIAL_CHARS to
FILTER_VALIDATE_URL?

Or an optional FILTER_FLAG_DISALLOW_SPECIAL_CHARS, if that's what you
prefer...

Because, you know, using URLs in an HTML context is not such an exotic
scenario. :0)



[2010-02-15 07:26:07] ras...@php.net

What you are after is a filter for the html-context.  There is nothing

wrong with your URL.  You only have an issue with it if you use it in 
an HTML context.  It is your target context you should be filtering 
for.  The URL sanitizer is very explicitly documented as:

Remove all characters except letters, digits and $-
_.+!*'(),{}|\\^~[]`#%;/?:@=.

Have a look through:

http://php.net/manual/en/filter.filters.sanitize.php

What you are looking for is FILTER_SANITIZE_SPECIAL_CHARS




[2010-02-15 07:20:03] pecoes at gmail dot com

Okay, I accept that the URL I posted, is valid. But it deserves
pointing out that valid does NOT mean safe.

Btw FILTER_SANITIZE_URL has the same effect on this URL.



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/51050

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



#50822 [Bgs]: Private instance variable visibile for new instance created within an object

2010-01-22 Thread degeberg
 ID:   50822
 Updated by:   degeb...@php.net
 Reported By:  aron at zajlik dot hu
 Status:   Bogus
 Bug Type: Scripting Engine problem
 Operating System: Mac OS X
 PHP Version:  5.3.1
 New Comment:

The reason why you make methods and properties private in an object is
to encapsulate things and to hide implementation specific details from
the outside world, so to speak. However, it is expected that an instance
of Test knows how Test works internally and therefore you are able to
access private properties of other instances of Test.

Test knows how Test works and Test knows there is a property called
$variable in Test. It's pointless hiding the implementation of Test from
Test.

You'll find that similar behavior is possible in other object oriented
languages (Java for instance).


Previous Comments:


[2010-01-22 15:16:49] aron at zajlik dot hu

Although my example (by chance) is similar to a singleton pattern, my 
goal was actually very different. But regardless, there is no reason 
why the object $my_test should be able to directly access a private 
variable of $tobj. Even if it were a singleton class this would not be

necessary. 

To say my point in a different way:
- In a typical singleton pattern, the instantiated object is a private

property of the singleton class, so there is no problem accessing that

from the class. In fact, you are able to access public properties and 
methods of the instantiated object from within the singleton class.
- BUT there is no reason why you should be able to access a private 
property of that instance! Only the instance itself should have access

to that...

Hope I made myself clear...

peace,
aron



[2010-01-22 14:38:05] j...@php.net

Ever heard of singleton ? Also: 

  http://php.net/manual/en/language.oop5.patterns.php

So yes, this is expected and correct behaviour.



[2010-01-22 12:45:36] aron at zajlik dot hu

Description:

I found a situation which to me seems like unexpected behavior. I 
private variable (as far as I know) should only be accessible within
the 
object itself, and not by the outside world. Yet this becomes a bit 
confusing once the object is created within an instance of itself. Is 
this a bug or is this expected behavior?

Reproduce code:
---
?
class Test{
private $variable = asdf;

static function create_a_test(){
$tobj = new Test();
echo $tobj-variable;   // Works! (which it shouldn't?!?)
}

}

$my_test = new Test();
//echo $my_test-variable;  // Returns Fatal error: Cannot access
private property (which it should!)
$my_test-create_a_test();

?

Expected result:

I would expect the above code NOT to return the private variable on
line 
7.

Actual result:
--
The private variable can be accessed without a problem.





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



#50809 [Opn]: empty(), isset() not helpful - need better alternative

2010-01-20 Thread degeberg
 ID:   50809
 Updated by:   degeb...@php.net
 Reported By:  seanr at webolutionary dot com
 Status:   Open
 Bug Type: Feature/Change Request
 Operating System: all
 PHP Version:  5.3.2RC1
 New Comment:

Anything that when cast to boolean is false is regarded as empty.

Seeing as false==0 and 0==0 then false==0 because equivalence is
transitive. So if false is empty, then 0 is empty because false==0.

If you want to check that a string's length is non-zero you can use
strlen().


Previous Comments:


[2010-01-20 20:15:02] seanr at webolutionary dot com

Description:

If the value is a string of 0, than it's not a true zero right?  The

behavior of empty() in this case is utterly absurd.  If you can't fix 
empty, there needs to be a new function to provide a better way to 
test on this than writing our own special functions to work around a 
PHP bug.

$a = 0;
$b = '';
$b = '0'

empty($a) returns true (correctly, but not helpfully)
empty($b) returns true (correctly)
empty($a) returns true (incorrectly, since it actually does have a 
value)

Of course, isset() returns true for all three (correctly, but not 
helpfully).  This means there's no way to find out that $a and $c have

values I can use and $b doesn't without writing my own special 
function or if statement.  EXTREMELY frustrating.






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



#50729 [Bgs]: Error Control Operator (@) Does Not Work With Custom Error Handler

2010-01-12 Thread degeberg
 ID:   50729
 Updated by:   degeb...@php.net
 Reported By:  keithdavis at solidtechservice dot com
 Status:   Bogus
 Bug Type: Scripting Engine problem
 Operating System: Windows 7 64 Bit
 PHP Version:  5.3.1
 New Comment:

On my setup using PHP 5.3.1, this code:

?php
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
var_dump(error_reporting());
}

set_error_handler('myErrorHandler', E_ALL);

var_dump(error_reporting());
@include 'does-not-exist.php';
var_dump(error_reporting());
?

Produces the following output:
int(32767)
int(0)
int(0)
int(32767)

It is your own responsibility to check the error handling level inside
your custom error handler.


Previous Comments:


[2010-01-12 15:17:50] keithdavis at solidtechservice dot com

The manual states

Of particular note is that this value will be 0 if the statement that
caused the error was prepended by the @ error-control operator. 

This is NOT happening.



[2010-01-12 15:15:27] keithdavis at solidtechservice dot com

But it's NOT setting the error reporting to 0. It is a bug, see this
reply to a bug done in 2002.

http://bugs.php.net/bug.php?id=16570edit=2

When I use the @, it is supposed to pass an error level of 0, but it
does not do this. It still sets it to 1024 and does NOT set my reporting
level to 0.



[2010-01-12 15:12:49] col...@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

@ temporarily sets error_reporting to 0, it doesn't prevent your
handler 
to be called. You've to do the filtering in it based on error_reporting

if you want to.



[2010-01-12 15:07:12] keithdavis at solidtechservice dot com

Description:

The @ is supposed to set error level to 0 (at least, I think that is
what it supposed to do), but that does not work with a custom error
handler. I can reproduce this every time.

Reproduce code:
---
Set error handler:

set_error_handler('ErrorHandler');

Code to generate error:

$this-_bind = @ldap_bind($this-_conn,
$this-_ad_username.$this-_account_suffix, $this-_ad_password);

Error Handler Test:

function ErrorHandler($iErrorNum, $sErrorMsg, $sErrorFile,
$iErrorLineNum){

 echo $iErrorNum;

}

Expected result:

No error message and an $iErroNum of 0.

Actual result:
--
error message:

WARNING [2] ldap_bind(): Unable to bind to server: Can't contact LDAP
server, Line: 140 in file
C:\inetpub\Intranet_Local\library\classes\adLDAP.php

$iErrorNum = 1024





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



#50721 [Opn-Fbk]: get_browser doesn't with with null for user agen

2010-01-11 Thread degeberg
 ID:   50721
 Updated by:   degeb...@php.net
 Reported By:  xellisx at gmail dot com
-Status:   Open
+Status:   Feedback
 Bug Type: *General Issues
 Operating System: Linux
 PHP Version:  5.3.1
 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

PHP 5.3.1 was released at 2009-11-14. Bug #50267 was fixed at
2009-11-24. There has not been a stable release of the 5.3.x branch
since.


Previous Comments:


[2010-01-11 17:15:18] xellisx at gmail dot com

Description:

This is the same as  #50267 but for linux.






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



#50726 [Opn]: Resume after Exceptions

2010-01-11 Thread degeberg
 ID:   50726
 Updated by:   degeb...@php.net
 Reported By:  kenaniah at gmail dot com
 Status:   Open
 Bug Type: Feature/Change Request
 Operating System: Linux
 PHP Version:  5.3.1
 New Comment:

An exception is by definition a state where the program no longer knows
how to proceed. It's basically a way of saying I give up, you'll have
to handle this yourself. You have this ability using a try-catch block.
Exceptions shouldn't be used to control the application flow, but should
be used for genuinely exceptional situations.

In my opinion, if a try-catch block doesn't satisfy your needs, you are
more than likely misusing exceptions.


Previous Comments:


[2010-01-11 23:53:02] kenaniah at gmail dot com

Description:

I think that PHP would benefit greatly by implementing a feature known
as resumeable exceptions. The end goal would be to provide a method by
which code execution may be continued from the point at which an
exception was thrown. 

Naturally, some exceptions should not be resumeable by nature, which
would require an extension to the Exception class of a simple boolean
property indicating whether an instance of that exception can be resumed
or not. 

The only real problem AFAICS with resumeable exceptions has to do with
the state of the execution stack. Obviously, if execution were to be
resumed after an exception is handled, the stack can not be unwound
automatically (Schrodinger's cat, anyone?). 

My suggestion would be to allow another keyword besides catch (such
as resume) to handle exceptions. If a resumeable exception is thrown
and caught in a resume block, the parser should proceed as if it were
handling a function call. In short, the unwinding of the execution stack
would need to be deferred until it is determined whether or not
execution will be resumed at the point of the exception.






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



#50538 [Opn]: php_date.c compliation fails

2009-12-20 Thread degeberg
 ID:   50538
 Updated by:   degeb...@php.net
 Reported By:  david at davidfavor dot com
 Status:   Open
-Bug Type: Doc Build problem
+Bug Type: Compile Failure
 Operating System: Ubuntu 9.10
 PHP Version:  5.3.1
 New Comment:

Hi David,

This is a problem with building PHP, not with building the
documentation. I've reclassified the bug report for you so it will get
to the right people.

Personally, I have built PHP 5.3.1 from source on my Ubuntu 9.10
install, so it's probably your setup that is missing something. See
http://www.php.net/support.php for support options.

- Daniel


Previous Comments:


[2009-12-20 15:28:50] david at davidfavor dot com

Description:

The same problem appears with all stable versions of php
(5.2.12, 5.3.0, 5.3.1) and Ubuntu Karmic with gcc-4.4.1
where php_date.c compilation fails.

Reproduce code:
---

r...@hive1:# ./configure
r...@hive1:# make
/bin/sh /home/dfavor/work/php-5.3.1/libtool --silent
--preserve-dup-deps --mode=compile gcc
-Iext/date/lib -Iext/date/ -I/home/dfavor/work/php-5.3.1/ext/date/
-DPHP_ATOM_INC
-I/home/dfavor/work/php-5.3.1/include
-I/home/dfavor/work/php-5.3.1/main
-I/home/dfavor/work/php-5.3.1
-I/home/dfavor/work/php-5.3.1/ext/date/lib
-I/home/dfavor/work/php-5.3.1/ext/ereg/regex -I/usr/include/libxml2
-I/home/dfavor/work/php-5.3.1/ext/sqlite3/libsqlite
-I/home/dfavor/work/php-5.3.1/TSRM
-I/home/dfavor/work/php-5.3.1/Zend -I/usr/include -g -O2
-fvisibility=hidden -c
/home/dfavor/work/php-5.3.1/ext/date/php_date.c -o
ext/date/php_date.lo
In file included from /usr/include/stdlib.h:33,
from /home/dfavor/work/php-5.3.1/include/../main/php_config.h:2845,
from /home/dfavor/work/php-5.3.1/Zend/zend_config.h:1,
from /home/dfavor/work/php-5.3.1/Zend/zend.h:51,
from /home/dfavor/work/php-5.3.1/main/php.h:34,
from /home/dfavor/work/php-5.3.1/ext/date/php_date.c:21:
/usr/lib/gcc/i486-linux-gnu/4.4.1/include/stddef.h:211: error:
duplicate 'unsigned'
In file included from /usr/include/stdlib.h:320,
from /home/dfavor/work/php-5.3.1/include/../main/php_config.h:2845,
from /home/dfavor/work/php-5.3.1/Zend/zend_config.h:1,
from /home/dfavor/work/php-5.3.1/Zend/zend.h:51,
from /home/dfavor/work/php-5.3.1/main/php.h:34,
from /home/dfavor/work/php-5.3.1/ext/date/php_date.c:21:
/usr/include/sys/types.h:151: error: duplicate 'unsigned'
/usr/include/sys/types.h:153: error: duplicate 'unsigned'
/usr/include/sys/types.h:153: error: two or more data types in
declaration specifiers
make: *** [ext/date/php_date.lo] Error 1

r...@hive1:# uname -a
Linux hive1.coolsurf.com 2.6.31-10-generic #35-Ubuntu SMP Tue Sep 22
17:33:42 UTC 2009 i686 GNU/Linux

r...@hive1:# gcc --version
gcc (Ubuntu 4.4.1-4ubuntu8) 4.4.1

r...@hive1:# libtool --version
ltmain.sh (GNU libtool) 2.2.6

There are many ways of hacking this to work and I'd prefer someone in
the know tell
me the correct way to fix this.

Thanks.






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