diff options
-rw-r--r-- | Zend/zend_API.h | 1 | ||||
-rw-r--r-- | ext/fileinfo/fileinfo.c | 2 | ||||
-rw-r--r-- | ext/fileinfo/tests/precedural_finfo_in_method.phpt | 18 |
3 files changed, 20 insertions, 1 deletions
diff --git a/Zend/zend_API.h b/Zend/zend_API.h index b23b5b32f0..b2faf7e253 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -342,6 +342,7 @@ ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *na ZEND_API char *zend_get_type_by_const(int type); #define getThis() (Z_OBJ(EX(This)) ? &EX(This) : NULL) +#define ZEND_IS_METHOD_CALL() (EX(func)->common.scope != NULL) #define WRONG_PARAM_COUNT ZEND_WRONG_PARAM_COUNT() #define WRONG_PARAM_COUNT_WITH_RETVAL(ret) ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c index f365b38573..6879926eca 100644 --- a/ext/fileinfo/fileinfo.c +++ b/ext/fileinfo/fileinfo.c @@ -57,7 +57,7 @@ typedef struct _finfo_object { } finfo_object; #define FILEINFO_DECLARE_INIT_OBJECT(object) \ - zval *object = getThis(); + zval *object = ZEND_IS_METHOD_CALL() ? getThis() : NULL; static inline finfo_object *php_finfo_fetch_object(zend_object *obj) { return (finfo_object *)((char*)(obj) - XtOffsetOf(finfo_object, zo)); diff --git a/ext/fileinfo/tests/precedural_finfo_in_method.phpt b/ext/fileinfo/tests/precedural_finfo_in_method.phpt new file mode 100644 index 0000000000..8c30b8a197 --- /dev/null +++ b/ext/fileinfo/tests/precedural_finfo_in_method.phpt @@ -0,0 +1,18 @@ +--TEST-- +Using procedural finfo API in a method +--FILE-- +<?php + +class Test { + public function method() { + $finfo = finfo_open(FILEINFO_MIME); + var_dump(finfo_file($finfo, __FILE__)); + } +} + +$test = new Test; +$test->method(); + +?> +--EXPECT-- +string(28) "text/plain; charset=us-ascii" |