diff -ur E:\source\c\bcompiler_orig/bcompiler.c E:\source\c\bcompiler_fixed/bcompiler.c --- E:\source\c\bcompiler_orig/bcompiler.c 2008-05-02 10:31:58.655340900 +0200 +++ E:\source\c\bcompiler_fixed/bcompiler.c 2008-05-02 10:44:13.446492600 +0200 @@ -437,7 +437,12 @@ file_handle->opened_path = estrdup(file_handle->filename); /* read bytecodes */ BCOMPILERG(current_include) = 1; + /* daniel: added currentfile to set the real filename/path when running a compiled script */ + BCOMPILERG(currentfile) = (char *) emalloc(strlen(file_handle->filename)); + BCOMPILERG(currentfile) = estrdup(file_handle->filename); op_array = bcompiler_read(TSRMLS_C); + BCOMPILERG(currentfile) = NULL; + efree(BCOMPILERG(currentfile)); if (!op_array) op_array = dummy_op_array(TSRMLS_C); #if 0 /* val: buffer allocation changed, so it can't be used anymore */ BCOMPILERG(buffer) = (char *) emalloc(1); /* avoid 1 byte memory leak */ @@ -1435,6 +1440,11 @@ char *key = NULL; int key_len; + /* daniel: This may should be done only if needed when restoring op_array */ + zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC); + zend_is_auto_global("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC); + zend_is_auto_global("_ENV", sizeof("_ENV")-1 TSRMLS_CC); + BCOMPILERG(parsing_error) = 0; DESERIALIZE_SCALAR_V(&item, char, BCOMPILER_READ_RESULT); @@ -1882,9 +1892,12 @@ } #endif -#if VAL_0 /* val: disabled since all PHP versions work without it */ +//#if VAL_0 /* val: disabled since all PHP versions work without it */ /* inherit: recursively inherit methods from base to all the children * of parent, the children of parent's children, and so on */ +/* daniel: put it back in so old styled classes work better + maybe it can be thrown out in later versions +*/ static void bcompiler_inherit(zend_class_entry* base TSRMLS_DC) { @@ -1908,7 +1921,7 @@ } } -#endif +//#endif @@ -2305,6 +2318,7 @@ #ifdef ZEND_ENGINE_2_1 if (zc->__unset == old) zc->__unset = act; if (zc->__isset == old) zc->__isset = act; + if (zc->__tostring == old) zc->__tostring = act; /* daniel: Added __tostring */ if (zc->serialize_func == old) zc->serialize_func = act; if (zc->unserialize_func == old) zc->unserialize_func = act; #endif @@ -2973,7 +2987,10 @@ apc_serialize_zstring(force_key, UBYTES(-force_key_len) TSRMLS_CC); } else { #endif - SERIALIZE_SCALAR(force_key_len, char); + /* daniel: one can't use char at this point since there are hash keys which are are longer + then 127 Characters. When restored, the opcode gets changed (ZEND_DECLARE_INHERITED_CLASS was + missing in that cases) */ + SERIALIZE_SCALAR(force_key_len, int); apc_serialize_zstring(force_key, force_key_len TSRMLS_CC); #if PHP_MAJOR_VERSION >= 6 } @@ -3168,7 +3185,8 @@ if (key_len) *key_len = 0; if (key) *key = NULL; if (BCOMPILERG(current_version) >= 0x0005) { - DESERIALIZE_SCALAR(&exists, char); + /* daniel: See apc_serialize_zend_class_entry why this must be int*/ + DESERIALIZE_SCALAR(&exists, int); if (exists > 0 && key_len && key) { *key_len = exists; apc_create_string2(key, -1 TSRMLS_CC); @@ -3187,11 +3205,14 @@ Since we now can do inheritance by striping - this is usefull.. */ -#if VAL_0 /* val: all PHP versions work fine without it */ +//#if VAL_0 /* val: all PHP versions work fine without it */ +/* daniel: No they doesn't. Old styled classes in PHP5 seems to need it. + Otherwise calling parent constructor with $this->parentClassName() wont be + resolved */ if (zce->parent) { bcompiler_inherit(zce TSRMLS_CC); } -#endif +//#endif if (parent_name) { apclib_free_string(&parent_name); } @@ -3411,7 +3432,12 @@ assert(zoa->start_op == NULL); SERIALIZE_SCALAR(zoa->return_reference, zend_bool); SERIALIZE_SCALAR(zoa->done_pass_two, zend_bool); - apc_serialize_string(zoa->filename TSRMLS_CC); + /* daniel: Throwed away storing of filename and ...*/ + //apc_serialize_string(zoa->filename TSRMLS_CC); + /* daniel: ... serialize only string. So compatibility to erlier versions is given. + filename op_array filename will be set during deserialisation so the real path will + be shown if an error occours */ + apc_serialize_string("string" TSRMLS_CC); #ifdef ZEND_ENGINE_2 if (BCOMPILERG(current_write) >= 0x0005) { @@ -3670,8 +3696,9 @@ DESERIALIZE_SCALAR(&zoa->return_reference, zend_bool); DESERIALIZE_SCALAR(&zoa->done_pass_two, zend_bool); - apc_create_string2(&fname, -1 TSRMLS_CC); - zoa->filename = zend_set_compiled_filename(fname TSRMLS_CC); + apc_create_string2(&fname, -1 TSRMLS_CC); /* daniel: returns 'string' now */ + /* daniel: setting the real filename */ + zoa->filename = zend_set_compiled_filename(BCOMPILERG(currentfile) TSRMLS_CC); apclib_free_string(&fname); #ifdef ZEND_ENGINE_2 if (BCOMPILERG(current_version) >= 0x0005) { @@ -3861,6 +3888,10 @@ BCOMPILER_DEBUG(("> it's an __isset handler\n")); ftype |= 0x80; } + if (zf == zc->__tostring) { /* daniel: Added __tostring */ + BCOMPILER_DEBUG(("> it's a __tostring handler\n")); + ftype |= 0x90; + } if (zf == zc->serialize_func) { BCOMPILER_DEBUG(("> it's a serialize_func handler\n")); ftype |= 0x100; @@ -3927,6 +3958,7 @@ #ifdef ZEND_ENGINE_2_1 if (ftype & 0x40) zc->__unset = zf; if (ftype & 0x80) zc->__isset = zf; + if (ftype & 0x90) zc->__tostring = zf; /* daniel: Added __tostring */ if (ftype & 0x100) zc->serialize_func = zf; if (ftype & 0x200) zc->unserialize_func = zf; #endif diff -ur E:\source\c\bcompiler_orig/php_bcompiler.h E:\source\c\bcompiler_fixed/php_bcompiler.h --- E:\source\c\bcompiler_orig/php_bcompiler.h 2008-05-02 10:32:12.139111800 +0200 +++ E:\source\c\bcompiler_fixed/php_bcompiler.h 2008-05-02 10:45:07.726353000 +0200 @@ -85,6 +85,7 @@ int current_include; /* read file after bcompiler_write_file() */ int parsing_error; /* i/o error while parsing, skip file */ const size_t *bcompiler_stdsize; /* array of standard data sizes */ + char *currentfile; /* daniel: the current (compiled)file */ zend_class_entry *cur_zc; /* current class entry */ ZEND_END_MODULE_GLOBALS(bcompiler)