Re: [PHP-DEV] Re: bug of the day: $this

2002-12-07 Thread Balazs Nagy
On Fri, 2002-12-06 at 22:11, Stig S. Bakken wrote:
> It won't be different in ZE2.  This is not a bug though, but a tricky
> design issue.  The problem is figuring out at runtime when to set $this
> or not in a method.  What most people would probably find intuitive, is
> that $this was set only in methods called in the object, but this would
> require pretty expensive checks for every method call.

Maybe the roots of OO is my problem. PHP does similar, but not exactly.
I don't know whether you like clear things, or is this clear to you, but
I see confusion about handling $this. Excerpt from the documentation:

http://www.php.net/manual/en/language.oop.php

Within a class definition, you do not know under which name the object
will be accessible in your program: at the time the Cart class was
written, it was unknown that the object will be named $cart or
$another_cart later. Thus, you cannot write $cart->items within the Cart
class itself. Instead, in order to be able to access it's own functions
and variables from within a class, one can use the pseudo-variable $this
which can be read as 'my own' or 'current object'. Thus,
'$this->items[$artnr] += $num' can be read as 'add $num to the $artnr
counter of my own items array' or 'add $num to the $artnr counter of the
items array within the current object'.

> Andi can shed more light on this if needed.

Andi, please tell me why.
-- 
jul

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




Re: [PHP-DEV] Re: bug of the day: $this

2002-12-03 Thread Balazs Nagy
On Tue, 2002-12-03 at 21:53, Ivan Ristic wrote:
> Balazs Nagy wrote:
> > Hi,
> > 
> > $this stays defined when an instantatiated member function calls a
> > non-instantiated member function.
> 
>Correct. I actually find it quite interesting. :)
>It can be useful at times, I have used it in my
>libraries as a feature.
> 
>There is an interesting article on the subject:
>http://www.advogato.org/article/470.html

Now, please tell me how can you decide whether the member function is
called as an object element (eg. $obj->func()) or as a class element
(eg. class::func()).

Basic functionality is killed with this so-called feature.  The right
way should be a call stack, with for example a $_STACK array, or through
stack functions (eg. this_object(), previous_object()).
-- 
jul

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




[PHP-DEV] bug of the day: $this

2002-12-03 Thread Balazs Nagy
Hi,

$this stays defined when an instantatiated member function calls a
non-instantiated member function.

Here's the tester:

test(); }
function btest() { b::test(); }
}

class b {
function test() { var_dump($this); }
function objtest($obj) { $obj->test(); }
function atest() { b::test(); }
}

print "A::test:\n";
a::test();
print "A::btest:\n";
a::btest();
print "B::test:\n";
b::test();
print "B::atest:\n";
b::atest();

$a = new a;
$b = new b;
print "\$A->test:\n";
$a->test();
print "\$A->btest:\n";
$a->btest();
print "\$A->objtest(\$B):\n";
$a->objtest($b);
print "\$B->test:\n";
$b->test();
print "\$B->atest:\n";
$b->atest();
print "\$B->objtest(\$A):\n";
$b->objtest($a);
?>

Sample output (php-4.3.0RC2, compiled with ./configure; make):

kotta:~/src/php-4.3.0RC2>>% ./sapi/cli/php ~/test.php
A::test:
NULL
A::btest:
NULL
B::test:
NULL
B::atest:
NULL
$A->test:
object(a)(0) {
}
$A->btest:
object(a)(0) {
}
$A->objtest($B):
object(b)(0) {
}
$B->test:
object(b)(0) {
}
$B->atest:
object(b)(0) {
}
$B->objtest($A):
object(a)(0) {
}


-- 
jul

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




[PHP-DEV] Is dbug broken in 4.2.0RC4?

2002-04-18 Thread Balazs Nagy

Hi,

I bumped to another segfault:

#0  _db_return_ (_line_=1633, _sfunc_=0x1b4c1d8, _sfile_=0x1b4c1dc, 
_slevel_=0x1b4c1e0) at dbug.c:827
#1  0x006df19b in mysql_select_db (mysql=0x84454c8, db=0x87c52d8 "tft")
at libmysql.c:1633
#2  0x006d9a4e in zif_mysql_select_db (ht=2, return_value=0x8628530, 
this_ptr=0x0, return_value_used=0, tsrm_ls=0x82e7680) at
php_mysql.c:797
#3  0x00425258 in execute (op_array=0x87e0988, tsrm_ls=0x82e7680)
at ./zend_execute.c:1598
#4  0x004278ec in execute (op_array=0x87cd980, tsrm_ls=0x82e7680)
at ./zend_execute.c:2141
...
(gdb) frame 0
#0  _db_return_ (_line_=1633, _sfunc_=0x1b4c1d8, _sfile_=0x1b4c1dc, 
_slevel_=0x1b4c1e0) at dbug.c:827
827   state->framep = (char **) *state->framep;
(gdb) print *state->framep
Cannot access memory at address 0xa
(gdb) print state->framep
$7 = (char **) 0xa

-- 
jul



signature.asc
Description: This is a digitally signed message part


Re: [PHP-DEV] PHP 4.2.0 RC4

2002-04-16 Thread Balazs Nagy

On Mon, 2002-04-15 at 19:04, [EMAIL PROTECTED] wrote:

> can you make a backtrace of this? 

Excusez moi, I had a hard time in the last D&D3 session when I wrote
this.  Here's the dump:

#0  0x00440397 in php_apache_sapi_log_message (
msg=0xbfffef80 "PHP Warning:  Unable to load dynamic library 'dba.so' - dba.so: 
cannot open shared object file: No such file or directory in Unknown on line 0") at 
sapi_apache2.c:214
214 ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO | APLOG_STARTUP, 0, 
ctx->r->server, "%s", msg);
(gdb) bt
#0  0x00440397 in php_apache_sapi_log_message (
msg=0xbfffef80 "PHP Warning:  Unable to load dynamic library 'dba.so' - dba.so: 
cannot open shared object file: No such file or directory in Unknown on line 0") at 
sapi_apache2.c:214
#1  0x00441701 in php_log_err (
log_message=0xbfffef80 "PHP Warning:  Unable to load dynamic library 'dba.so' - 
dba.so: cannot open shared object file: No such file or directory in Unknown on line 
0", tsrm_ls=0x81414a0) at main.c:324
#2  0x00441c7b in php_error_cb (type=32, error_filename=0x4f0250 "Unknown", 
error_lineno=0, 
format=0x4f8e20 "Unable to load dynamic library '%s' - %s", args=0xb838) at 
main.c:459
#3  0x00434c39 in zend_error (type=32, format=0x4f8e20 "Unable to load dynamic library 
'%s' - %s")
at zend.c:682
#4  0x00485dce in php_dl (file=0x814c718, type=1, return_value=0xb880, 
tsrm_ls=0x81414a0) at dl.c:137
#5  0x004460e8 in php_load_function_extension_cb (arg=0x814c718, tsrm_ls=0x81414a0) at 
php_ini.c:188
#6  0x0042d113 in zend_llist_apply (l=0x51aa3c, func=0x4460c4 
, 
tsrm_ls=0x81414a0) at zend_llist.c:186
#7  0x004464ad in php_ini_delayed_modules_startup (tsrm_ls=0x81414a0) at php_ini.c:313
#8  0x004432af in php_module_startup (sf=0x4ffac0) at main.c:1001
#9  0x004409f4 in php_apache_server_startup (pconf=0x80b90a0, plog=0x80ef178, 
ptemp=0x80f1180, s=0x80bbce0)
at sapi_apache2.c:435
#10 0x0808025e in ap_run_post_config (pconf=0x80b90a0, plog=0x80ef178, 
ptemp=0x80f1180, s=0x80bbce0)
at config.c:127
#11 0x08084af8 in main (argc=2, argv=0xbab4) at main.c:569
#12 0x002ca627 in __libc_start_main (main=0x80844bc , argc=2, ubp_av=0xbab4, 
init=0x805ee6c <_init>, fini=0x809d9d0 <_fini>, rtld_fini=0x11dcc4 <_dl_fini>, 
stack_end=0xbaac)
at ../sysdeps/generic/libc-start.c:129
(gdb) print ctx
$1 = (php_struct *) 0x0

-- 
jul



signature.asc
Description: This is a digitally signed message part


Re: [PHP-DEV] PHP 4.2.0 RC4

2002-04-15 Thread Balazs Nagy

I made a very clean startup with apache2 and php4.2.0RC4, and I set
extension_dir to a false './'. I got a very big segfault. Everything
else is cool.
-- 
jul



signature.asc
Description: This is a digitally signed message part


Re: [PHP-DEV] if (empty(trim('x'))) == parse error?

2001-11-28 Thread Balazs Nagy

Andrey Hristov wrote:

>From the docs for empty():
>"Note that this is meaningless when used on anything which isn't a
>variable; i.e. empty (addslashes ($name)) has
>no meaning since it would be checking whether something which isn't a variable is a 
>variable with a FALSE value. "
>

Maybe I am not so clever, but the document writer tried to explain that 
empty()'s flaw is a feature. The correct doc should contain lvalue 
instead of variable.

-- 
jul




-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] buildconf produce invalid configure fail

2001-11-27 Thread Balazs Nagy

Serg Musichenko wrote:

> Platforma:
> Autoconf 2.52
> Automake 1.5
> Libtool 1.4.2
> OS RH 7.2


Automake 1.5 is bogus. Use automake-1.4. RH7.2's automake is fine.
Autoconf 2.52 has some incompatibilities in macros. Autoconf 2.13 works 
fine, but maybe 2.52 works too.

-- 
jul




-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] 4.1.0RC2

2001-11-21 Thread Balazs Nagy

On Sun, Nov 18 2001, Derick Rethans <[EMAIL PROTECTED]> wrote:

> can you clarify your patches? I've no idea why they are needed.

Hi,

I found that these patches are for autoconf-2.52.  Sadly
_AC_DECL_YYTEXT breaks the compatibility with autoconf-2.13.

BTW +2 successful RC3 tests (RH72), but autoconf-2.52 needs my patches.
-- 
jul

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] buildconf

2001-11-20 Thread Balazs Nagy

On Mon, Nov 19 2001, Serg Musichenko <[EMAIL PROTECTED]> wrote:

> I reinstall aunoconf 2.13 only and buildconf work Ok
> 
> Autoconf 2.52d not produce configure from  configure.in
> 
> [EMAIL PROTECTED] wrote:
> 
> > I suggest you use automake 1.4 and libtool 1.4 (not newer versions). (I
> > think automake is the problem here though, you might to test that first).

Correct: checked with automake 1.5.  It is bogus.  I have autoconf 2.52 and
it works OK to me.
-- 
jul

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] 4.1.0RC2

2001-11-18 Thread Balazs Nagy

On Sun, Nov 18 2001, Derick Rethans <[EMAIL PROTECTED]> wrote:

> I merged those patches. Can you try the latest CVS version?

Works well. BTW is this a feature?

'A', 'b'=>'B');
$b = array('a' => 'newA');
$c = $a + $b;
$d = array_merge($a, $b);
var_dump($c);
var_dump($d);
?>

returns: 

X-Powered-By: PHP/4.1.0RC2
Content-type: text/html

array(2) {
  ["a"]=>
  string(1) "A"
  ["b"]=>
  string(1) "B"
}
array(2) {
  ["a"]=>
  string(4) "newA"
  ["b"]=>
  string(1) "B"
}
-- 
jul

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] 4.1.0RC2

2001-11-17 Thread Balazs Nagy

On Tue, Nov 13 2001, Derick Rethans <[EMAIL PROTECTED]> wrote:

> Forgot to attached it...

I have downloaded the latest php4 from PHP_4_0_7 branch, and still I can't
complile, but I found some patches against the HEAD branch which should
applied to PHP_4_0_7 too:

http://cvsweb.php.net/diff.php/php4/acinclude.m4?sbt=2&r1=1.139&r2=1.140&ty=u
http://cvsweb.php.net/diff.php/php4/configure.in?sbt=2&r1=1.273&r2=1.274&ty=u

(acinclude.m4 diff release 1.139 to 1.140 and
 configure.in diff release 1.273 to 1.274)
-- 
jul

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] 4.1.0RC2

2001-11-13 Thread Balazs Nagy

On Tue, Nov 13 2001, Zeev Suraski <[EMAIL PROTECTED]> wrote:

> Either that or we can simply check if this #define exists...  What do you 
> think?

Checking for a version and for a #define is the same, but version checking
is more subtle and can be hidden than another check for the #define's
existence.
-- 
jul

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] 4.1.0RC2

2001-11-13 Thread Balazs Nagy

On Tue, Nov 13 2001, Zeev Suraski <[EMAIL PROTECTED]> wrote:

> http://www.php.net/~zeev/php-4.1.0RC2.tar.gz
> 
> Do your thang :)

make[1]: Entering directory /home/js/dl/linux/web/php-4.1.0RC2/ext/curl'
gcc -I. -I/home/js/dl/linux/web/php-4.1.0RC2/ext/curl
-I/home/js/dl/linux/web/php-4.1.0RC2/main
-I/home/js/dl/linux/web/php-4.1.0RC2
-I/home/js/dl/linux/web/php-4.1.0RC2/Zend -I/usr/include/freetype2/freetype
-I/home/js/dl/linux/web/php-4.1.0RC2/ext/xml/expat
-I/home/js/dl/linux/web/php-4.1.0RC2/TSRM -g -Wall  -c curl.c && touch
curl.lo
curl.c: In function `zm_startup_curl':
curl.c:145: `CURLOPT_SSL_VERIFYHOST' undeclared (first use in this function)
curl.c:145: (Each undeclared identifier is reported only once
curl.c:145: for each function it appears in.)
curl.c: In function `zif_curl_setopt':
curl.c:640: `CURLOPT_SSL_VERIFYHOST' undeclared (first use in this function)
make[1]: *** [curl.lo] Error 1
make[1]: Leaving directory /home/js/dl/linux/web/php-4.1.0RC2/ext/curl'
make: *** [all-recursive] Error 1

It doesn't work with curl-7.8.  It's old enough but this version is included
into Red Hat Linux 7.2.  In the 7.9.1 CHANGES file:

Version 7.8.1-pre4

[...]

- Patrick Bihan-Faou introduced CURLOPT_SSL_VERIFYHOST, which makes curl
  verify the server's CN field when talking https://. If --cacert is not used,
  any failures in matching is only displayed as information (-v).

Thus configure's curl check should contain a version check for 7.8.1 or
higher.
-- 
jul



-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] using PEAR and safe_mode at the same time (long)

2001-01-27 Thread Balazs Nagy

Hi,

I work for a web hosting / ASP / linux company, and my last problem is using
a standard library (which can be accessed by any php users, like PEAR), and
keeping the secret of other directories.

Solution for the first problem is 'include_path = ".:/path/to/shared/libs",'
and for the second one is 'safe_mode = on.'

Well, it's good enough but there's a little glitch: file ownership.  In safe
mode the interpreter refuses opening files which owner uid is not the same
as the running script's. Eg. I have to copy the stdlib (ohh, those wonderful
days of MudOS mudlib writing!) for each user of each virtual hosts.

I think a safe_mode_checkuid flag would solve the problem.

In stock php 4.0.4pl1 safe_mode is checked by

- sapi/apache/php_apache: AUTHORIZATION env.var is not serviced
- main/fopen-wrappers: fopen wrappers checks for same userid
- main/main: set_time_limit is blocked
- ext/standard/basic_functions: handles safe_mode_(allowed|protected)_env_vars
- ext/standard/dl: dl is blocked
- ext/standard/exec: exec is restricted to safe_mode_exec_dir and ``s are
  blocked
- ext/standard/file: popen is restricted to safe_mode_exec_dir
  mkdir, rmdir, rename, unlink, copy are privileges-checked
- ext/standard/filestat: chkgrp, chown, chmod, touch are privileges-checked 
  chmod is limited to 0777 (no special rights)
- ext/standard/link: symlink, link are privileges-checked
- ext/posix/posix: mkfifo is privileges-checked
- ext/pgsql/pgsql: pg_loimport is privileges-checked
- ext/filepro/filepro: filepro, filepro_rowcount, filepro_retrieve are
  privileges-checked
- ext/dbase/dbase: dbase_open, dbase_create are privileges-checked
- ext/db/db: dbmopen is privileges-checked

Check/block summary

env.var block:
  - AUTHORIZATION (only in apache SAPI)
function block:
  - dl
  - set_time_limit
function restrictions: 
  - safe_mode_allowed_env_vars
  - safe_mode_protected_env_vars
privileges
  - sanity checks
mkdir, rmdir, rename, unlink, copy, chkgrp, chown, chmod, touch,
symlink, link, mkfifo, pg_loimport, filepro, filepro_rowcount,
filepro_retrieve, dbase_open, dbase_create, dbmopen
  - special access permissions block
chmod
  - userid checks
fopen

Conclusion

Some things are must-have in safe_mode, but I would put an own flag for each
type (well, the privilege sanity checks don't do any bad, so this type
doesn't need another flag).

Comments? Implementations?
-- 
Nagy Balazs, LSC
http://www.lsc.hu/

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]