On Thu, 2004-02-26 at 08:57, Marcus Boerger wrote:
> Hello Timm,
> 
> i think this is not completley correct. When reflection is used from a
> static member of the class itself it should still work.

Correct:

class Foo {
  protected function __construct() { }

  public static function create() {
    $r= new Reflection_Class('Foo');
    return $r->newInstance();
  }
}

should work as newInstance() is called within the context "Foo".

> We have functions which enable such checks.

I've tried to find out which context I am in. Alas, EG(scope)->name
contains "reflection_class" at the moment I'm trying to check it.
Something like EG(prev_execute_data) might help, but I'm not sure I
should be using it:)

> Could you have a try with those? Also i have
> already incorporated the other patch so you need to update the engine
> sources.

I saw that, but you missed this one (fixes the following segfault:

$ cat reflection_segfault.php
<?php
   $r= new Reflection_Class(NULL);
?>
$ php-dev reflection_segfault.php
Segmentation fault (core dumped)

Attached is a one-line patch that fixes it.

- Timm
Index: zend_reflection_api.c
===================================================================
RCS file: /repository/ZendEngine2/zend_reflection_api.c,v
retrieving revision 1.89
diff -u -r1.89 zend_reflection_api.c
--- zend_reflection_api.c	26 Feb 2004 01:06:18 -0000	1.89
+++ zend_reflection_api.c	26 Feb 2004 07:24:07 -0000
@@ -1800,6 +1800,7 @@
 			zval_add_ref(&argument);
 		}
 	} else { 
+		convert_to_string_ex(&argument);
 		if (zend_lookup_class(Z_STRVAL_P(argument), Z_STRLEN_P(argument), &ce TSRMLS_CC) == FAILURE) {
 			zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
 					"Class %s does not exist", Z_STRVAL_P(argument));

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

Reply via email to