[PHP-DEV] [PATCH] Output control

2002-02-13 Thread Yasuo Ohgaki

Current output control code have some problems. This patch solves some.

1) ob_end_clean/ob_end_flush destory buffer that is not supposed to.
Deleteting output compression does not make sense once output is
started. (Additional checks)
2) Memory leak, crash when deleting output buffer when nesting
level is 0. (Additional checks)
3) User has no way to know which buffer is deleted by ob_end_*()
functions. (ob_get_status())
4) User has no way to know buffer functions are executed correctly
or not. (ob_*() functions return bool)
5) User has no way to know status of buffers. (ob_get_status())

TODO for output control.
  - Implicit flush is not working. Need more work to make
implicit flush actually work with nested buffers...
  - Fix crash with user defined (PHP script) output handler.

Any comment is appreciated :)

PS: Session patch, I've posted here, is also includeed in
this patch. It fixes verious session problems.

-- 
Yasuo Ohgaki


? ext/standard/Makefile.frag
? ext/session/tmp.diff
? ext/session/bak
Index: main/output.c
===
RCS file: /repository/php4/main/output.c,v
retrieving revision 1.84
diff -u -r1.84 output.c
--- main/output.c   7 Feb 2002 02:50:28 -   1.84
+++ main/output.c   13 Feb 2002 08:41:58 -
@@ -29,7 +29,7 @@
 static int php_ub_body_write_no_header(const char *str, uint str_length TSRMLS_DC);
 static int php_b_body_write(const char *str, uint str_length TSRMLS_DC);
 
-static void php_ob_init(uint initial_size, uint block_size, zval *output_handler, 
uint chunk_size TSRMLS_DC);
+static void php_ob_init(uint initial_size, uint block_size, zval *output_handler, 
+uint chunk_size, zend_bool erase TSRMLS_DC);
 static void php_ob_append(const char *text, uint text_length TSRMLS_DC);
 #if 0
 static void php_ob_prepend(const char *text, uint text_length);
@@ -110,15 +110,15 @@
 
 /* {{{ php_start_ob_buffer
  * Start output buffering */
-PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size TSRMLS_DC)
+PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size, zend_bool erase 
+TSRMLS_DC)
 {
if (OG(ob_lock)) {
return FAILURE;
}
if (chunk_size) {
-   php_ob_init((chunk_size*3/2), chunk_size/2, output_handler, chunk_size 
TSRMLS_CC);
+   php_ob_init((chunk_size*3/2), chunk_size/2, output_handler, 
+chunk_size, erase TSRMLS_CC);
} else {
-   php_ob_init(40*1024, 10*1024, output_handler, chunk_size TSRMLS_CC);
+   php_ob_init(40*1024, 10*1024, output_handler, chunk_size, erase 
+TSRMLS_CC);
}
OG(php_body_write) = php_b_body_write;
return SUCCESS;
@@ -185,6 +185,7 @@
orig_buffer-refcount-=2;
}
zval_ptr_dtor(z_status);
+   zval_ptr_dtor(OG(active_ob_buffer).output_handler);
}
 
if (!final_buffer) {
@@ -283,7 +284,7 @@
 
 /* {{{ php_ob_set_internal_handler
  */
-PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t 
internal_output_handler, uint buffer_size TSRMLS_DC)
+PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t 
+internal_output_handler, uint buffer_size, char *handler_name, zend_bool erase 
+TSRMLS_DC)
 {
if (OG(ob_nesting_level)==0) {
return;
@@ -292,6 +293,8 @@
OG(active_ob_buffer).internal_output_handler = internal_output_handler;
OG(active_ob_buffer).internal_output_handler_buffer = (char *) 
emalloc(buffer_size);
OG(active_ob_buffer).internal_output_handler_buffer_size = buffer_size;
+   OG(active_ob_buffer).handler_name = handler_name;
+   OG(active_ob_buffer).erase = erase; 
 }
 /* }}} */
 
@@ -315,7 +318,7 @@
 
 /* {{{ php_ob_init
  */
-static void php_ob_init(uint initial_size, uint block_size, zval *output_handler, 
uint chunk_size TSRMLS_DC)
+static void php_ob_init(uint initial_size, uint block_size, zval *output_handler, 
+uint chunk_size, zend_bool erase TSRMLS_DC)
 {
if (OG(ob_nesting_level)0) {
if (OG(ob_nesting_level)==1) { /* initialize stack */
@@ -332,6 +335,18 @@
OG(active_ob_buffer).chunk_size = chunk_size;
OG(active_ob_buffer).status = 0;
OG(active_ob_buffer).internal_output_handler = NULL;
+   if (output_handler  output_handler-type == IS_STRING) {
+   OG(active_ob_buffer).handler_name = Z_STRVAL_P(output_handler);
+   }
+   else if (output_handler  output_handler-type == IS_ARRAY) {
+   /* FIXME: Array type is not supported yet.
+  See call_user_function_ex() for detials. */
+   OG(active_ob_buffer).handler_name = array is not supported yet;
+   }
+   else {
+   OG(active_ob_buffer).handler_name = default output handler;
+   }
+   OG(active_ob_buffer).erase = erase; 
 }
 /* }}} */
 
@@ -478,47 +493,24 @@
  * 

Re: [PHP-DEV] [patch] one script to handle them all

2002-02-13 Thread Stefan Esser

Hmm,

maybe we should first hear if anyone has an argument against
such an additional feature. I think its less overhead than mod_rewrite.

+1 from me

Stefan



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




Re: [PHP-DEV] [patch] one script to handle them all

2002-02-13 Thread Lukas Schroeder

On Wed, Feb 13, 2002 at 08:13:42AM +0100, Markus Fischer wrote:
 Patches should always be against latest CVS.

here it is. against latest CVS.



regards,
  -lukas
 


Index: sapi/apache/mod_php4.c
===
RCS file: /repository/php4/sapi/apache/mod_php4.c,v
retrieving revision 1.127
diff -u -r1.127 mod_php4.c
--- sapi/apache/mod_php4.c  11 Dec 2001 15:31:53 -  1.127
+++ sapi/apache/mod_php4.c  13 Feb 2002 11:20:58 -
@@ -483,6 +483,39 @@
 }
 /* }}} */
 
+/* {{{ php_get_request_handler
+ */
+static int php_get_request_handler(request_rec *r, char **target)
+{
+   HashTable *per_dir_conf;
+   php_per_dir_entry *per_dir_entry;
+   char *filename;
+
+   if (!(per_dir_conf = get_module_config(r-per_dir_config, php4_module)))
+   return 0;
+
+   if (zend_hash_find(per_dir_conf, request_handler, 
+sizeof(request_handler)-1,
+   (void **)per_dir_entry) == SUCCESS) {
+
+   if (!ap_os_is_path_absolute(per_dir_entry-value)) {
+   char *dirnam = ap_pstrdup(r-pool, r-filename);
+   char *x = strrchr(dirnam, '/');
+
+   if (x != NULL)
+   *x = 0;
+   filename = ap_make_full_path(r-pool, dirnam, 
+per_dir_entry-value);
+   }
+   else
+   filename = ap_pstrdup(r-pool, per_dir_entry-value);
+
+   *target = filename;
+   return 1;
+   }
+
+   return 0;
+}
+/* }}} */
+
 /* {{{ send_php
  */
 static int send_php(request_rec *r, int display_source_mode, char *filename)
@@ -502,6 +535,9 @@
return OK;
}
 
+   if (php_get_request_handler(r, filename))
+   r-filename = filename;
+
zend_first_try {
/* We don't accept OPTIONS requests, but take everything else */
if (r-method_number == M_OPTIONS) {
@@ -846,6 +882,26 @@
 }
 /* }}} */
 
+/* {{{ php_type_checker
+ */
+static int php_type_checker(request_rec *r)
+{
+   char *filename;
+   
+   /* if a request_handler has been registered, the type checker tells 
+* apache to invoke our send_php handler; otherwise we deny responsibility
+* for this request
+*/
+   
+   if (php_get_request_handler(r, filename)) {
+   r-handler = application/x-httpd-php;
+   return OK;
+   }
+   
+   return DECLINED;
+}
+/* }}} */
+
 /* {{{ handler_rec php_handlers[]
  */
 handler_rec php_handlers[] =
@@ -885,7 +941,7 @@
NULL,   /* check_user_id */
NULL,   /* check auth */
NULL,   /* check access */
-   NULL,   /* type_checker */
+   php_type_checker,   /* type_checker */
NULL,   /* fixups */
NULL/* logger */
 #if MODULE_MAGIC_NUMBER = 19970103



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


Re: [PHP-DEV] msession tech note, 'feature' (buglet), call for

2002-02-13 Thread mlwmohawk

 At 10:16 PM 2/12/2002 -0500, [EMAIL PROTECTED] wrote:
There are a number of ways to deal with this, but creating a socket
pool of active sockets, and have a number of threads handle the sockets
in a classing queue fashion seems like the best way.

Anyone have a better idea?
 
 Either do a thread pool like you mention here or if you want to get
 maximum  performance you should consider non-blocking I/O. Check out 
 http://state-threads.sourceforge.net/

The msession daemson does no I/O. It is a ram only system. The only I/O 
it does do is to the network card. The network does not block unless I 
code it to do so.



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




Re: [PHP-DEV] 80,000 posts

2002-02-13 Thread Jason Greene

Wow, 

I wonder what the size of all those would be in bytes: )

-Jason




On Tue, 2002-02-12 at 22:13, Andrei Zmievski wrote:
 php-dev has had 80,000 posts to it. At least I hope mine is number
 80,000.
 
 P.S. Well, most of those were probably bug reports/closings.
 
 -Andrei
 
 -- 
 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




Re: [PHP-DEV] 80,000 posts

2002-02-13 Thread Andrei Zmievski

On Wed, 13 Feb 2002, Jason Greene wrote:
 Wow, 
 
 I wonder what the size of all those would be in bytes: )

271,622,000

-Andrei

The secret of flying is to throw yourself
at the ground, and miss. -- Douglas Adams

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




[PHP-DEV] php globals delete

2002-02-13 Thread brad lafountain


Question..

why doens't the destructor get called on shutdown with the following line...

ZEND_INIT_MODULE_GLOBALS(soap, php_init_globals, php_del_globals);


- Brad


__
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

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




[PHP-DEV] Re: php globals delete

2002-02-13 Thread Yasuo Ohgaki

Brad Lafountain wrote:
 Question..
 
 why doens't the destructor get called on shutdown with the following line...
 
 ZEND_INIT_MODULE_GLOBALS(soap, php_init_globals, php_del_globals);
 

According to the macro definition, it does not use
it unless PHP is compiled with ZTS.

-- 
Yasuo Ohgaki


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




[PHP-DEV] Re: Bug #15535 Updated: Un-HTML-Entities

2002-02-13 Thread Wez Furlong

Well, I've already coded it and it's ready to commit :-)

Should we include html_entity_decode in CVS?
It is effectively the same as the snippet below, just a little
bit more obvious that it can be done (and slightly faster).

--Wez.

On 13/02/02, [EMAIL PROTECTED] wrote:
 ID:   15535
 +Status:   Closed

 I'm closing this, because you can do this:
 $trans = get_html_translation_table(HTML_ENTITIES);
 $str = Hallo  Frau  Krämer
 $original = strtr($str, $trans);
 
 IMO, this does not warrant a new function.



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




Re: [PHP-DEV] Re: php globals delete

2002-02-13 Thread brad lafountain

Well how do i properly delete my global memory with without having
zts enabled

- Brad 
--- Yasuo Ohgaki [EMAIL PROTECTED] wrote:
 Brad Lafountain wrote:
  Question..
  
  why doens't the destructor get called on shutdown with the following
 line...
  
  ZEND_INIT_MODULE_GLOBALS(soap, php_init_globals, php_del_globals);
  
 
 According to the macro definition, it does not use
 it unless PHP is compiled with ZTS.
 
 -- 
 Yasuo Ohgaki
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 


__
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

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




[PHP-DEV] CVS Account Request: jtate

2002-02-13 Thread Joseph Tate

I'd like to help with the DOM-XML extension, getting it up to snuff.  Filling in the 
holes, etc.  I've already submitted one patch, and feel I can help a very strapped 
development team.

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




Re: [PHP-DEV] Re: php globals delete

2002-02-13 Thread derick

On Wed, 13 Feb 2002, brad lafountain wrote:

 Well how do i properly delete my global memory with without having
 zts enabled

You can do it in your MINIT/MSHUTDOWN functions. (or RINIT and
RSHUTDOWN):

http://www.php.net/manual/en/zend.structure.module-block.php
http://www.php.net/manual/en/zend.startup-and-shutdown.php

regards,
Derick


 - Brad
 --- Yasuo Ohgaki [EMAIL PROTECTED] wrote:
  Brad Lafountain wrote:
   Question..
  
   why doens't the destructor get called on shutdown with the following
  line...
  
   ZEND_INIT_MODULE_GLOBALS(soap, php_init_globals, php_del_globals);
  
 
  According to the macro definition, it does not use
  it unless PHP is compiled with ZTS.
 
  --
  Yasuo Ohgaki
 
 
  --
  PHP Development Mailing List http://www.php.net/
  To unsubscribe, visit: http://www.php.net/unsub.php
 


 __
 Do You Yahoo!?
 Send FREE Valentine eCards with Yahoo! Greetings!
 http://greetings.yahoo.com

 --
 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] RE: Bug #15530 Updated: conent of node node correct reading new DOM value after set_content of node

2002-02-13 Thread Joseph Tate

Ok, try the following code:

function getContent ($n)
{
if (!($children = $n-children())) return '';

$content = '';
foreach ($children as $c) {
if ($c-type == XML_TEXT_NODE) {
$content .= $c-content;
}
}

return $content;
}

Then use getContent($n) rather than $n-content.  This could fix your
problem, but I'm not sure.  It still uses the -content property (though in
a TEXT_NODE context).  I don't actually make changes and then read back the
contents in any of my code, so this is new to me.

As for the time frame for the next release of php?  I don't know.

Joseph

 -Original Message-
 From: Rob Richards [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, February 13, 2002 11:42 AM
 To: Joseph Tate
 Subject: Re: Bug #15530 Updated: conent of node node correct reading new
 DOM value after set_content of node


 Management's definition of a custom build is any package or port
 that we use
 not coming from a maintainer - go figure.  This includes grabbing CVS
 updates.  Losing battle trying to argue this with them.

 We have built a package for RedHat 7.2, 7.1 as well as FreeBSD,  but the
 ultimate server is out of our control and they will only use the FreeBSD
 ports they can pull from within it.

 Basically, we are stuck with our code needing to run on the
 FreeBSD version
 they run which right now only is up to revision 1.90 of the domxml code.

 Do you happen to know any time frame for a next release?  This may not be
 much of a problem depending upon that.

 Thanks,

 Rob

 - Original Message -
 From: Joseph Tate [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]; Php-Dev List [EMAIL PROTECTED]
 Sent: Wednesday, February 13, 2002 11:19 AM
 Subject: RE: Bug #15530 Updated: conent of node node correct
 reading new DOM
 value after set_content of node


  You kind of have to have a custom php build anyway because DOMXML stuff
  isn't part of the RH php installation.  I've got rpms for RH 7.2 if that
  will help.  They don't have the get_content stuff, but I could
 add that to
  my custom patch (that fixes bug #14934) no problem.  Besides,
 it'll be in
  the next release; it's not custom code in the purest definition of the
  term.
 
  Joseph
 
   -Original Message-
   From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
   Sent: Wednesday, February 13, 2002 11:04 AM
   To: [EMAIL PROTECTED]
   Subject: Bug #15530 Updated: conent of node node correct
 reading new DOM
   value after set_content of node
  
  
ID:   15530
Updated by:   [EMAIL PROTECTED]
Reported By:  [EMAIL PROTECTED]
Status:   Open
Bug Type: DOM XML related
Operating System: RedHat 7.2
PHP Version:  4.1.1
New Comment:
  
   Any other workaround for the get_content problem?  We can use a custom
   php build on our development machines, but cant on the server
 where the
   code will actually be going.
  
   Thanks
  
  
   Previous Comments:
  
 
  
   [2002-02-13 10:43:55] [EMAIL PROTECTED]
  
   The problem is that the content property is going away, so that
   property is not set.  This is why it's not being updated.  It's being
   replaced by a get_content() function.  This is in CVS at this very
   moment.
  
   As for the appending of xml contents, the comment in the code is as
   follows:
   // FIXME: another gotcha. If node has children, calling
   // xmlNodeSetContent will remove the children - we loose the zval's
   // To prevent crash, append content if children are set
  
  
   I think if you just used the get_content() function instead of the
   -content property that your problem would go away.  Of course you're
   going to have to pull it from CVS.
  
  
 
  
   [2002-02-12 16:18:23] [EMAIL PROTECTED]
  
   The following simplied script shows that when we update the value of a
   node, the DOM is updated as shown through the dump.  When you try to
   read the content of the node however, it returns the origional value.
  
  
   If this is a bug, is there any known workaround to get the desired
   result?
  
   Also, we had to use the set_content as provided in the script because
   if a node already has a value and we try to call set_content directly
   on the node rather than on the the text element (value node), it
   appends the data to the node rather than overwriting the exisitng
   value.
  
   XPath is used in here as our real XML data is quite complex so needed
   to illustrate how we were finding the correct node.
  
   ?
   $xmltest = root_nodenode1ORG VALUE/node1/root_node;
   $mydoc = xmldoc($xmltest);
   echo pre.$mydoc-dumpmem()./prebr;
   $ctx=$mydoc-xpath_new_context();
   $query_xo = xpath_eval($ctx,/root_node/node1);
   $oNode = $query_xo-nodeset[0];
   if (is_null($oNode)) {
   $root = $$mydoc-root();
   $root-new_child(node1, empty);
   } else {

[PHP-DEV] Re: Bug #15530 Updated: conent of node node correct reading new DOM value after set_content of node

2002-02-13 Thread Rob Richards

Thanks, but same results.

when I put the example code up there I also was thinking who would ever need
to set and then read the same information.  Unfortunately our real case
scenario runs into this.

Just for reference: We have a complex workflow, so have no idea where we are
in the workflow we are when information is passed to through it.  We have a
case, which is how we found this problem, where data is set and then in
another point in the workflow the information is accessed.  Only work around
we could come up with was to hard code an indicator which identified when we
were in this problem section so that it would ignore reading the newly set
data and use the information we had previously set.

Thanks for the help.

Rob

- Original Message -
From: Joseph Tate [EMAIL PROTECTED]
To: Rob Richards [EMAIL PROTECTED]; Php-Dev List
[EMAIL PROTECTED]
Sent: Wednesday, February 13, 2002 11:51 AM
Subject: RE: Bug #15530 Updated: conent of node node correct reading new DOM
value after set_content of node


 Ok, try the following code:

 function getContent ($n)
 {
 if (!($children = $n-children())) return '';

 $content = '';
 foreach ($children as $c) {
 if ($c-type == XML_TEXT_NODE) {
 $content .= $c-content;
 }
 }

 return $content;
 }

 Then use getContent($n) rather than $n-content.  This could fix your
 problem, but I'm not sure.  It still uses the -content property (though
in
 a TEXT_NODE context).  I don't actually make changes and then read back
the
 contents in any of my code, so this is new to me.

 As for the time frame for the next release of php?  I don't know.

 Joseph

  -Original Message-
  From: Rob Richards [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, February 13, 2002 11:42 AM
  To: Joseph Tate
  Subject: Re: Bug #15530 Updated: conent of node node correct reading new
  DOM value after set_content of node
 
 
  Management's definition of a custom build is any package or port
  that we use
  not coming from a maintainer - go figure.  This includes grabbing CVS
  updates.  Losing battle trying to argue this with them.
 
  We have built a package for RedHat 7.2, 7.1 as well as FreeBSD,  but the
  ultimate server is out of our control and they will only use the FreeBSD
  ports they can pull from within it.
 
  Basically, we are stuck with our code needing to run on the
  FreeBSD version
  they run which right now only is up to revision 1.90 of the domxml code.
 
  Do you happen to know any time frame for a next release?  This may not
be
  much of a problem depending upon that.
 
  Thanks,
 
  Rob
 
  - Original Message -
  From: Joseph Tate [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]; Php-Dev List [EMAIL PROTECTED]
  Sent: Wednesday, February 13, 2002 11:19 AM
  Subject: RE: Bug #15530 Updated: conent of node node correct
  reading new DOM
  value after set_content of node
 
 
   You kind of have to have a custom php build anyway because DOMXML
stuff
   isn't part of the RH php installation.  I've got rpms for RH 7.2 if
that
   will help.  They don't have the get_content stuff, but I could
  add that to
   my custom patch (that fixes bug #14934) no problem.  Besides,
  it'll be in
   the next release; it's not custom code in the purest definition of
the
   term.
  
   Joseph
  
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 11:04 AM
To: [EMAIL PROTECTED]
Subject: Bug #15530 Updated: conent of node node correct
  reading new DOM
value after set_content of node
   
   
 ID:   15530
 Updated by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Open
 Bug Type: DOM XML related
 Operating System: RedHat 7.2
 PHP Version:  4.1.1
 New Comment:
   
Any other workaround for the get_content problem?  We can use a
custom
php build on our development machines, but cant on the server
  where the
code will actually be going.
   
Thanks
   
   
Previous Comments:
   
  
   
[2002-02-13 10:43:55] [EMAIL PROTECTED]
   
The problem is that the content property is going away, so that
property is not set.  This is why it's not being updated.  It's
being
replaced by a get_content() function.  This is in CVS at this very
moment.
   
As for the appending of xml contents, the comment in the code is as
follows:
// FIXME: another gotcha. If node has children, calling
// xmlNodeSetContent will remove the children - we loose the zval's
// To prevent crash, append content if children are set
   
   
I think if you just used the get_content() function instead of the
-content property that your problem would go away.  Of course
you're
going to have to pull it from CVS.
   
   
  

Re: [PHP-DEV] passing by reference

2002-02-13 Thread Andi Gutmans

At 07:28 PM 2/12/2002 +0100, Markus Fischer wrote:
On Tue, Feb 12, 2002 at 10:05:06AM -0500, Chad Cunningham wrote :
  4.1.1 seems to have gotten rid of ParameterPassedByReference. What is the
  proper, backwards compatable way to handle this now?

 PZVAL_IS_REF(z) defined in zend.h

Even better :)

Andi


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




[PHP-DEV] Re: Bug in current Object Model

2002-02-13 Thread Andi Gutmans

I don't think it's a bug. This weird behavior is due to the Engine 1 object 
model (which will be different in Engine 2).

At 07:38 PM 2/12/2002 -0600, Jason Greene wrote:
Zeev, Andi

It appears that the bug we talked about in private correspondence does
not just apply to object overloading. It appears to apply to normal
objects as well.

Consider the following code:

class test {
 var $dummy;

 function do_something() {
  print Hello\n;
 }

}

$obj=new test();

$obj == is_ref=1/refcount=1

debug_zval_dump($obj);

You are passing $obj by value. So inside the debug_zval_dump() it will be 
is_ref=0/refcount=1 (it will be copied).


$obj-do_something();

Inside do_something it will be is_ref=1/refcount=2

debug_zval_dump($obj);

You are passing $obj by value. So inside the debug_zval_dump() it will be 
is_ref=0/refcount=1 (it will be copied).

Bottom line: Passing it by value makes it duplicate. This is Engine 1. 
Nothing to do about it. I guess debug_zval_dump() isn't that useful after 
all :)

Andi


This will produce the following output:

object(test)(1) refcount(2){
   [dummy]=
   long(1) refcount(2)
}
Hello
object(test)(1) refcount(1){
   [dummy]=
   long(1) refcount(3)
}

ZEND_SEND_VAR is the opcode that does this in this scenario as well




-jason



--
Jason T. Greene
Internet Software Engineer

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

Use PHP: http://www.php.net


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




[PHP-DEV] socket_fd_* functions in ext/sockets

2002-02-13 Thread Richard Samar

Can anyone help me out for what the socket_fd_* functions
in ext/sockets are good for and in which scenario they might
be useful?

thx n greetZ
-moh

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




[PHP-DEV] Re: [PHP-CVS] cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_language_parser.y

2002-02-13 Thread Andi Gutmans

Can we change the commit address to [EMAIL PROTECTED]?
I like to filter my mail with the Qmail Delivered-To: directive so it help 
if the mailing list name would be different.
Andi

At 07:26 PM 2/13/2002 +, Andi Gutmans wrote:
andiWed Feb 13 14:26:07 2002 EDT

   Modified files:
 /ZendEngine2zend_compile.c zend_compile.h zend_language_parser.y
   Log:
   @ Allow a series of consecutive catch() statements (Andi, Zend Engine)
   ?php
 class MyException1 {

 }

 class MyException2 {

 }

 try {
 throw new MyException2();
 } catch (MyException1 $m) {
 print Caught MyException1;
 } catch (MyException2 $m) {
 print Caught MyException2;
 }


Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.268 ZendEngine2/zend_compile.c:1.269
--- ZendEngine2/zend_compile.c:1.268Thu Feb  7 09:08:43 2002
+++ ZendEngine2/zend_compile.c  Wed Feb 13 14:26:07 2002
@@ -1255,7 +1255,7 @@
 }
  }

-void zend_do_begin_catch(znode *try_token, znode *catch_class, znode 
*catch_var TSRMLS_DC)
+void zend_do_begin_catch(znode *try_token, znode *catch_class, znode 
*catch_var, zend_bool first_catch TSRMLS_DC)
  {
 long catch_op_number = get_next_op_number(CG(active_op_array));
 zend_op *opline;
@@ -1266,11 +1266,12 @@
 SET_UNUSED(opline-op1); /* FIXME: Define IS_CLASS or something 
 like that */
 opline-op2 = *catch_var;

-   zend_llist_apply_with_argument(CG(throw_list), 
(llist_apply_with_arg_func_t) throw_list_applier, CG(catch_begin) TSRMLS_CC);
-   zend_llist_destroy(CG(throw_list));
-   efree(CG(throw_list));
-   CG(throw_list) = (void *) try_token-throw_list;
-
+   if (first_catch) {
+   zend_llist_apply_with_argument(CG(throw_list), 
(llist_apply_with_arg_func_t) throw_list_applier, CG(catch_begin) TSRMLS_CC);
+   zend_llist_destroy(CG(throw_list));
+   efree(CG(throw_list));
+   CG(throw_list) = (void *) try_token-throw_list;
+   }
 try_token-u.opline_num = catch_op_number;
  }

Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.165 ZendEngine2/zend_compile.h:1.166
--- ZendEngine2/zend_compile.h:1.165Sun Feb 10 07:54:02 2002
+++ ZendEngine2/zend_compile.h  Wed Feb 13 14:26:07 2002
@@ -279,7 +279,7 @@
  void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC);

  void zend_do_try(znode *try_token TSRMLS_DC);
-void zend_do_begin_catch(znode *try_token, znode *catch_class, znode 
*catch_var TSRMLS_DC);
+void zend_do_begin_catch(znode *try_token, znode *catch_class, znode 
*catch_var, zend_bool first_catch TSRMLS_DC);
  void zend_do_end_catch(znode *try_token TSRMLS_DC);
  void zend_do_throw(znode *expr TSRMLS_DC);

Index: ZendEngine2/zend_language_parser.y
diff -u ZendEngine2/zend_language_parser.y:1.46 
ZendEngine2/zend_language_parser.y:1.47
--- ZendEngine2/zend_language_parser.y:1.46 Sun Jan 20 15:42:15 2002
+++ ZendEngine2/zend_language_parser.y  Wed Feb 13 14:26:07 2002
@@ -206,10 +206,16 @@
 |   T_DECLARE { zend_do_declare_begin(TSRMLS_C); } '(' 
 declare_list ')' declare_statement { zend_do_declare_end(TSRMLS_C); }
 |   ';' /* empty statement */
 |   T_TRY { zend_do_try($1 TSRMLS_CC); } '{' 
 inner_statement_list '}'
-   T_CATCH '(' catch_class_entry T_VARIABLE ')' { 
zend_do_begin_catch($1, $8, $9 TSRMLS_CC); } '{' inner_statement_list 
'}' { zend_do_end_catch($1 TSRMLS_CC); }
+   catches
 |   T_THROW expr ';' { zend_do_throw($2 TSRMLS_CC); }
 |   T_DELETE  cvar  ';' { 
 zend_do_end_variable_parse(BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset($1, 
 ZEND_UNSET_OBJ TSRMLS_CC); }
  ;
+
+catches:
+   catches T_CATCH '(' catch_class_entry T_VARIABLE ')' { 
zend_do_begin_catch($2, $4, $5, 0 TSRMLS_CC); } '{' 
inner_statement_list '}' { zend_do_end_catch($2 TSRMLS_CC); }
+   |   T_CATCH '(' catch_class_entry T_VARIABLE ')' { 
zend_do_begin_catch($1, $3, $4, 1 TSRMLS_CC); } '{' 
inner_statement_list '}' { zend_do_end_catch($1 TSRMLS_CC); }
+;
+

  unset_variables:
 unset_variable



--
PHP CVS 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




Re: [PHP-DEV] Re: Bug in current Object Model

2002-02-13 Thread Jason Greene

On Wed, 2002-02-13 at 12:24, Andi Gutmans wrote:
 $obj=new test();
 
 $obj == is_ref=1/refcount=1
 
 debug_zval_dump($obj);
 
 You are passing $obj by value. So inside the debug_zval_dump() it will be 
 is_ref=0/refcount=1 (it will be copied).
 
 
 $obj-do_something();
 
 Inside do_something it will be is_ref=1/refcount=2
 
 debug_zval_dump($obj);
 
 You are passing $obj by value. So inside the debug_zval_dump() it will be 
 is_ref=0/refcount=1 (it will be copied).
 
 Bottom line: Passing it by value makes it duplicate. This is Engine 1. 
 Nothing to do about it. I guess debug_zval_dump() isn't that useful after 
 all :)
 
 Andi



Yes I do realize that the function would copy the value; however, I
would think the output before and after $obj-do_something would be
equal  The problem I was mainly refering to is the reference count of
the properties elements. Why would it grow from 2 to 3 after the call to
$obj-do_somtehing? Why does the reference count of the object drop from
2 to 1 after the function is called?


If I remove the line $obj-do_something I get the following.


object(test)(1) refcount(2){
  [dummy]=
  long(1) refcount(2)
}
object(test)(1) refcount(2){
  [dummy]=
  long(1) refcount(2)
}


Perhaps I am missing something obvious?



 
 
 This will produce the following output:
 
 object(test)(1) refcount(2){
[dummy]=
long(1) refcount(2)
 }
 Hello
 object(test)(1) refcount(1){
[dummy]=
long(1) refcount(3)
 }
 
 ZEND_SEND_VAR is the opcode that does this in this scenario as well
 
 
 
 
 -jason
 
 
 
 --
 Jason T. Greene
 Internet Software Engineer
 
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 
 Use PHP: http://www.php.net
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php
 
-- 
Jason T. Greene
Internet Software Engineer

[EMAIL PROTECTED]
[EMAIL PROTECTED] 
[EMAIL PROTECTED]

Use PHP: http://www.php.net



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




[PHP-DEV] Re: socket_fd_* functions in ext/sockets

2002-02-13 Thread Richard Samar


Richard Samar wrote:
 
 Can anyone help me out for what the socket_fd_* functions
 in ext/sockets are good for and in which scenario they might
 be useful?


hmm obviously a wrap of the FD_* macros

...sorry to bother :-)
-moh

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




Re: [PHP-DEV] Re: Bug in current Object Model

2002-02-13 Thread Andi Gutmans

At 01:34 PM 2/13/2002 -0600, Jason Greene wrote:
Yes I do realize that the function would copy the value; however, I
would think the output before and after $obj-do_something would be
equal  The problem I was mainly refering to is the reference count of
the properties elements. Why would it grow from 2 to 3 after the call to
$obj-do_somtehing? Why does the reference count of the object drop from
2 to 1 after the function is called?


If I remove the line $obj-do_something I get the following.


object(test)(1) refcount(2){
   [dummy]=
   long(1) refcount(2)
}
object(test)(1) refcount(2){
   [dummy]=
   long(1) refcount(2)
}


Perhaps I am missing something obvious?

I have a bit of a stack overflow right now but as there was some zval 
splitting going on this could have happened. In the end if there's no leak 
nor a crash it means the reference counting was most probably doing well.
One of the main reasons for the new object model is such weird behavior. 
The new one is completely consistent.

Andi


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




Re: [PHP-DEV] Re: Bug #15530 Updated: conent of node node correct reading new DOM value after set_content of node

2002-02-13 Thread Markus Fischer

Well, as far as I understand, the content thing is not
compltely imlpemented (there's even a note about this in the
source). Sadly, no time currently to fix it.

- Markus

On Wed, Feb 13, 2002 at 12:11:58PM -0500, Rob Richards wrote : 
 Thanks, but same results.
 
 when I put the example code up there I also was thinking who would ever need
 to set and then read the same information.  Unfortunately our real case
 scenario runs into this.
 
 Just for reference: We have a complex workflow, so have no idea where we are
 in the workflow we are when information is passed to through it.  We have a
 case, which is how we found this problem, where data is set and then in
 another point in the workflow the information is accessed.  Only work around
 we could come up with was to hard code an indicator which identified when we
 were in this problem section so that it would ignore reading the newly set
 data and use the information we had previously set.
 
 Thanks for the help.
 
 Rob
 
 - Original Message -
 From: Joseph Tate [EMAIL PROTECTED]
 To: Rob Richards [EMAIL PROTECTED]; Php-Dev List
 [EMAIL PROTECTED]
 Sent: Wednesday, February 13, 2002 11:51 AM
 Subject: RE: Bug #15530 Updated: conent of node node correct reading new DOM
 value after set_content of node
 
 
  Ok, try the following code:
 
  function getContent ($n)
  {
  if (!($children = $n-children())) return '';
 
  $content = '';
  foreach ($children as $c) {
  if ($c-type == XML_TEXT_NODE) {
  $content .= $c-content;
  }
  }
 
  return $content;
  }
 
  Then use getContent($n) rather than $n-content.  This could fix your
  problem, but I'm not sure.  It still uses the -content property (though
 in
  a TEXT_NODE context).  I don't actually make changes and then read back
 the
  contents in any of my code, so this is new to me.
 
  As for the time frame for the next release of php?  I don't know.
 
  Joseph
 
   -Original Message-
   From: Rob Richards [mailto:[EMAIL PROTECTED]]
   Sent: Wednesday, February 13, 2002 11:42 AM
   To: Joseph Tate
   Subject: Re: Bug #15530 Updated: conent of node node correct reading new
   DOM value after set_content of node
  
  
   Management's definition of a custom build is any package or port
   that we use
   not coming from a maintainer - go figure.  This includes grabbing CVS
   updates.  Losing battle trying to argue this with them.
  
   We have built a package for RedHat 7.2, 7.1 as well as FreeBSD,  but the
   ultimate server is out of our control and they will only use the FreeBSD
   ports they can pull from within it.
  
   Basically, we are stuck with our code needing to run on the
   FreeBSD version
   they run which right now only is up to revision 1.90 of the domxml code.
  
   Do you happen to know any time frame for a next release?  This may not
 be
   much of a problem depending upon that.
  
   Thanks,
  
   Rob
  
   - Original Message -
   From: Joseph Tate [EMAIL PROTECTED]
   To: [EMAIL PROTECTED]; Php-Dev List [EMAIL PROTECTED]
   Sent: Wednesday, February 13, 2002 11:19 AM
   Subject: RE: Bug #15530 Updated: conent of node node correct
   reading new DOM
   value after set_content of node
  
  
You kind of have to have a custom php build anyway because DOMXML
 stuff
isn't part of the RH php installation.  I've got rpms for RH 7.2 if
 that
will help.  They don't have the get_content stuff, but I could
   add that to
my custom patch (that fixes bug #14934) no problem.  Besides,
   it'll be in
the next release; it's not custom code in the purest definition of
 the
term.
   
Joseph
   
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, February 13, 2002 11:04 AM
 To: [EMAIL PROTECTED]
 Subject: Bug #15530 Updated: conent of node node correct
   reading new DOM
 value after set_content of node


  ID:   15530
  Updated by:   [EMAIL PROTECTED]
  Reported By:  [EMAIL PROTECTED]
  Status:   Open
  Bug Type: DOM XML related
  Operating System: RedHat 7.2
  PHP Version:  4.1.1
  New Comment:

 Any other workaround for the get_content problem?  We can use a
 custom
 php build on our development machines, but cant on the server
   where the
 code will actually be going.

 Thanks


 Previous Comments:

   

 [2002-02-13 10:43:55] [EMAIL PROTECTED]

 The problem is that the content property is going away, so that
 property is not set.  This is why it's not being updated.  It's
 being
 replaced by a get_content() function.  This is in CVS at this very
 moment.

 As for the appending of xml contents, the comment in the code is as
 follows:
 // FIXME: another gotcha. If node has children, 

[PHP-DEV] Nuking issock - PHP Streams

2002-02-13 Thread Wez Furlong

Hi All,

Well, after a period of semi-absence (I've had a LOT of work on),
I've managed to do some more work on PHP Streams.

I've attached a diff that I would like to commit in a day-or-so - it
would be great if you could look through and yell if there is any reason
not to commit it, or if there are some errors.

By default, the patch should not change the way your build works; you
will need to re-configure with the --enable-php-streams switch to activate
the streams.

Hopefully, once activated, you will not notice any difference with your
build. :-)

I'd like feedback on things like fopen wrappers; streams don't implement
them yet (the infrastructure is there) but do fall back on regular fopen
wrappers - so it should still work.

I'd like to see streams enabled as the default option for PHP 5 :-)

TODO: revisit fsock.c, make SSL aware version of socket streams,
port http and any other url fopen wrappers to streams,
ensure that all extensions that use File-Handles are streams aware (
just the network aware extensions to do, IIRC),
and finally nuke issock and reduce the nightmare...

--Wez.




wez.streams.diff.gz
Description: application/gzip-compressed

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


[PHP-DEV] Constants

2002-02-13 Thread Evan Nemerson

I was thinking about putting together a list of constants, their purpose, 
what version of PHP they initially appeared in, etc.

So far, I have figured out a function called REGISTER_LONG_CONSTANT is 
used, or a constant is defined in the source with a name that has a 
preceeding PHP_ (eg PHP_RAND_MAX- which is 2^31??? why not 2^32? sorry 
off the point.) Are there any other ways? Are these ways inaccurate?

Please reply to my e-mail address ([EMAIL PROTECTED]). I don't subscribe 
to this list.


Evan Nemerson

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




[PHP-DEV] Re: Bug #15535 Updated: Un-HTML-Entities

2002-02-13 Thread Yasuo Ohgaki

Wez Furlong wrote:
 Well, I've already coded it and it's ready to commit :-)
 
 Should we include html_entity_decode in CVS?
 It is effectively the same as the snippet below, just a little
 bit more obvious that it can be done (and slightly faster).
 
 --Wez.

Why not?
+1

 
 On 13/02/02, [EMAIL PROTECTED] wrote:
 
ID:   15535
+Status:   Closed

 
I'm closing this, because you can do this:
$trans = get_html_translation_table(HTML_ENTITIES);
$str = Hallo  Frau  Krämer
$original = strtr($str, $trans);

IMO, this does not warrant a new function.

 
 

-- 
Yasuo Ohgaki


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




[PHP-DEV] Improved array dereferencing

2002-02-13 Thread Jesse McCarthy

I posted this to the PHP Into the Future forum on Zend.com and no one 
responded, so now I'm posting it here, though I'm not sure how directly 
relevant it is to this list: 

I don't know if this has come up, but I think it would be great to have 
improved array dereferencing support in PHP so that you can dereference an 
element of an anonymous array (such as an array returned by a function), like 
you can with a list in Perl, e.g. (stat($file))[8], or in PHP (parse_url( 
$URL ))[ 'host' ]. 

Improved object dereferencing support is included in the Zend v2 overview, 
but I don't see anything about arrays.  Can someone tell me if this 
functionality is in PHP's future? 

Jesse McCarthy


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




[PHP-DEV] ZendAPI manual problem?

2002-02-13 Thread Yasuo Ohgaki

I cannot do make test for ZendAPI.
Am I missing something?

[yohgaki@dev ZendAPI]$ make test
nsgmls -i lang-en -s ./phpdocxml.dcl
nsgmls:./phpdocxml.dcl:179:2:E: end of document in prolog

ZendAPI is small enough to do make html, though.

-- 
Yasuo Ohgaki


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




Re: [PHP-DEV] Constants

2002-02-13 Thread Lars Torben Wilson

On Wed, 2002-02-13 at 17:22, Evan Nemerson wrote:
 I was thinking about putting together a list of constants, their purpose, 
 what version of PHP they initially appeared in, etc.
 
 So far, I have figured out a function called REGISTER_LONG_CONSTANT is 
 used, or a constant is defined in the source with a name that has a 
 preceeding PHP_ (eg PHP_RAND_MAX- which is 2^31??? why not 2^32? sorry 
 off the point.) Are there any other ways? Are these ways inaccurate?
 
 Please reply to my e-mail address ([EMAIL PROTECTED]). I don't subscribe 
 to this list.
 
 
 Evan Nemerson

I've committed a list of (almost) all predefined constants and classes 
to the phpdoc cvs. There is a bit more work to be done before the list
makes it into the online manual, but you can either check out phpdoc 
from cvs, or view it online here:

  http://cvs.php.net/co.php/phpdoc/en/appendices/predefined.xml?r=1.3

Warning: it's a long list. There are over a thousand predefined 
constants, all told. :)

Comments welcome (from Evan and from anybody else reading this...)


-- 
 Torben Wilson [EMAIL PROTECTED]
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


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




[PHP-DEV] CVS Account Request: avaly

2002-02-13 Thread Agachi Valentin

Translating Documentation in Romanian

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




[PHP-DEV] file permissions in function copy()

2002-02-13 Thread Andrew Sitnikov

Hello php-dev,

  Function copy(), when create new file use 0777 permissinos
  instead 0666, as result with umask 022 we have new file with 0755.

  Any comments ?

Best regards,
 Andrew Sitnikov 
 e-mail : [EMAIL PROTECTED]
 GSM: (+372) 56491109


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