Re: [PHP-DEV] [PATCH] fix crash in solaris when fdopen() fails

2005-04-08 Thread Uwe Schindler
OK - I found out that the fdopen() code is never called in the PHP 
environment, so patch is not needed (PHP sets zend_file_handle always to 
STREAM). But I still want to know for what extensions/functions the casts 
from posix to stdio are needed- Will casting appear somewhere when the user 
calls the userlevel-file-functions starting with fopen()?. It is hard work 
to find out with simple search through CVS.
The only position I know is because of popen() etc. in the exec functions 
which are stdio (posix variants are more complicated), which is the cause 
for the bug report I mentioned.

At 09:40 07.04.2005, Uwe Schindler wrote:
I am fixing bug #32614: Problem, on the solaris platform fdopen() can fail 
even if fd is a correct file descriptor, when fd255 (the well-known 
solaris stdio problem). The webserver of the user crashes because the 
return value of fdopen() is not checked for NULL when casting a stream 
from posix to stdio. After this fd==-1 and fp==NULL == further calls to 
fread/fwrite with this fp segfault.
I committed the patches for PHP but I have no karme for ZendEngine2. Can 
someone with karma submit this patch?

According to this it would be interesting, WHEN some PHP/Zend code tries 
to cast a POSIX stream to stdio? In which extension/functions? Can this be 
fixed to only use posix IO? The zend engine itself should be safe since 
4.3.3 and since PHP5.

Does stream casts apply if a user uses the PHP user functions fopen, 
fread, fwrite? Since Saschas fix in PHP4 there this does not happen. What 
about PHP5?

I would try to fix this everywhere in the future.
-
Uwe Schindler
[EMAIL PROTECTED] - http://www.php.net
NSAPI SAPI developer
Erlangen, Germany

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
-
Uwe Schindler
[EMAIL PROTECTED] - http://www.php.net
NSAPI SAPI developer
Bremen, Germany
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Andrey Hristov
  Hi Marcus,
what about class_constant_exists(classname, const)
(a bit long function name though)?
Andrey
Marcus Boerger wrote:
helly   Fri Apr  8 09:33:17 2005 EDT
  Modified files:  
/ZendEngine2	zend_builtin_functions.c 
  Log:
  - Add property_exits()
  
http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.262r2=1.263ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.262 ZendEngine2/zend_builtin_functions.c:1.263
--- ZendEngine2/zend_builtin_functions.c:1.262	Mon Apr  4 13:23:38 2005
+++ ZendEngine2/zend_builtin_functions.c	Fri Apr  8 09:33:15 2005
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 13:33:15 helly Exp $ */
 
 #include zend.h
 #include zend_API.h
@@ -43,6 +43,7 @@
 static ZEND_FUNCTION(get_class);
 static ZEND_FUNCTION(get_parent_class);
 static ZEND_FUNCTION(method_exists);
+static ZEND_FUNCTION(property_exists);
 static ZEND_FUNCTION(class_exists);
 static ZEND_FUNCTION(interface_exists);
 static ZEND_FUNCTION(function_exists);
@@ -102,6 +103,7 @@
 	ZEND_FE(get_class,			NULL)
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Marcus Boerger
Hello Andrey,

  somehow i knew someone would ask for that
  how about you writing a patch?

Friday, April 8, 2005, 5:01:24 PM, you wrote:

Hi Marcus,
 what about class_constant_exists(classname, const)
 (a bit long function name though)?

 Andrey

 Marcus Boerger wrote:
 helly Fri Apr  8 09:33:17 2005 EDT
 
   Modified files:  
 /ZendEngine2  zend_builtin_functions.c 
   Log:
   - Add property_exits()
   
 http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.262r2=1.263ty=u
 Index: ZendEngine2/zend_builtin_functions.c
 diff -u ZendEngine2/zend_builtin_functions.c:1.262
 ZendEngine2/zend_builtin_functions.c:1.263
 --- ZendEngine2/zend_builtin_functions.c:1.262Mon Apr  4 13:23:38 
 2005
 +++ ZendEngine2/zend_builtin_functions.c  Fri Apr  8 09:33:15 2005
 @@ -17,7 +17,7 @@

 +--+
  */
  
 -/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas Exp $ */
 +/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 13:33:15 helly Exp $ */
  
  #include zend.h
  #include zend_API.h
 @@ -43,6 +43,7 @@
  static ZEND_FUNCTION(get_class);
  static ZEND_FUNCTION(get_parent_class);
  static ZEND_FUNCTION(method_exists);
 +static ZEND_FUNCTION(property_exists);
  static ZEND_FUNCTION(class_exists);
  static ZEND_FUNCTION(interface_exists);
  static ZEND_FUNCTION(function_exists);
 @@ -102,6 +103,7 @@
   ZEND_FE(get_class,  NULL)




-- 
Best regards,
 Marcusmailto:[EMAIL PROTECTED]

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



Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Andrey Hristov
 Hello Marcus,
ok, I will try to cook up something but this time I won't
be so fast since I have some pending commercial :) stuff.
Andrey
Marcus Boerger wrote:
Hello Andrey,
  somehow i knew someone would ask for that
  how about you writing a patch?
Friday, April 8, 2005, 5:01:24 PM, you wrote:

  Hi Marcus,
what about class_constant_exists(classname, const)
(a bit long function name though)?

Andrey

Marcus Boerger wrote:
helly Fri Apr  8 09:33:17 2005 EDT
 Modified files:  
   /ZendEngine2  zend_builtin_functions.c 
 Log:
 - Add property_exits()
 
http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.262r2=1.263ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.262
ZendEngine2/zend_builtin_functions.c:1.263
--- ZendEngine2/zend_builtin_functions.c:1.262Mon Apr  4 13:23:38 2005
+++ ZendEngine2/zend_builtin_functions.c  Fri Apr  8 09:33:15 2005
@@ -17,7 +17,7 @@
  
+--+
*/

-/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 13:33:15 helly Exp $ */
#include zend.h
#include zend_API.h
@@ -43,6 +43,7 @@
static ZEND_FUNCTION(get_class);
static ZEND_FUNCTION(get_parent_class);
static ZEND_FUNCTION(method_exists);
+static ZEND_FUNCTION(property_exists);
static ZEND_FUNCTION(class_exists);
static ZEND_FUNCTION(interface_exists);
static ZEND_FUNCTION(function_exists);
@@ -102,6 +103,7 @@
 ZEND_FE(get_class,  NULL)



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


[PHP-DEV] Problem with ./configure on peardoc

2005-04-08 Thread colder.ch
Hello!
I was wondering if I could get some help about a problem I have when I 
try to configure the peardoc for livedocs.

the problem seems to be located on the autogenerated file :  
config.status ( line ~146)

here is the log from the ./configure :
***
checking for php... E:/HTTPserver/php/php
checking php version... PHP 5.0.4 (cli) (built: Mar 31 2005 02:45:48)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies ok
checking for openjade... /usr/bin/openjade
checking for onsgmls... /usr/bin/onsgmls
checking for docbook.dsl... autodetected: ../phpdoc/dsssl/docbook
checking for docbook.xsl... autodetected: ../phpdoc/xsl/docbook
checking for language... en
configure: creating ./config.status
config.status: creating \
.infig.status: error: cannot find input file: \
***
As you can see I'm using windows. This problem happens when I simply try 
to make a ./configure --with-php=E:/HTTPserver/php/php --with-lang=en on 
the peardoc/ directory.

This command is called for every languages by build.sh from the 
livedocs directory.

Any help would be really apreciated!
Thanks in advance.
--
colder
http://www.colder.ch/v2
[EMAIL PROTECTED]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Lukas Smith
Andrey Hristov wrote:
  Hi Marcus,
what about class_constant_exists(classname, const)
(a bit long function name though)?
maybe leave of the ant ...
class_const_exists()
fits in with
class MyClass
{
   const constant = 'constant value';
   function showConstant() {
   echo  self::constant . \n;
   }
}
regards,
Lukas
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] [PATCH] fix crash in solaris when fdopen() fails

2005-04-08 Thread Wez Furlong
Yeah, popen is tricky to replace.
A workaround for solaris is to use proc_open() in the scripts instead.
Other extensions that might have issues are those that will accept a
stream to use as a source for data.  Off the top of my head, you'll
want to check the PDFlib and ming extensions.  Actually, you be able
to grep the php source to see where the php_stream_cast function is
called; that'll highlight problem areas pretty easily I should think.

--Wez.

On Apr 8, 2005 10:58 AM, Uwe Schindler [EMAIL PROTECTED] wrote:
 OK - I found out that the fdopen() code is never called in the PHP
 environment, so patch is not needed (PHP sets zend_file_handle always to
 STREAM). But I still want to know for what extensions/functions the casts
 from posix to stdio are needed- Will casting appear somewhere when the user
 calls the userlevel-file-functions starting with fopen()?. It is hard work
 to find out with simple search through CVS.
 The only position I know is because of popen() etc. in the exec functions
 which are stdio (posix variants are more complicated), which is the cause
 for the bug report I mentioned.
 
 At 09:40 07.04.2005, Uwe Schindler wrote:
 I am fixing bug #32614: Problem, on the solaris platform fdopen() can fail
 even if fd is a correct file descriptor, when fd255 (the well-known
 solaris stdio problem). The webserver of the user crashes because the
 return value of fdopen() is not checked for NULL when casting a stream
 from posix to stdio. After this fd==-1 and fp==NULL == further calls to
 fread/fwrite with this fp segfault.
 I committed the patches for PHP but I have no karme for ZendEngine2. Can
 someone with karma submit this patch?
 
 According to this it would be interesting, WHEN some PHP/Zend code tries
 to cast a POSIX stream to stdio? In which extension/functions? Can this be
 fixed to only use posix IO? The zend engine itself should be safe since
 4.3.3 and since PHP5.
 
 Does stream casts apply if a user uses the PHP user functions fopen,
 fread, fwrite? Since Saschas fix in PHP4 there this does not happen. What
 about PHP5?
 
 I would try to fix this everywhere in the future.
 
 -
 Uwe Schindler
 [EMAIL PROTECTED] - http://www.php.net
 NSAPI SAPI developer
 Erlangen, Germany
 
 
 
 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 -
 Uwe Schindler
 [EMAIL PROTECTED] - http://www.php.net
 NSAPI SAPI developer
 Bremen, Germany
 


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



[PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Andi Gutmans
Marcus,
There was a long discussion about this a few months ago.
The conclusion was to use the reflection_api for the very few instances 
where isset() isn't relevant.
Although we have done bad stuff in the past, it's also not a good idea to 
continue polluting the global namespace.
Please revert this patch.
FYI, all the other requests for additional functions like 
class_constant_exists() should also be reflection API. It's best for the 
language.

Thanks,
Andi
At 01:33 PM 4/8/2005 +, Marcus Boerger wrote:
helly   Fri Apr  8 09:33:17 2005 EDT
  Modified files:
/ZendEngine2zend_builtin_functions.c
  Log:
  - Add property_exits()
http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.262r2=1.263ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.262 
ZendEngine2/zend_builtin_functions.c:1.263
--- ZendEngine2/zend_builtin_functions.c:1.262  Mon Apr  4 13:23:38 2005
+++ ZendEngine2/zend_builtin_functions.cFri Apr  8 09:33:15 2005
@@ -17,7 +17,7 @@
+--+
 */

-/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 13:33:15 helly Exp $ */
 #include zend.h
 #include zend_API.h
@@ -43,6 +43,7 @@
 static ZEND_FUNCTION(get_class);
 static ZEND_FUNCTION(get_parent_class);
 static ZEND_FUNCTION(method_exists);
+static ZEND_FUNCTION(property_exists);
 static ZEND_FUNCTION(class_exists);
 static ZEND_FUNCTION(interface_exists);
 static ZEND_FUNCTION(function_exists);
@@ -102,6 +103,7 @@
ZEND_FE(get_class,  NULL)
ZEND_FE(get_parent_class,   NULL)
ZEND_FE(method_exists,  NULL)
+   ZEND_FE(property_exists,NULL)
ZEND_FE(class_exists,   NULL)
ZEND_FE(interface_exists,   NULL)
ZEND_FE(function_exists,NULL)
@@ -889,6 +891,63 @@
 }
 /* }}} */
+/* {{{ proto bool property_exists(mixed object_or_class, string 
property_name)
+   Checks if the object or class has a property */
+ZEND_FUNCTION(property_exists)
+{
+   zval **object, **property;
+   zend_class_entry *ce, **pce;
+   zend_property_info *property_info;
+   char *prop_name, *class_name;
+
+   if (ZEND_NUM_ARGS()!= 2 || zend_get_parameters_ex(2, object, 
property)==FAILURE) {
+   ZEND_WRONG_PARAM_COUNT();
+   }
+   convert_to_string_ex(property);
+
+   switch((*object)-type) {
+   case IS_STRING:
+   if (zend_lookup_class(Z_STRVAL_PP(object), 
Z_STRLEN_PP(object), pce TSRMLS_CC) == SUCCESS) {
+   ce = *pce;
+   }
+   if (!ce) {
+   RETURN_NULL();
+   }
+   if (!(property_info = zend_get_property_info(ce, 
*property, 1 TSRMLS_CC)) || property_info == EG(std_property_info)) {
+   RETURN_FALSE;
+   }
+   if (property_info-flags  ZEND_ACC_PUBLIC) {
+   RETURN_TRUE;
+   }
+   zend_unmangle_property_name(property_info-name, 
class_name, prop_name);
+   if (!strncmp(class_name, *, 1)) {
+   if (instanceof_function(EG(scope), ce TSRMLS_CC)) {
+   RETURN_TRUE;
+   }
+   RETURN_FALSE;
+   }
+   if (zend_lookup_class(Z_STRVAL_PP(object), 
Z_STRLEN_PP(object), pce TSRMLS_CC) == SUCCESS) {
+   ce = *pce;
+   } else {
+   RETURN_FALSE; /* shouldn't happen */
+   }
+   RETURN_BOOL(EG(scope) == ce);
+   RETURN_FALSE;
+
+   case IS_OBJECT:
+   if (Z_OBJ_HANDLER_PP(object, has_property)  
Z_OBJ_HANDLER_PP(object, has_property)(*object, *property, 1 TSRMLS_CC)) {
+   RETURN_TRUE;
+   }
+   RETURN_FALSE;
+
+   default:
+   zend_error(E_WARNING, Parameter must either be an object 
or the name of an existing class);
+   RETURN_NULL();
+   }
+}
+/* }}} */
+
+
 /* {{{ proto bool class_exists(string classname [, bool autoload])
Checks if the class exists */
 ZEND_FUNCTION(class_exists)

--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Problem with ./configure on peardoc

2005-04-08 Thread Nuno Lopes
You should contact the peardoc team instead: [EMAIL PROTECTED]
BTW, livedocs shouldn't work with peardoc correctly, because the indexing 
system is a bit phpdoc specific.

Nuno
- Original Message - 
Hello!
I was wondering if I could get some help about a problem I have when I try 
to configure the peardoc for livedocs.

the problem seems to be located on the autogenerated file :  config.status 
( line ~146)

here is the log from the ./configure :
***
checking for php... E:/HTTPserver/php/php
checking php version... PHP 5.0.4 (cli) (built: Mar 31 2005 02:45:48)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies ok
checking for openjade... /usr/bin/openjade
checking for onsgmls... /usr/bin/onsgmls
checking for docbook.dsl... autodetected: ../phpdoc/dsssl/docbook
checking for docbook.xsl... autodetected: ../phpdoc/xsl/docbook
checking for language... en
configure: creating ./config.status
config.status: creating \
.infig.status: error: cannot find input file: \
***
As you can see I'm using windows. This problem happens when I simply try 
to make a ./configure --with-php=E:/HTTPserver/php/php --with-lang=en on 
the peardoc/ directory.

This command is called for every languages by build.sh from the livedocs 
directory.

Any help would be really apreciated!
Thanks in advance.
--
colder
http://www.colder.ch/v2
[EMAIL PROTECTED] 
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Marcus Boerger
Hello Andi,

  to this i only agree under two conditions. First we remove other like
method_exists() too and second we fix handling of implicit public and
dynamic properties. Unless the second is done i see such a function as
relative important and don't like to use reflection overhead always.

regards
marcus

Friday, April 8, 2005, 6:00:03 PM, you wrote:

 Marcus,

 There was a long discussion about this a few months ago.
 The conclusion was to use the reflection_api for the very few instances 
 where isset() isn't relevant.
 Although we have done bad stuff in the past, it's also not a good idea to 
 continue polluting the global namespace.
 Please revert this patch.
 FYI, all the other requests for additional functions like 
 class_constant_exists() should also be reflection API. It's best for the 
 language.

 Thanks,
 Andi

 At 01:33 PM 4/8/2005 +, Marcus Boerger wrote:
helly   Fri Apr  8 09:33:17 2005 EDT

   Modified files:
 /ZendEngine2zend_builtin_functions.c
   Log:
   - Add property_exits()

http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.262r2=1.263ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.262 
ZendEngine2/zend_builtin_functions.c:1.263
--- ZendEngine2/zend_builtin_functions.c:1.262  Mon Apr  4 13:23:38 2005
+++ ZendEngine2/zend_builtin_functions.cFri Apr  8 09:33:15 2005
@@ -17,7 +17,7 @@

 +--+
  */

-/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 13:33:15 helly Exp $ */

  #include zend.h
  #include zend_API.h
@@ -43,6 +43,7 @@
  static ZEND_FUNCTION(get_class);
  static ZEND_FUNCTION(get_parent_class);
  static ZEND_FUNCTION(method_exists);
+static ZEND_FUNCTION(property_exists);
  static ZEND_FUNCTION(class_exists);
  static ZEND_FUNCTION(interface_exists);
  static ZEND_FUNCTION(function_exists);
@@ -102,6 +103,7 @@
 ZEND_FE(get_class,  NULL)
 ZEND_FE(get_parent_class,   NULL)
 ZEND_FE(method_exists,  NULL)
+   ZEND_FE(property_exists,NULL)
 ZEND_FE(class_exists,   NULL)
 ZEND_FE(interface_exists,   NULL)
 ZEND_FE(function_exists,NULL)
@@ -889,6 +891,63 @@
  }
  /* }}} */

+/* {{{ proto bool property_exists(mixed object_or_class, string 
property_name)
+   Checks if the object or class has a property */
+ZEND_FUNCTION(property_exists)
+{
+   zval **object, **property;
+   zend_class_entry *ce, **pce;
+   zend_property_info *property_info;
+   char *prop_name, *class_name;
+
+   if (ZEND_NUM_ARGS()!= 2 || zend_get_parameters_ex(2, object, 
property)==FAILURE) {
+   ZEND_WRONG_PARAM_COUNT();
+   }
+   convert_to_string_ex(property);
+
+   switch((*object)-type) {
+   case IS_STRING:
+   if (zend_lookup_class(Z_STRVAL_PP(object), 
Z_STRLEN_PP(object), pce TSRMLS_CC) == SUCCESS) {
+   ce = *pce;
+   }
+   if (!ce) {
+   RETURN_NULL();
+   }
+   if (!(property_info = zend_get_property_info(ce, 
*property, 1 TSRMLS_CC)) || property_info == EG(std_property_info)) {
+   RETURN_FALSE;
+   }
+   if (property_info-flags  ZEND_ACC_PUBLIC) {
+   RETURN_TRUE;
+   }
+   zend_unmangle_property_name(property_info-name, 
class_name, prop_name);
+   if (!strncmp(class_name, *, 1)) {
+   if (instanceof_function(EG(scope), ce TSRMLS_CC)) {
+   RETURN_TRUE;
+   }
+   RETURN_FALSE;
+   }
+   if (zend_lookup_class(Z_STRVAL_PP(object), 
Z_STRLEN_PP(object), pce TSRMLS_CC) == SUCCESS) {
+   ce = *pce;
+   } else {
+   RETURN_FALSE; /* shouldn't happen */
+   }
+   RETURN_BOOL(EG(scope) == ce);
+   RETURN_FALSE;
+
+   case IS_OBJECT:
+   if (Z_OBJ_HANDLER_PP(object, has_property)  
Z_OBJ_HANDLER_PP(object, has_property)(*object, *property, 1 TSRMLS_CC)) {
+   RETURN_TRUE;
+   }
+   RETURN_FALSE;
+
+   default:
+   zend_error(E_WARNING, Parameter must either be an object 
or the name of an existing class);
+   RETURN_NULL();
+   }
+}
+/* }}} */
+
+
  /* {{{ proto bool class_exists(string classname [, bool autoload])
 Checks if the class exists */
  ZEND_FUNCTION(class_exists)

--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Best regards,
 Marcusmailto:[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing 

Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Andrey Hristov
  Hello Andi, Marcus,
method_exists() is quite vital to help where the type hinting fail.
Type hinting fail because it leads to a fatal error which is uncatchable
and the code cannot react on this. Therefore, for me type hinting is
kind of useless since I cannot catch my bugs by executing some code whenever
the data passed is not what the function/method expects. Reflection API is
overkill to write everywhere and has to be wrapped to something which at
the end will simulate method_exists().
Thanks for you attention,
Andrey
Marcus Boerger wrote:
Hello Andi,
  to this i only agree under two conditions. First we remove other like
method_exists() too and second we fix handling of implicit public and
dynamic properties. Unless the second is done i see such a function as
relative important and don't like to use reflection overhead always.
regards
marcus
Friday, April 8, 2005, 6:00:03 PM, you wrote:

Marcus,

There was a long discussion about this a few months ago.
The conclusion was to use the reflection_api for the very few instances 
where isset() isn't relevant.
Although we have done bad stuff in the past, it's also not a good idea to 
continue polluting the global namespace.
Please revert this patch.
FYI, all the other requests for additional functions like 
class_constant_exists() should also be reflection API. It's best for the 
language.

Thanks,
Andi

At 01:33 PM 4/8/2005 +, Marcus Boerger wrote:
helly   Fri Apr  8 09:33:17 2005 EDT
 Modified files:
   /ZendEngine2zend_builtin_functions.c
 Log:
 - Add property_exits()
http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.262r2=1.263ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.262 
ZendEngine2/zend_builtin_functions.c:1.263
--- ZendEngine2/zend_builtin_functions.c:1.262  Mon Apr  4 13:23:38 2005
+++ ZendEngine2/zend_builtin_functions.cFri Apr  8 09:33:15 2005
@@ -17,7 +17,7 @@
  
+--+
*/

-/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 13:33:15 helly Exp $ */
#include zend.h
#include zend_API.h
@@ -43,6 +43,7 @@
static ZEND_FUNCTION(get_class);
static ZEND_FUNCTION(get_parent_class);
static ZEND_FUNCTION(method_exists);
+static ZEND_FUNCTION(property_exists);
static ZEND_FUNCTION(class_exists);
static ZEND_FUNCTION(interface_exists);
static ZEND_FUNCTION(function_exists);
@@ -102,6 +103,7 @@
   ZEND_FE(get_class,  NULL)
   ZEND_FE(get_parent_class,   NULL)
   ZEND_FE(method_exists,  NULL)
+   ZEND_FE(property_exists,NULL)
   ZEND_FE(class_exists,   NULL)
   ZEND_FE(interface_exists,   NULL)
   ZEND_FE(function_exists,NULL)
@@ -889,6 +891,63 @@
}
/* }}} */
+/* {{{ proto bool property_exists(mixed object_or_class, string 
property_name)
+   Checks if the object or class has a property */
+ZEND_FUNCTION(property_exists)
+{
+   zval **object, **property;
+   zend_class_entry *ce, **pce;
+   zend_property_info *property_info;
+   char *prop_name, *class_name;
+
+   if (ZEND_NUM_ARGS()!= 2 || zend_get_parameters_ex(2, object, 
property)==FAILURE) {
+   ZEND_WRONG_PARAM_COUNT();
+   }
+   convert_to_string_ex(property);
+
+   switch((*object)-type) {
+   case IS_STRING:
+   if (zend_lookup_class(Z_STRVAL_PP(object), 
Z_STRLEN_PP(object), pce TSRMLS_CC) == SUCCESS) {
+   ce = *pce;
+   }
+   if (!ce) {
+   RETURN_NULL();
+   }
+   if (!(property_info = zend_get_property_info(ce, 
*property, 1 TSRMLS_CC)) || property_info == EG(std_property_info)) {
+   RETURN_FALSE;
+   }
+   if (property_info-flags  ZEND_ACC_PUBLIC) {
+   RETURN_TRUE;
+   }
+   zend_unmangle_property_name(property_info-name, 
class_name, prop_name);
+   if (!strncmp(class_name, *, 1)) {
+   if (instanceof_function(EG(scope), ce TSRMLS_CC)) {
+   RETURN_TRUE;
+   }
+   RETURN_FALSE;
+   }
+   if (zend_lookup_class(Z_STRVAL_PP(object), 
Z_STRLEN_PP(object), pce TSRMLS_CC) == SUCCESS) {
+   ce = *pce;
+   } else {
+   RETURN_FALSE; /* shouldn't happen */
+   }
+   RETURN_BOOL(EG(scope) == ce);
+   RETURN_FALSE;
+
+   case IS_OBJECT:
+   if (Z_OBJ_HANDLER_PP(object, has_property)  
Z_OBJ_HANDLER_PP(object, has_property)(*object, *property, 1 TSRMLS_CC)) {
+   RETURN_TRUE;
+   }
+   RETURN_FALSE;
+
+   default:
+   zend_error(E_WARNING, Parameter must either 

Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Marcus Boerger
Hello Andrey,

  same goes for property_exists() which is why i added it.

marcus

Friday, April 8, 2005, 6:31:48 PM, you wrote:

Hello Andi, Marcus,
 method_exists() is quite vital to help where the type hinting fail.
 Type hinting fail because it leads to a fatal error which is uncatchable
 and the code cannot react on this. Therefore, for me type hinting is
 kind of useless since I cannot catch my bugs by executing some code whenever
 the data passed is not what the function/method expects. Reflection API is
 overkill to write everywhere and has to be wrapped to something which at
 the end will simulate method_exists().

 Thanks for you attention,
 Andrey

 Marcus Boerger wrote:
 Hello Andi,
 
   to this i only agree under two conditions. First we remove other like
 method_exists() too and second we fix handling of implicit public and
 dynamic properties. Unless the second is done i see such a function as
 relative important and don't like to use reflection overhead always.
 
 regards
 marcus
 
 Friday, April 8, 2005, 6:00:03 PM, you wrote:
 
 
Marcus,
 
 
There was a long discussion about this a few months ago.
The conclusion was to use the reflection_api for the very few instances 
where isset() isn't relevant.
Although we have done bad stuff in the past, it's also not a good idea to
continue polluting the global namespace.
Please revert this patch.
FYI, all the other requests for additional functions like 
class_constant_exists() should also be reflection API. It's best for the 
language.
 
 
Thanks,
Andi
 
 
At 01:33 PM 4/8/2005 +, Marcus Boerger wrote:

helly   Fri Apr  8 09:33:17 2005 EDT

  Modified files:
/ZendEngine2zend_builtin_functions.c
  Log:
  - Add property_exits()

http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.262r2=1.263ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.262 
ZendEngine2/zend_builtin_functions.c:1.263
--- ZendEngine2/zend_builtin_functions.c:1.262  Mon Apr  4 13:23:38 2005
+++ ZendEngine2/zend_builtin_functions.cFri Apr  8 09:33:15 2005
@@ -17,7 +17,7 @@
   
+--+
 */

-/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 13:33:15 helly Exp $ */

 #include zend.h
 #include zend_API.h
@@ -43,6 +43,7 @@
 static ZEND_FUNCTION(get_class);
 static ZEND_FUNCTION(get_parent_class);
 static ZEND_FUNCTION(method_exists);
+static ZEND_FUNCTION(property_exists);
 static ZEND_FUNCTION(class_exists);
 static ZEND_FUNCTION(interface_exists);
 static ZEND_FUNCTION(function_exists);
@@ -102,6 +103,7 @@
ZEND_FE(get_class,  NULL)
ZEND_FE(get_parent_class,   NULL)
ZEND_FE(method_exists,  NULL)
+   ZEND_FE(property_exists,NULL)
ZEND_FE(class_exists,   NULL)
ZEND_FE(interface_exists,   NULL)
ZEND_FE(function_exists,NULL)
@@ -889,6 +891,63 @@
 }
 /* }}} */

+/* {{{ proto bool property_exists(mixed object_or_class, string 
property_name)
+   Checks if the object or class has a property */
+ZEND_FUNCTION(property_exists)
+{
+   zval **object, **property;
+   zend_class_entry *ce, **pce;
+   zend_property_info *property_info;
+   char *prop_name, *class_name;
+
+   if (ZEND_NUM_ARGS()!= 2 || zend_get_parameters_ex(2, object, 
property)==FAILURE) {
+   ZEND_WRONG_PARAM_COUNT();
+   }
+   convert_to_string_ex(property);
+
+   switch((*object)-type) {
+   case IS_STRING:
+   if (zend_lookup_class(Z_STRVAL_PP(object), 
Z_STRLEN_PP(object), pce TSRMLS_CC) == SUCCESS) {
+   ce = *pce;
+   }
+   if (!ce) {
+   RETURN_NULL();
+   }
+   if (!(property_info = zend_get_property_info(ce, 
*property, 1 TSRMLS_CC)) || property_info == EG(std_property_info)) {
+   RETURN_FALSE;
+   }
+   if (property_info-flags  ZEND_ACC_PUBLIC) {
+   RETURN_TRUE;
+   }
+   zend_unmangle_property_name(property_info-name, 
class_name, prop_name);
+   if (!strncmp(class_name, *, 1)) {
+   if (instanceof_function(EG(scope), ce TSRMLS_CC)) {
+   RETURN_TRUE;
+   }
+   RETURN_FALSE;
+   }
+   if (zend_lookup_class(Z_STRVAL_PP(object), 
Z_STRLEN_PP(object), pce TSRMLS_CC) == SUCCESS) {
+   ce = *pce;
+   } else {
+   RETURN_FALSE; /* shouldn't happen */
+   }
+   RETURN_BOOL(EG(scope) == ce);
+   RETURN_FALSE;
+
+   case IS_OBJECT:
+   if (Z_OBJ_HANDLER_PP(object, has_property)  
Z_OBJ_HANDLER_PP(object, 

[PHP-DEV] Stacktrace on fatal error (inspired my property_exists() discussion)

2005-04-08 Thread Andrey Hristov
 Hi all,
since long time ago I feel like disabled when a complex script dies
with a fatal error, for example call on sth which is not an object and
the only thing I get in the error log is the line it has happened. Without
any logging facility running all the time and logging megabytes of data,
most of the time unneeded, I can find the execution trace of the code.
  My wish is to have, whenever possible, the stack trace dumped to the error
log, if a fatal error occurs. An ini option would be something good to
control that. Ah, yes, all that Java web apps that crash and show their
stack trace are ugly - the web user does not need to see the stack trace
thus the right place for it is the PHP error log.
Thanks for you attention and I hope someone from the guys who have knowledge
of the engine inner workings will volunteer some time to make the life of
the people easier.
andrey
P.S.
The idea is to catch problems not only in development, where a debugger may
help, but also on live machines (where bugs also creep and occur).
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Andi Gutmans
At 06:14 PM 4/8/2005 +0200, Marcus Boerger wrote:
Hello Andi,
  to this i only agree under two conditions. First we remove other like
method_exists() too and second we fix handling of implicit public and
dynamic properties. Unless the second is done i see such a function as
relative important and don't like to use reflection overhead always.
Marcus,
What are you talking about? The fact that method_exists() for past reasons 
means we should not think of coding standards anymore? The point in time 
when we decided on internals@ to work in a certain way was looking forward. 
We didn't start breaking BC and removing lots of non-compliant code and 
function names (as you know there are many of those in PHP). So BC is an 
issue and thus, method_exists() won't be removed.
Secondly, for the few instances that someone requires property_exists() I 
don't see any reason not to use reflection API.

I don't even understand your second condition. I don't see why we have to 
work with setting conditions.
Andi

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


Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Andi Gutmans
At 06:31 PM 4/8/2005 +0200, Andrey Hristov wrote:
  Hello Andi, Marcus,
method_exists() is quite vital to help where the type hinting fail.
Type hinting fail because it leads to a fatal error which is uncatchable
and the code cannot react on this. Therefore, for me type hinting is
kind of useless since I cannot catch my bugs by executing some code whenever
the data passed is not what the function/method expects. Reflection API is
overkill to write everywhere and has to be wrapped to something which at
the end will simulate method_exists().
a) I was never talking about removing method_exists() due to BC.
b) If you want a function like this, and really can't live with reflection 
API (which is BS because you can write your own method_exists() in PHP), 
then we should pick a new naming similar to debug_*, mysql_* to put these 
functions in. I don't think we should keep on working against coding 
standards unless there's an exceptional reason.
c) We discussed this in the past and agreed to using reflection API so I 
don't understand where this commit is even coming from.

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


Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Andi Gutmans
It's vital? Come on, you can convince me that it's nice to have, sure. But 
vital? What can it do which you can do with reflection API? If the name is 
sexier than you can write your own PHP function.

At 06:36 PM 4/8/2005 +0200, Marcus Boerger wrote:
Hello Andrey,
  same goes for property_exists() which is why i added it.
marcus
Friday, April 8, 2005, 6:31:48 PM, you wrote:
Hello Andi, Marcus,
 method_exists() is quite vital to help where the type hinting fail.
 Type hinting fail because it leads to a fatal error which is uncatchable
 and the code cannot react on this. Therefore, for me type hinting is
 kind of useless since I cannot catch my bugs by executing some code 
whenever
 the data passed is not what the function/method expects. Reflection API is
 overkill to write everywhere and has to be wrapped to something which at
 the end will simulate method_exists().

 Thanks for you attention,
 Andrey
 Marcus Boerger wrote:
 Hello Andi,

   to this i only agree under two conditions. First we remove other like
 method_exists() too and second we fix handling of implicit public and
 dynamic properties. Unless the second is done i see such a function as
 relative important and don't like to use reflection overhead always.

 regards
 marcus

 Friday, April 8, 2005, 6:00:03 PM, you wrote:


Marcus,


There was a long discussion about this a few months ago.
The conclusion was to use the reflection_api for the very few instances
where isset() isn't relevant.
Although we have done bad stuff in the past, it's also not a good idea to
continue polluting the global namespace.
Please revert this patch.
FYI, all the other requests for additional functions like
class_constant_exists() should also be reflection API. It's best for the
language.


Thanks,
Andi


At 01:33 PM 4/8/2005 +, Marcus Boerger wrote:

helly   Fri Apr  8 09:33:17 2005 EDT

  Modified files:
/ZendEngine2zend_builtin_functions.c
  Log:
  - Add property_exits()

http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1. 
262r2=1.263ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.262
ZendEngine2/zend_builtin_functions.c:1.263
--- ZendEngine2/zend_builtin_functions.c:1.262  Mon Apr  4 13:23:38 2005
+++ ZendEngine2/zend_builtin_functions.cFri Apr  8 09:33:15 2005
@@ -17,7 +17,7 @@

+--+
 */

-/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas 
Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 13:33:15 helly 
Exp $ */

 #include zend.h
 #include zend_API.h
@@ -43,6 +43,7 @@
 static ZEND_FUNCTION(get_class);
 static ZEND_FUNCTION(get_parent_class);
 static ZEND_FUNCTION(method_exists);
+static ZEND_FUNCTION(property_exists);
 static ZEND_FUNCTION(class_exists);
 static ZEND_FUNCTION(interface_exists);
 static ZEND_FUNCTION(function_exists);
@@ -102,6 +103,7 @@
ZEND_FE(get_class,  NULL)
ZEND_FE(get_parent_class,   NULL)
ZEND_FE(method_exists,  NULL)
+   ZEND_FE(property_exists,NULL)
ZEND_FE(class_exists,   NULL)
ZEND_FE(interface_exists,   NULL)
ZEND_FE(function_exists,NULL)
@@ -889,6 +891,63 @@
 }
 /* }}} */

+/* {{{ proto bool property_exists(mixed object_or_class, string
property_name)
+   Checks if the object or class has a property */
+ZEND_FUNCTION(property_exists)
+{
+   zval **object, **property;
+   zend_class_entry *ce, **pce;
+   zend_property_info *property_info;
+   char *prop_name, *class_name;
+
+   if (ZEND_NUM_ARGS()!= 2 || zend_get_parameters_ex(2, object,
property)==FAILURE) {
+   ZEND_WRONG_PARAM_COUNT();
+   }
+   convert_to_string_ex(property);
+
+   switch((*object)-type) {
+   case IS_STRING:
+   if (zend_lookup_class(Z_STRVAL_PP(object),
Z_STRLEN_PP(object), pce TSRMLS_CC) == SUCCESS) {
+   ce = *pce;
+   }
+   if (!ce) {
+   RETURN_NULL();
+   }
+   if (!(property_info = zend_get_property_info(ce,
*property, 1 TSRMLS_CC)) || property_info == EG(std_property_info)) {
+   RETURN_FALSE;
+   }
+   if (property_info-flags  ZEND_ACC_PUBLIC) {
+   RETURN_TRUE;
+   }
+   zend_unmangle_property_name(property_info-name,
class_name, prop_name);
+   if (!strncmp(class_name, *, 1)) {
+   if (instanceof_function(EG(scope), ce 
TSRMLS_CC)) {
+   RETURN_TRUE;
+   }
+   RETURN_FALSE;
+   }
+   if (zend_lookup_class(Z_STRVAL_PP(object),
Z_STRLEN_PP(object), pce TSRMLS_CC) == SUCCESS) {
+   ce = *pce;
+   } else {
+   RETURN_FALSE; /* shouldn't happen 

Re: [PHP-DEV] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Andrey Hristov
 Hi Andi,
I am not a Refl API guru, but for the simple check of method_exists()
one has to create one object and then iterate a result set. The other
solution is get_class_methods() which again returns an array which
has to be used only once - let's say with in_array(). in_array() is
a bit slow because no hashing is used. What can be optimized is doing
some caching in the memory but then the memory usage grows and grows.
And a simple solution like method_exists() gives the answer directly.
No complications to iterate over an array returned by reflection api
or get_class_methods() and no additional memory allocated over and over
and later probably cleaned by the gc.
Why I am concerned about speed and memory usage? Since I may call
method_exists() hundreds of times per script call and this will be a burden
with a user-space solution.
This is my POV.
Andrey
P.S.
I have changed a bit the topic since my mail filter is not that smart :)
Andi Gutmans wrote:
It's vital? Come on, you can convince me that it's nice to have, sure. 
But vital? What can it do which you can do with reflection API? If the 
name is sexier than you can write your own PHP function.

At 06:36 PM 4/8/2005 +0200, Marcus Boerger wrote:
Hello Andrey,
  same goes for property_exists() which is why i added it.
marcus
Friday, April 8, 2005, 6:31:48 PM, you wrote:
Hello Andi, Marcus,
 method_exists() is quite vital to help where the type hinting fail.
 Type hinting fail because it leads to a fatal error which is 
uncatchable
 and the code cannot react on this. Therefore, for me type hinting is
 kind of useless since I cannot catch my bugs by executing some code 
whenever
 the data passed is not what the function/method expects. Reflection 
API is
 overkill to write everywhere and has to be wrapped to something 
which at
 the end will simulate method_exists().

 Thanks for you attention,
 Andrey
 Marcus Boerger wrote:
 Hello Andi,

   to this i only agree under two conditions. First we remove other 
like
 method_exists() too and second we fix handling of implicit public and
 dynamic properties. Unless the second is done i see such a function as
 relative important and don't like to use reflection overhead always.

 regards
 marcus

 Friday, April 8, 2005, 6:00:03 PM, you wrote:


Marcus,


There was a long discussion about this a few months ago.
The conclusion was to use the reflection_api for the very few 
instances
where isset() isn't relevant.
Although we have done bad stuff in the past, it's also not a good 
idea to
continue polluting the global namespace.
Please revert this patch.
FYI, all the other requests for additional functions like
class_constant_exists() should also be reflection API. It's best 
for the
language.


Thanks,
Andi


At 01:33 PM 4/8/2005 +, Marcus Boerger wrote:

helly   Fri Apr  8 09:33:17 2005 EDT

  Modified files:
/ZendEngine2zend_builtin_functions.c
  Log:
  - Add property_exits()

http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1. 
262r2=1.263ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.262
ZendEngine2/zend_builtin_functions.c:1.263
--- ZendEngine2/zend_builtin_functions.c:1.262  Mon Apr  4 
13:23:38 2005
+++ ZendEngine2/zend_builtin_functions.cFri Apr  8 
09:33:15 2005
@@ -17,7 +17,7 @@

+--+ 

 */

-/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas 
Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 13:33:15 
helly Exp $ */

 #include zend.h
 #include zend_API.h
@@ -43,6 +43,7 @@
 static ZEND_FUNCTION(get_class);
 static ZEND_FUNCTION(get_parent_class);
 static ZEND_FUNCTION(method_exists);
+static ZEND_FUNCTION(property_exists);
 static ZEND_FUNCTION(class_exists);
 static ZEND_FUNCTION(interface_exists);
 static ZEND_FUNCTION(function_exists);
@@ -102,6 +103,7 @@
ZEND_FE(get_class,  NULL)
ZEND_FE(get_parent_class,   NULL)
ZEND_FE(method_exists,  NULL)
+   ZEND_FE(property_exists,NULL)
ZEND_FE(class_exists,   NULL)
ZEND_FE(interface_exists,   NULL)
ZEND_FE(function_exists,NULL)
@@ -889,6 +891,63 @@
 }
 /* }}} */

+/* {{{ proto bool property_exists(mixed object_or_class, string
property_name)
+   Checks if the object or class has a property */
+ZEND_FUNCTION(property_exists)
+{
+   zval **object, **property;
+   zend_class_entry *ce, **pce;
+   zend_property_info *property_info;
+   char *prop_name, *class_name;
+
+   if (ZEND_NUM_ARGS()!= 2 || zend_get_parameters_ex(2, object,
property)==FAILURE) {
+   ZEND_WRONG_PARAM_COUNT();
+   }
+   convert_to_string_ex(property);
+
+   switch((*object)-type) {
+   case IS_STRING:
+   if (zend_lookup_class(Z_STRVAL_PP(object),
Z_STRLEN_PP(object), pce TSRMLS_CC) == SUCCESS) {
+   ce = *pce;

Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Marcus Boerger
Hello Andi,

  erm yes i could put it to spl as a convenience function prefixed by 'spl_'
and we could also add a namespace for class functions 'class_' or one for
the reflection api (whatever that might be) or we could put those as static
methods into class 'Reflection'. However all of these makee it harder since
having 'class_exists', 'function_exists', 'method_exists' simply screems for
having 'property_exists' also. Why must we always make php so hard by
preventing not to have it consitent? I know the 'global namespace' argument.
But like many other things it is to late to enforce that rule...many years
to late. And don't ask me about consts. They were wrong right from the
beginning. we should have read only proeprties instead and be done.

marcus

Friday, April 8, 2005, 6:53:33 PM, you wrote:

 It's vital? Come on, you can convince me that it's nice to have, sure. But
 vital? What can it do which you can do with reflection API? If the name is
 sexier than you can write your own PHP function.

 At 06:36 PM 4/8/2005 +0200, Marcus Boerger wrote:
Hello Andrey,

   same goes for property_exists() which is why i added it.

marcus

Friday, April 8, 2005, 6:31:48 PM, you wrote:

 Hello Andi, Marcus,
  method_exists() is quite vital to help where the type hinting fail.
  Type hinting fail because it leads to a fatal error which is uncatchable
  and the code cannot react on this. Therefore, for me type hinting is
  kind of useless since I cannot catch my bugs by executing some code 
 whenever
  the data passed is not what the function/method expects. Reflection API is
  overkill to write everywhere and has to be wrapped to something which at
  the end will simulate method_exists().

  Thanks for you attention,
  Andrey

  Marcus Boerger wrote:
  Hello Andi,
 
to this i only agree under two conditions. First we remove other like
  method_exists() too and second we fix handling of implicit public and
  dynamic properties. Unless the second is done i see such a function as
  relative important and don't like to use reflection overhead always.
 
  regards
  marcus
 
  Friday, April 8, 2005, 6:00:03 PM, you wrote:
 
 
 Marcus,
 
 
 There was a long discussion about this a few months ago.
 The conclusion was to use the reflection_api for the very few instances
 where isset() isn't relevant.
 Although we have done bad stuff in the past, it's also not a good idea to
 continue polluting the global namespace.
 Please revert this patch.
 FYI, all the other requests for additional functions like
 class_constant_exists() should also be reflection API. It's best for the
 language.
 
 
 Thanks,
 Andi
 
 
 At 01:33 PM 4/8/2005 +, Marcus Boerger wrote:
 
 helly   Fri Apr  8 09:33:17 2005 EDT
 
   Modified files:
 /ZendEngine2zend_builtin_functions.c
   Log:
   - Add property_exits()
 
 http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.
 262r2=1.263ty=u
 Index: ZendEngine2/zend_builtin_functions.c
 diff -u ZendEngine2/zend_builtin_functions.c:1.262
 ZendEngine2/zend_builtin_functions.c:1.263
 --- ZendEngine2/zend_builtin_functions.c:1.262  Mon Apr  4 13:23:38 2005
 +++ ZendEngine2/zend_builtin_functions.cFri Apr  8 09:33:15 2005
 @@ -17,7 +17,7 @@
 
 +--+
  */
 
 -/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas 
 Exp $ */
 +/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 13:33:15 helly 
 Exp $ */
 
  #include zend.h
  #include zend_API.h
 @@ -43,6 +43,7 @@
  static ZEND_FUNCTION(get_class);
  static ZEND_FUNCTION(get_parent_class);
  static ZEND_FUNCTION(method_exists);
 +static ZEND_FUNCTION(property_exists);

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



Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Andi Gutmans
Marcus,
PHP is being used by millions of people and it is irrelevant whether you 
think that const was wrong from the beginning or not, because we won't fix 
something which has been around probably since 1995. Restating that over 
and over is not productive as we should support what has been around for a 
long time. And mind you, PHP is quite useful the way it is.
Talking about making PHP hard, a lot of the OOP things you are pushing are 
doing exactly that, and will result in PHP to loose it's ease of use. A lot 
of the SPL stuff takes this approach and goes very far into the Java-realm 
which is precisely why so many ppl left Java for PHP in the first place. 
Simplicity. We don't have to and shouldn't overcomplicate things.
Now property_exists() doesn't fall into that category and isn't quite 
related. Frankly, I couldn't care too much about it except for the fact 
that I know there will be other *_exists() after that and we should follow 
our rules and try to work by our rules for new things. If every time, we 
asked someone to follow the new rules would point at all the past wrong 
doings then we wouldn't get anywhere. Everyone who has been involved on PHP 
development for a long time knows exactly where it came from and why/when 
we decided to be more structured. The decision to preserve BC doesn't mean 
we have to create new stuff in the spirit of old. And we're talking about a 
function which the millions of PHP servers have done without forever.

Andi
At 07:15 PM 4/8/2005 +0200, Marcus Boerger wrote:
Hello Andi,
  erm yes i could put it to spl as a convenience function prefixed by 'spl_'
and we could also add a namespace for class functions 'class_' or one for
the reflection api (whatever that might be) or we could put those as static
methods into class 'Reflection'. However all of these makee it harder since
having 'class_exists', 'function_exists', 'method_exists' simply screems for
having 'property_exists' also. Why must we always make php so hard by
preventing not to have it consitent? I know the 'global namespace' argument.
But like many other things it is to late to enforce that rule...many years
to late. And don't ask me about consts. They were wrong right from the
beginning. we should have read only proeprties instead and be done.
marcus
Friday, April 8, 2005, 6:53:33 PM, you wrote:
 It's vital? Come on, you can convince me that it's nice to have, sure. But
 vital? What can it do which you can do with reflection API? If the name is
 sexier than you can write your own PHP function.
 At 06:36 PM 4/8/2005 +0200, Marcus Boerger wrote:
Hello Andrey,

   same goes for property_exists() which is why i added it.

marcus

Friday, April 8, 2005, 6:31:48 PM, you wrote:

 Hello Andi, Marcus,
  method_exists() is quite vital to help where the type hinting fail.
  Type hinting fail because it leads to a fatal error which is uncatchable
  and the code cannot react on this. Therefore, for me type hinting is
  kind of useless since I cannot catch my bugs by executing some code
 whenever
  the data passed is not what the function/method expects. Reflection 
API is
  overkill to write everywhere and has to be wrapped to something which at
  the end will simulate method_exists().

  Thanks for you attention,
  Andrey

  Marcus Boerger wrote:
  Hello Andi,
 
to this i only agree under two conditions. First we remove other like
  method_exists() too and second we fix handling of implicit public and
  dynamic properties. Unless the second is done i see such a function as
  relative important and don't like to use reflection overhead always.
 
  regards
  marcus
 
  Friday, April 8, 2005, 6:00:03 PM, you wrote:
 
 
 Marcus,
 
 
 There was a long discussion about this a few months ago.
 The conclusion was to use the reflection_api for the very few instances
 where isset() isn't relevant.
 Although we have done bad stuff in the past, it's also not a good 
idea to
 continue polluting the global namespace.
 Please revert this patch.
 FYI, all the other requests for additional functions like
 class_constant_exists() should also be reflection API. It's best 
for the
 language.
 
 
 Thanks,
 Andi
 
 
 At 01:33 PM 4/8/2005 +, Marcus Boerger wrote:
 
 helly   Fri Apr  8 09:33:17 2005 EDT
 
   Modified files:
 /ZendEngine2zend_builtin_functions.c
   Log:
   - Add property_exits()
 
 http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.
 262r2=1.263ty=u
 Index: ZendEngine2/zend_builtin_functions.c
 diff -u ZendEngine2/zend_builtin_functions.c:1.262
 ZendEngine2/zend_builtin_functions.c:1.263
 --- ZendEngine2/zend_builtin_functions.c:1.262  Mon Apr  4 
13:23:38 2005
 +++ ZendEngine2/zend_builtin_functions.cFri Apr  8 
09:33:15 2005
 @@ -17,7 +17,7 @@
 
 +-- 
+
  */
 
 -/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas
 Exp $ */
 +/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 

Re: [PHP-DEV] [PATCH] fix crash in solaris when fdopen() fails

2005-04-08 Thread Andi Gutmans
Not sure. Wez or Sara know that part of the code best.
I'll refrain from applying to the Zend Engine then or should I apply that 
patch anyway? It seems quite harmless either way...

Andi
At 04:58 PM 4/8/2005 +0200, Uwe Schindler wrote:
OK - I found out that the fdopen() code is never called in the PHP 
environment, so patch is not needed (PHP sets zend_file_handle always to 
STREAM). But I still want to know for what extensions/functions the casts 
from posix to stdio are needed- Will casting appear somewhere when the 
user calls the userlevel-file-functions starting with fopen()?. It is hard 
work to find out with simple search through CVS.
The only position I know is because of popen() etc. in the exec functions 
which are stdio (posix variants are more complicated), which is the cause 
for the bug report I mentioned.

At 09:40 07.04.2005, Uwe Schindler wrote:
I am fixing bug #32614: Problem, on the solaris platform fdopen() can 
fail even if fd is a correct file descriptor, when fd255 (the well-known 
solaris stdio problem). The webserver of the user crashes because the 
return value of fdopen() is not checked for NULL when casting a stream 
from posix to stdio. After this fd==-1 and fp==NULL == further calls to 
fread/fwrite with this fp segfault.
I committed the patches for PHP but I have no karme for ZendEngine2. 
Can someone with karma submit this patch?

According to this it would be interesting, WHEN some PHP/Zend code tries 
to cast a POSIX stream to stdio? In which extension/functions? Can this 
be fixed to only use posix IO? The zend engine itself should be safe 
since 4.3.3 and since PHP5.

Does stream casts apply if a user uses the PHP user functions fopen, 
fread, fwrite? Since Saschas fix in PHP4 there this does not happen. What 
about PHP5?

I would try to fix this everywhere in the future.
-
Uwe Schindler
[EMAIL PROTECTED] - http://www.php.net
NSAPI SAPI developer
Erlangen, Germany

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
-
Uwe Schindler
[EMAIL PROTECTED] - http://www.php.net
NSAPI SAPI developer
Bremen, Germany
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Andi Gutmans
Guess what. I've already cooked it up for you! (OK so I didn't write the 
code but...)

/* {{{ proto public bool ReflectionClass::hasConstant(string name)
   Returns wether a constant exists or not */
Now if it really is too much for you to write then with 4 lines of code you 
can create your own class_constant_exists(classname, const) function 
and prepend it and never worry about not having it again.

On a more serious note, sorry for being sarcastic, but I really don't think 
we need to add yet another _exists() function for something which is easily 
done.

Andi
At 05:12 PM 4/8/2005 +0200, Andrey Hristov wrote:
 Hello Marcus,
ok, I will try to cook up something but this time I won't
be so fast since I have some pending commercial :) stuff.
Andrey
Marcus Boerger wrote:
Hello Andrey,
  somehow i knew someone would ask for that
  how about you writing a patch?
Friday, April 8, 2005, 5:01:24 PM, you wrote:
  Hi Marcus,
what about class_constant_exists(classname, const)
(a bit long function name though)?

Andrey

Marcus Boerger wrote:
helly Fri Apr  8 09:33:17 2005 EDT
 Modified files:
   /ZendEngine2  zend_builtin_functions.c  Log:
 - Add property_exits()
http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.262r2=1.263ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.262
ZendEngine2/zend_builtin_functions.c:1.263
--- ZendEngine2/zend_builtin_functions.c:1.262Mon Apr  4 
13:23:38 2005
+++ ZendEngine2/zend_builtin_functions.c  Fri Apr  8 09:33:15 2005
@@ -17,7 +17,7 @@

+--+
*/
-/* $Id: zend_builtin_functions.c,v 1.262 2005/04/04 17:23:38 stas Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.263 2005/04/08 13:33:15 helly Exp 
$ */
#include zend.h
#include zend_API.h
@@ -43,6 +43,7 @@
static ZEND_FUNCTION(get_class);
static ZEND_FUNCTION(get_parent_class);
static ZEND_FUNCTION(method_exists);
+static ZEND_FUNCTION(property_exists);
static ZEND_FUNCTION(class_exists);
static ZEND_FUNCTION(interface_exists);
static ZEND_FUNCTION(function_exists);
@@ -102,6 +103,7 @@
 ZEND_FE(get_class,  NULL)

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


Re: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

2005-04-08 Thread Marcus Boerger
Hello Andi,

Saturday, April 9, 2005, 1:10:12 AM, you wrote:

 Marcus,

 PHP is being used by millions of people and it is irrelevant whether you 
 think that const was wrong from the beginning or not, because we won't fix
 something which has been around probably since 1995. Restating that over 
 and over is not productive as we should support what has been around for a
 long time. And mind you, PHP is quite useful the way it is.

This was about const which was introduced by sterling in 2004 iirc.

[...]
 Andi

 At 07:15 PM 4/8/2005 +0200, Marcus Boerger wrote:
Hello Andi,

   erm yes i could put it to spl as a convenience function prefixed by 'spl_'
and we could also add a namespace for class functions 'class_' or one for
the reflection api (whatever that might be) or we could put those as static
methods into class 'Reflection'. However all of these makee it harder since
having 'class_exists', 'function_exists', 'method_exists' simply screems for
having 'property_exists' also. Why must we always make php so hard by
preventing not to have it consitent? I know the 'global namespace' argument.
But like many other things it is to late to enforce that rule...many years
to late. And don't ask me about consts. They were wrong right from the
beginning. we should have read only proeprties instead and be done.

[...]

marcus

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



Re: [PHP-DEV] Re: os x linking issue with extension

2005-04-08 Thread Justin Hannus
FYI: I've posted this topic to the php.pecl.dev list. You should reply 
there, it may be more constructive.
--

Try compiling a your extension as a shared object and loading that into 
PHP with the dl() function. This way you can narrow down where the 
problem is coming from with the linker without the added confusion of 
the PHP build system. Once you figure that out you can go back to the 
config.m4 and add whatever you need. An example of these command lines 
(on OSX) would be:

$ gcc -fPIC -Wall -g -DCOMPILE_DL_CARBONAE -Iphpsrc \
-Iphpsrc/main -Iphpsrc/regex -Iphpsrc/Zend \
-Iphpsrc/TSRM -c -o carbonae.o carbonae.c
$ cc -bundle -flat_namespace -undefined suppress \
-framework Carbon -o carbonae.so carbonae.o
Just add the needed frameworks with the -framework switch and make sure 
that COMPILE_DL_CARBONAE in your extension, if defined, will enable a 
line something like:

#if COMPILE_DL_CARBONAE
ZEND_GET_MODULE(carbonae)
#endif
This is done for you with ext_skel or Pecl::Gen, assuming the name of 
your extension is carbonae.

-Justin
Michael Johnston wrote:
Hi,
The config is:
PHP_ARG_WITH(carbonae, for carbonae support,
[  --with-carbonae Include Carbon Apple Events support])
if test $PHP_CARBONAE != no; then
  if test `(uname) 2/dev/null` != Darwin; then
AC_MSG_ERROR([--with-carbonae can only be used on Mac OS X systems.])
  fi
  PHP_ADD_FRAMEWORK(Carbon)
  PHP_ADD_FRAMEWORK(CoreFoundation)
  PHP_ADD_FRAMEWORK(CoreServices)
  PHP_ADD_FRAMEWORK(ApplicationServices)
  PHP_NEW_EXTENSION(carbonae, carbonae.c, $ext_shared)
fi
This extension so far just has a simple function that makes a CFString 
to verify that carbon is getting loaded. The extension builds and loads, 
but when calling the function I get a symbol not found error from the 
dynamic linker.

I want to wrap the Apple Event API, as the first part of porting 
appscript (http://freespace.virgin.net/hamish.sanderson/appscript.html), 
which is a python module that allows you to script applications as you 
would with applescript. Combined with PHPOSA, php would then become a 
scripting language for os x, that can be used to control applications. I 
am doing this because as a web developer I am quite familiar with php as 
a language, and I am. utterly. sick. of applescript. as a language.  
(but I have to use it quite a lot for automating QuarkXPress workflow)

Cheers,
Michael Johnston
On 5-Apr-05, at 3:35 AM, Justin Hannus wrote:
Can you post a link to your config.m4?
PHP_ADD_FRAMEWORK(Framework) should do the trick. Try having a look at 
the config.m4 for the OpenDirectory extension. It links to the 
DirectoryService framework. 
http://pecl.php.net/get/opendirectory-0.2.6.tgz

Curious, what specific part of Carbon are you wrapping. Sounds 
interesting.

-Justin
Michael Johnston wrote:
(I'm not sure if extension development belongs on this list, but I 
couldn't find a better one. If there is a more appropriate list, 
could someone please point me to it?)
I am working on an extension that is os x specific  relies on Carbon 
 ApplicationServices (it is a port of appscript, to allow writing 
applescript applications in php).
I used ext_skel to create an extension, and ran phpize. In the 
config.m4, I put:
  PHP_ADD_FRAMEWORK(Carbon)
  PHP_ADD_INCLUDE(/Developer/Headers/FlatCarbon)
but when I attempt to use carbon api I get an undefined symbol error 
from the dynamic linker.
looking at the configure script generated by phpize, it seemed to me 
that the PHP_ADD_FRAMEWORK macro is not actually being used to affect 
the build. I attempted to change this by manually editing the 
configure script to add $PHP_FRAMEWORKS to the arguments passed to 
linktool mode=link, and added   PHP_VAR_SUBST=$PHP_FRAMEWORKS. 
Using make --debug, I verified that linktool mode=link was now being 
called with the -framework param, but I still get the same undefined 
symbol error.
I don't know much about how the dynamic linker works. What do I need 
to do to have extension .so link to carbon?
I am using the 5.0.3 release source package of php, os x 10.3.8, gcc 3.3
Michael Johnston

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