#39553 [NEW]: Add coalesce() and coalesce_strict() functions

2006-11-19 Thread greg at mtechsolutions dot ca
From: greg at mtechsolutions dot ca
Operating system: all
PHP version:  5.2.0
PHP Bug Type: Feature/Change Request
Bug description:  Add coalesce() and coalesce_strict() functions

Description:

I see value in adding two functions to php: coalesce() and
coalesce_strict(). 

Both of these would take an arbitrary number of arguments, and use the
first non-empty() or non-null value (respectively).

For example:

$username = coalesce($_POST['username'], $_COOKIE['username'], 'guest');

Parameters passed would not have to be defined (eg, the above script
should not generate notices if E_STRICT is on and $_POST['username'] is
undefined), and undefined variables would be treated as null. 


Reproduce code:
---
// The PHP (close) equivalents:
function coalesce() {
$max = func_num_args();
for ($i = 0; $i  $max-1; $i++) {
$value = func_get_arg($i);
if (!empty($value)) {
return $value;
}
}
return func_get_arg($max-1);
}
function coalesce_strict() {
$max = func_num_args();
for ($i = 0; $i  $max-1; $i++) {
$value = func_get_arg($i);
if ($value !== null) {
return $value;
}
}
return func_get_arg($max-1);
}

Expected result:

coalesce('',0,1); // returns 1
coalesce(0,null,false,''); // returns '' (last value)
coalesce_strict(0,null,false,''); // returns 0




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


#39554 [NEW]: filter callback

2006-11-19 Thread xmlich02 at stud dot fit dot vutbr dot cz
From: xmlich02 at stud dot fit dot vutbr dot cz
Operating system: any
PHP version:  5.2.0
PHP Bug Type: Feature/Change Request
Bug description:  filter callback

Description:

it is possible to add into php any callback function which handles spam?

Reproduce code:
---
var_dump(filter_var($_REQUEST['message'], FILTER_CALLBACK, 'antispam'));


function antismap($message) {
  return exec('spamassasin $message');
}

// i can't use exec because of safe mode.
// so it whould be nice to have any
// option to embeded antispam function

Expected result:

set_ini (antispam, '/usr/bin/spamassasin');
var_dump(filter_var($_REQUEST['message'], FILTER_ANTISPAM));


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


#39555 [NEW]: ftp_rawlist not work with open_basedir

2006-11-19 Thread freidman at mail dot ru
From: freidman at mail dot ru
Operating system: Gentoo Linux
PHP version:  5.2.0
PHP Bug Type: FTP related
Bug description:  ftp_rawlist not work with open_basedir

Description:

This is related to bug #32708

There must be a way to set tmp-file creation of this functions, but
setting TMPDIR environment variable doesn't work. I don't want to include
/tmp dir in open_basedir directories.



Reproduce code:
---
?php
putenv('TMPDIR=/hosting/clients/xxx.com/httpd/tmp');

echo getenv('TMPDIR');

// set up basic connection
$conn_id = ftp_connect(xxx.com);

// login with username and password
$login_result = ftp_login($conn_id, xxx, xxx);

// get the file list for /
$buff = ftp_rawlist($conn_id, '/');

// close the connection
ftp_close($conn_id);

// output the buffer
var_dump($buff);
?

Expected result:

listing of files

Actual result:
--
/hosting/clients/xxx.com/httpd/tmp
Warning: ftp_rawlist() [function.ftp-rawlist]: open_basedir restriction in
effect. File(/tmp) is not within the allowed path(s):
(/hosting/clients/xxx.com/httpd:/usr/lib/php:/usr/local/lib/php) in
/hosting/clients/xxx.com/httpd/htdocs/a.php on line 15

Warning: ftp_rawlist() [function.ftp-rawlist]: Unable to create temporary
file. Check permissions in temporary files directory. in
/hosting/clients/xxx.com/httpd/htdocs/a.php on line 15
bool(false) 

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


#39449 [Com]: Overloaded array properties do not work correctly

2006-11-19 Thread v dot anagnostos at mail dot bg
 ID:   39449
 Comment by:   v dot anagnostos at mail dot bg
 Reported By:  pstradomski at gmail dot com
 Status:   Open
 Bug Type: Scripting Engine problem
 Operating System: Linux
 PHP Version:  5.2.0
 New Comment:

Reproduce code:
---

?php

class A{

private $test = array(1,2,3,4,5);

public function __get($v){
return $this-test;
}

}

$a = new A;

foreach( $a-overloaded_property as $val )
echo $val.br /\n;

?

Expected result:


1
2
3
4
5

Actual result:
--

Notice: Indirect modification of overloaded property
A::$overloaded_property has no effect in
C:\Apache\htdocs\dancho\index.php on line 15
1
2
3
4
5


Previous Comments:


[2006-11-14 20:31:16] cboden at gmail dot com

In the above example:
  $a-arr[]='d';
produced the expected results in PHP-5.1 but now gives the following
error in PHP-5.2
Notice: Indirect modification of overloaded property



[2006-11-09 14:05:23] pstradomski at gmail dot com

Reopening.

This should never be expected behaviour. This way encapsulation got
severly broken - __get was introduced to allow dynamic creation of
properties - and therefore implementation of record-like classes. Such
properties were meant to be indistinguishable from standard properties
- but aren't. Neither passing by reference works, nor array elements
do.

Developer can expect to be able to modify object properties for example
in such a way:

$x-arr = array('a');
array_push($x-arr, 'b');

Now it is impossible - although it should be. I understand previous
behaviour could be considered improper, bu now developers don't even
get a chance to choose between passing by value and passing by
reference.



[2006-11-09 13:50:54] [EMAIL PROTECTED]

This is expected behaviour.



[2006-11-09 13:43:27] pstradomski at gmail dot com

Description:

It is now impossible to implement overloaded array properties. Array
returned via __get is now a copy (not a reference as in 5.1.x) and it
is impossible to force getter to pass a reference.

Reproduce code:
---
?php

class A {
public function  __get($val) {
  return $this-keys[$val];
}
public function __set($k, $v) {
  $this-keys[$k] = $v;
}
private $keys = array();
}

$a =new A();

$a-arr = array('a','b','c');

$b = $a-arr;
$b[]= 'd';

foreach ($a-arr as $k = $v) {
  echo $k = $v\n;
}

$a-arr[]='d';

foreach ($a-arr as $k = $v) {
  echo $k = $v\n;
}

?

Expected result:

0 = a
1 = b
2 = c
3 = d

0 = a
1 = b
2 = c
3 = d
4 = d


Actual result:
--
Notice: Indirect modification of overloaded property A::$arr has no
effect in /home/pawel/tmp/a.php on line 18

Notice: Indirect modification of overloaded property A::$arr has no
effect in /home/pawel/tmp/a.php on line 21
0 = a
1 = b
2 = c

Notice: Indirect modification of overloaded property A::$arr has no
effect in /home/pawel/tmp/a.php on line 25

Notice: Indirect modification of overloaded property A::$arr has no
effect in /home/pawel/tmp/a.php on line 27
0 = a
1 = b
2 = c






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


#39555 [Opn-Bgs]: ftp_rawlist not work with open_basedir

2006-11-19 Thread iliaa
 ID:   39555
 Updated by:   [EMAIL PROTECTED]
 Reported By:  freidman at mail dot ru
-Status:   Open
+Status:   Bogus
 Bug Type: FTP related
 Operating System: Gentoo Linux
 PHP Version:  5.2.0
 New Comment:

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

In order to use tmp directory with open_basedir the directory 
must be part of the open_basedir directive.


Previous Comments:


[2006-11-19 10:18:27] freidman at mail dot ru

Description:

This is related to bug #32708

There must be a way to set tmp-file creation of this functions, but
setting TMPDIR environment variable doesn't work. I don't want to
include /tmp dir in open_basedir directories.



Reproduce code:
---
?php
putenv('TMPDIR=/hosting/clients/xxx.com/httpd/tmp');

echo getenv('TMPDIR');

// set up basic connection
$conn_id = ftp_connect(xxx.com);

// login with username and password
$login_result = ftp_login($conn_id, xxx, xxx);

// get the file list for /
$buff = ftp_rawlist($conn_id, '/');

// close the connection
ftp_close($conn_id);

// output the buffer
var_dump($buff);
?

Expected result:

listing of files

Actual result:
--
/hosting/clients/xxx.com/httpd/tmp
Warning: ftp_rawlist() [function.ftp-rawlist]: open_basedir restriction
in effect. File(/tmp) is not within the allowed path(s):
(/hosting/clients/xxx.com/httpd:/usr/lib/php:/usr/local/lib/php) in
/hosting/clients/xxx.com/httpd/htdocs/a.php on line 15

Warning: ftp_rawlist() [function.ftp-rawlist]: Unable to create
temporary file. Check permissions in temporary files directory. in
/hosting/clients/xxx.com/httpd/htdocs/a.php on line 15
bool(false) 





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


#39554 [Opn-WFx]: filter callback

2006-11-19 Thread derick
 ID:   39554
 Updated by:   [EMAIL PROTECTED]
 Reported By:  xmlich02 at stud dot fit dot vutbr dot cz
-Status:   Open
+Status:   Wont fix
 Bug Type: Feature/Change Request
 Operating System: any
 PHP Version:  5.2.0
 New Comment:

No, we can't do this as this would allow everybody to break out of
safemode.


Previous Comments:


[2006-11-19 10:15:56] xmlich02 at stud dot fit dot vutbr dot cz

Description:

it is possible to add into php any callback function which handles
spam?

Reproduce code:
---
var_dump(filter_var($_REQUEST['message'], FILTER_CALLBACK,
'antispam'));


function antismap($message) {
  return exec('spamassasin $message');
}

// i can't use exec because of safe mode.
// so it whould be nice to have any
// option to embeded antispam function

Expected result:

set_ini (antispam, '/usr/bin/spamassasin');
var_dump(filter_var($_REQUEST['message'], FILTER_ANTISPAM));






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


#38770 [Opn-Csd]: pack/unpack is broken on 64bit

2006-11-19 Thread iliaa
 ID:   38770
 Updated by:   [EMAIL PROTECTED]
 Reported By:  fwmatt at dsl dot pipex dot com
-Status:   Open
+Status:   Closed
 Bug Type: Unknown/Other Function
 Operating System: Linux x86_64
 PHP Version:  5.1.6
 New Comment:

This bug has been fixed in CVS.

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:


[2006-09-10 16:31:27] fwmatt at dsl dot pipex dot com

Sorry for re-opening this but;

Why should the same code produce different output on a 64bit machine
than it does on a 32bit machine ? 

If 4294937296 is the expect result then it is broken on 32bit machines
where it returns -3.



[2006-09-10 16:03:10] [EMAIL PROTECTED]

http://php.net/pack:

N - unsigned long (always 32 bit, big endian byte order)



[2006-09-10 15:55:20] fwmatt at dsl dot pipex dot com

Description:

On my 32bit x86 system the attached code produces the expected results,
however on my x86 64bit system it produces the (actual) attached.

Reproduce code:
---
print_r( unpack( N, pack( 'N', -3 ) ));

Expected result:

Array
(
[1] = -3
)

Actual result:
--
Array
(
[1] = 4294937296
)





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


#39557 [NEW]: Make functions accept superglobals as default value for its args

2006-11-19 Thread hermanscheele at gmail dot com
From: hermanscheele at gmail dot com
Operating system: *
PHP version:  5.2.0
PHP Bug Type: Feature/Change Request
Bug description:  Make functions accept superglobals as default value for its 
args

Description:

This is really a request to make an exception to the following
limitation:

The default value must be a constant expression, not (for example) a
variable, a class member or a function call.

Quoted from: http://nl2.php.net/manual/en/functions.arguments.php

It's my guess that this has to do with the vars scope getting messy, but I
think superglobals would qualify for an exception to this.

Constants are already accepted.

Reproduce code:
---
function foo($bar=$_SERVER['REMOTE_ADDR'])
{
  echo('Given IP is: '.$bar.'br /');
}
foo('192.168.1.1');
foo();

Expected result:

I would expect PHP to echo the submitted string the first function-call.
And echo the clients IP the second call.

Actual result:
--
I get the following parse error, which is correct, but not desirable I
think.

Parse error: parse error, unexpected T_VARIABLE in path\to\file.php on
line 1

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


#39531 [Bgs]: soft evaluation between integers and strings

2006-11-19 Thread mgf
 ID:   39531
 Updated by:   [EMAIL PROTECTED]
 Reported By:  jakobsg at gmail dot com
 Status:   Bogus
 Bug Type: Variables related
 Operating System: All
 PHP Version:  4.4.4
 New Comment:

No, I haven't missed the point at all -- you have.  In that table, the
last row and last column have the heading php which is intended to
represent *all* strings except the 3 explicitly mentioned elsewhere --
this would include the string o.

(This conversion of non-numeric strings to zero is also noted at
http://www.php.net/manual/en/language.types.string.php#language.types.string.conversion)


Previous Comments:


[2006-11-17 11:56:54] jakobsg at gmail dot com

OK, I think you missed the point. It's not the stringified zero (0)
I'm talking about, it's the letter o that evaluates true when
compared with zero. The letter o is no where en the O-2 table. Sorry
if we have been talking about apples and bananas :-)



[2006-11-17 10:49:01] [EMAIL PROTECTED]

Er -- yes it is. Table O-2, to be specific.



[2006-11-16 21:07:15] jakobsg at gmail dot com

Is there some where in particular I should look?

It's not here:
http://www.php.net/manual/da/types.comparisons.php



[2006-11-16 11:15:44] [EMAIL PROTECTED]

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





[2006-11-16 11:08:28] jakobsg at gmail dot com

Description:

This is pretty straight forward.
The soft evaluation (==) feature in php can be nice, personally I never
use it, but I acknowledge that it can be useful in some situations.
The result of the following evaluation however is not acceptable by any
means (even in soft evaluation):

0 == '0'  (true, and acceptable)
0 == 'o'  (true, really!!!)

0 == 'o' are equal ... Common - this can only lead to errors.

Best regards Jakob Simon-Gaarde

Reproduce code:
---
var_export(0=='o');

Expected result:

false

Actual result:
--
true





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