Re: [PHP-DEV] Moving extensions to PECL

2003-01-13 Thread Brad Bulger

If I may, I'd like to suggest that if you want to emphasize PEAR in PHP5,
that someone should look at bug 20933, to either verify that it is a bug,
or make it clear that this new behavior is intended. (The bug is about
isset() on a string subset like $a{1} always returning false.)

Only because at the moment, pear/Console/Getopt.php depends on the old
behavior, and so the 'pear' package manager script is broken. There's some
reluctance to accept a workaround patch to acommodate ZE2 when the problem
might just go away eventually.

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] $scalar{index} syntax

2002-12-11 Thread Brad Bulger

yes, whoosp, just found that page. the problem turns out to be
that isset($string{n}) is always false with ZE2, and empty($string{n}) is
always true. same for $string[n]. it works with ZE1, so i'll
just log the bug.

(though it does kick out an 'Uninitialized...' notice, which the same
test on an array key or object property does not. i sympathize with the
bugs that have been logged about that, which have generally been marked
Bogus. but that can be suppressed with @, at least, so not a big thing.)

On Tue, 10 Dec 2002, Rasmus Lerdorf wrote:

 You mean $string{2} ?  That's the more correct way to do $string[2] to
 make it clear that it is a character offset.  This has been supported for
 years and will not go away.

 -Rasmus

 On Tue, 10 Dec 2002, Brad Bulger wrote:

 
  trying to fix bugs in some PEAR code, i noticed the person used a way
  of getting at the individual characters in a string:
 
  $string{2} === substr($string,2,1)
 
  is that old syntax or something? is there any reason to expect it to work
  in future versions?
 
  thanks
 
  --
  PHP Development Mailing List http://www.php.net/
  To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] $scalar{index} syntax

2002-12-10 Thread Brad Bulger

trying to fix bugs in some PEAR code, i noticed the person used a way
of getting at the individual characters in a string:

$string{2} === substr($string,2,1)

is that old syntax or something? is there any reason to expect it to work
in future versions?

thanks

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] overridden php.ini directives in CLI version

2002-12-03 Thread Brad Bulger

shouldn't 'output_buffering' be overridden to 0 (off) in the CLI SAPI?
doesn't help to override 'implicit_flush' but not that one. especially
since there's no way to turn off the ini-level output buffering from
a script.  you can't end it with ob_end_*() and you can't set it with
ini_set(). whereas anyone who wants output buffering in a script
can always turn it on themselves.

i know it defaults to off in php.ini-dist, but don't underestimate the
appeal of the word 'recommended'...

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] cvsclean removes pear/PEAR on OS X 10.2

2002-11-24 Thread Brad Bulger
I think this is the darned case-insensitivity causing a problem again. 
the pear/.cvsignore
file lists 'pear' - meaning the installer, presumably - but when 
cvsclean does a remove
of it, it ends up removing the PEAR directory. (this came up because 
the 10.2 upgrade
installed a too-new version of autoconf, so buildconf is running 
cvsclean)

i honestly can't see what to do about it except to build the 'pear' 
file inside a directory,
so that it's not parallel to the PEAR directory...


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] ZEND_PUTC question

2002-11-21 Thread Brad Bulger
I was looking at compile warnings for 4.3, and came across this
in Zend/zend.h

/* output support */
#define ZEND_WRITE(str, str_len)zend_write((str), (str_len))
#define ZEND_PUTS(str)  zend_write((str), strlen((str)))
#define ZEND_PUTC(c)zend_write((c), 1), (c)

is there a reason why that last line isn't just

#define ZEND_PUTC(c)zend_write((c), 1)

??


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] on the subject of overloading: __call()

2002-11-17 Thread Brad Bulger
On Sun, 17 Nov 2002, Stanislav Malyshev wrote:

 BB related topic: in the current state of ze2, there are several ways to
 BB call methods directly that can't be emulated by call_user_func() -
 BB calling self::method() for instance, or the visibility of $this if
 BB you call class::method(). is that likely to stay true?

 Since __call is the method of the class, calling self::method can be
 achieved, I think. As for the second point - could you please explain
 furher what you mean, maybe with an example?

right, because static method calls don't get caught by __call, so you
always have $this.

the basic problem is that as it is now, if i do any of these

self::a_method($arg1,$arg2);
parent::a_method($arg1,$arg2);
some_other_class::a_method($arg1,$arg2);

inside of a class's method, $this is visible inside those called methods,
and points to the calling object.

but there is no way to make equivalent calls using call_user_func()
or call_user_func_array(). you can't use parent::a_method,
array($this,'parent::a_method'), array(parent,a_method),
or array('parent',a_method). if you use the literal class name,
call_user_func_array(array(get_parent_class($this),'a_method'), $args);
it doesn't fail, but it's as if you were making a static method call
from outside of an object context - $this is not defined.

it's the last two cases - parent:: and some_other_class:: - that relate
to __call(), as you point out. and what truly matters is call_user_func_array(),
because not having it means you can't hand off the arguments from __call()'s
parameters to a method in the parent class or in some other class. not without
writing some pretty hacky eval() code, that is.

(btw, there should probably be a warning in the docs that methods that
are expecting to force their parameters to be references will not work
as expected when called by call_user_func_array().)

i'm attaching kind of long test case code  resulting output that
show what i mean.


?php
class bar
{
var $z = 'initial value of z for bar';
function test($x=NULL,$y=NULL)
{
print \tthis is bar::test x=.var_export($x,TRUE). y=$y\n;
if (isset($this))
{
print \tbar::test - this-z = {$this-z}\n;
}
else
{
print \tbar::test - this is not set\n;
}
}
function __call($m,$a) {}
}
class base
{
var $z = 'initial value of z for base';
function test($x=NULL,$y=NULL)
{
print \tthis is base::test x=.var_export($x,TRUE). y=$y\n;
if (isset($this))
{
print \tbase::test - this-z = {$this-z}\n;
}
else
{
print \tbase::test - this is not set\n;
}
self::whoami('self::whoami from base::test');
}
function __call($m,$a) {}
function whoami($caller=NULL)
{
print \twhoami caller=$caller: __CLASS__ = .__CLASS__.\n;
$class = get_class(new self);
print \twhoami caller=$caller: get_class(new self) = $class\n;
$class = get_class('self');
print \twhoami caller=$caller: get_class('self') = $class\n;
if (isset($this))
{
$class = get_class($this);
}
else
{
$class = '$this is not set';
}
print \twhoami caller=$caller: get_class(this) = $class\n;
}
}
class foo extends base
{
var $z = 'initial value of z for foo';
function test($x=NULL,$y=NULL)
{
print \tthis is foo::test x=.var_export($x,TRUE). y=$y\n;
if (isset($this))
{
print \tfoo::test - this-z = {$this-z}\n;
}
else
{
print \tfoo::test - this is not set\n;
}
self::whoami('self::whoami from foo::test');
}
function test_parent($x=NULL,$y=NULL)
{
ob_start();

$results = '';
$results .= this is foo::test_parent x=.var_export($x,TRUE). 
y=$y\n;
if (isset($this))
{
$results .= foo::test_parent - this-z = {$this-z}\n;
}
else
{
$results .= foo::test_parent - this is not set\n;
}

$results .= \n-\n;
$results .= __CLASS__.'::'.__FUNCTION__.'['.__LINE__.'] 
parent::test($x,$y);'.\n;
parent::test($x,$y);

[PHP-DEV] on the subject of overloading: __call()

2002-11-15 Thread Brad Bulger
was there discussion about the interaction of __call() and
methods which declaring their arguments as references?
there's no way at present to make this work, as far as i can tell.
seems like it could just be a documented limitation, but i thought
i'd check.

related topic: in the current state of ze2, there are several
ways to call methods directly that can't be emulated by
call_user_func() - calling self::method() for instance, or
the visibility of $this if you call class::method().
is that likely to stay true?


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] $HTTP_RAW_POST_DATA

2002-11-10 Thread Brad Bulger

On Sun, 10 Nov 2002, Rasmus Lerdorf wrote:

 Hrm..  Ok, actually Hartmut changed this recently.  See:

 
http://cvs.php.net/diff.php/php4/main/php_content_types.c?login=2r1=1.21r2=1.22ty=u

 It works when you turn on always_populate_raw_post_data, right?

kind of. it doesn't quite follow the doc blurb - even if always_populate
is turned on, if the content type IS recognized, and it's not the default
- which right now means only multipart/form-data far as i can tell -
then HTTP_RAW_POST_DATA is not set. something should be changed to
take that into account, either making it work with multipart/form-data
or changing the documentation.

also, there was a small change i had to make in php_content_types.c to
make it pick up XML data without getting an error about the string
not being null-terminated. i'm attaching a diff file.

Index: php_content_types.c
===
RCS file: /repository/php4/main/php_content_types.c,v
retrieving revision 1.23
diff -u -r1.23 php_content_types.c
--- php_content_types.c 8 Nov 2002 08:41:52 -   1.23
+++ php_content_types.c 10 Nov 2002 17:16:04 -
 -38,6 +38,7 
 SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
 {
char *data = NULL;
+   int data_length = 0;
 
if(PG(always_populate_raw_post_data)) {
if(NULL == SG(request_info).post_data) { /* no data yet */
 -45,16 +46,18 
/* no post handler registered, so we just swallow the 
data */
sapi_read_standard_form_data(TSRMLS_C);
data = SG(request_info).post_data;
+   data_length = SG(request_info).post_data_length;
SG(request_info).post_data = NULL;
SG(request_info).post_data_length = 0;
}
} else {
/* copy existing post data */
-   data = estrndup(SG(request_info).post_data, 
SG(request_info).post_data_length);
+   data_length = SG(request_info).post_data_length;
+   data = estrndup(SG(request_info).post_data, data_length);
}

if(data) {
-   SET_VAR_STRINGL(HTTP_RAW_POST_DATA, data, 
SG(request_info).post_data_length);
+   SET_VAR_STRINGL(HTTP_RAW_POST_DATA, data, data_length);
}
}
 }

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] overload() crashes in ZE2

2002-08-10 Thread Brad Bulger


trying to build CVS version with ZendEngine2 and use the overload extension.
PHP crashes with a bus error on the call to overload(). it's a hash table
problem, over my head for sure. i can't get this to work at all and wonder
if it's a Darwin(OS X) issue. has anyone else run into this?

this is the compile process:

cvs checkout php4
cd php4
cvs checkout ZendEngine2

then i have to edit ZendEngine2/Zend.m4 to change this line:

fprintf(fp, %d %d\n, ZEND_MM_ALIGNMENT, zeros);

to add that '\n' char, or else configure fails and ZEND_MM_ALIGNMENT
and ZEND_MM_ALIGNMENT_LOG2 don't get defined correctly - you can see
why i'm thinking this is a platform and/or config problem...

then continuing:
./buildconf --ZendEngine2
mv Zend Zend1.2
mv ZendEngine2 Zend
./configure
make

sapi/cli/php -v
PHP 4.3.0-dev (cli), Copyright (c) 1997-2002 The PHP Group
Zend Engine v2.0.0-alpha2, Copyright (c) 1998-2002 Zend Technologies

sapi/cli/php -m
[PHP Modules]
xml
tokenizer
standard
session
posix
pcre
overload
mysql
mbstring
ctype

[Zend Modules]

sapi/cli/php -r class foo {} overload('foo');
Bus error

gdb sapi/cli/php
GNU gdb 5.0-20001113 (Apple version gdb-203) (Wed Nov  7 16:28:57 GMT 2001) (UI_OUT)
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type show copying to see the conditions.
There is absolutely no warranty for GDB.  Type show warranty for details.
This GDB was configured as powerpc-apple-macos10.
Reading symbols for shared libraries .. done
(gdb) run -r class foo {} overload('foo');
Starting program: /usr/local/book/php4/sapi/cli/php -r class foo {} overload('foo');
[Switching to thread 1 (process 486 thread 0x1603)]
Reading symbols for shared libraries . done

Program received signal EXC_BAD_ACCESS, Could not access memory.
0x000f9820 in zend_hash_exists (ht=0x521234, arKey=0x118990 __get, nKeyLength=6) at 
/usr/local/book/php4/Zend/zend_hash.c:924
924 p = ht-arBuckets[nIndex];
(gdb) bt
#0  0x000f9820 in zend_hash_exists (ht=0x521234, arKey=0x118990 __get, nKeyLength=6) 
at /usr/local/book/php4/Zend/zend_hash.c:924
#1  0x0003d9a8 in zif_overload (ht=0, return_value=0x53de88, this_ptr=0x6, 
return_value_used=0) at /usr/local/book/php4/ext/overload/overload.c:671
#2  0x0010a88c in execute (op_array=0x53dc38) at 
/usr/local/book/php4/Zend/zend_execute.c:2079
#3  0x000e975c in zend_eval_string (str=0xb728 , retval_ptr=0x0, 
string_name=0x0) at /usr/local/book/php4/Zend/zend_execute_API.c:715
#4  0x00112058 in main (argc=3, argv=0xbbc4) at 
/usr/local/book/php4/sapi/cli/php_cli.c:717
#5  0x1b80 in _start ()
#6  0x19b0 in start ()
(gdb)


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php