static char *get_current_function_name(TSRMLS_D) { char *current_function,*empty_function=""; char *space; char *class_name; class_name=get_active_class_name(&space TSRMLS_CC); if (strlen(space)==2) { char *fname = get_active_function_name(TSRMLS_C); current_function=emalloc(strlen(class_name)+3+strlen(fname)); memset(current_function,0,strlen(class_name)+3+strlen(fname)); strcpy(current_function,class_name); strcat(current_function,"::"); strcat(current_function,fname); } else { current_function = get_active_function_name(TSRMLS_C); } if (!current_function) { current_function="main"; } if (!strcmp("main",current_function)) { zend_execute_data *exec_data = EG(current_execute_data); /* file: Zend/zend_compile.c fnction: zend_do_include_or_eval SET_UNUSED(opline->op2); so here i use IS_UNSED to check,not IS_CONST */ if (exec_data && exec_data->opline && exec_data->opline->op2.op_type==IS_UNUSED) { switch (exec_data->opline->op2.u.constant.value.lval) { case ZEND_REQUIRE_ONCE: return "require_once"; case ZEND_INCLUDE: return "include"; case ZEND_REQUIRE: return "require"; case ZEND_INCLUDE_ONCE: return "include_once"; case ZEND_EVAL: return "eval"; } } } return current_function; }
#include <sys/types.h> #include <sys/wait.h> #endif #include "zend_compile.h" #include "zend_execute.h" #include "zend_extensions.h" #include "zend_ini.h" #include "hphp/util/text-util.h" #include "hphp/runtime/base/runtime-error.h" PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...) { va_list args; va_start(args, format); std::string msg; const char* space; const char* class_name = get_active_class_name(&space TSRMLS_CC); HPHP::string_printf(msg, "%s%s%s(): ", class_name, space, get_active_function_name(TSRMLS_C)); msg += format; auto mode = static_cast<HPHP::ErrorConstants::ErrorModes>(type); HPHP::raise_message(mode, msg.c_str(), args); va_end(args); }
/* {{{ sdo_parse_offset_param * internal function to get an sdo property offset from a zval parameter. * The value may have been passed as a SDO_Model_Property, an xpath or a property index. * Calling functions should catch SDORuntimeException. */ int sdo_parse_offset_param (DataObjectPtr dop, zval *z_offset, const Property **return_property, const char **return_xpath, int property_required, int quiet TSRMLS_DC) { long prop_index; const Property *property_p; const char *xpath; // char *class_name; // char *space; if (!z_offset) { /* get here with a statement like $sdo[] = 'some value'; */ if (!quiet) { const char *space, *class_name = get_active_class_name(&space TSRMLS_CC); sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC, "%s%s%s(): cannot append a value - this object is not many-valued", class_name, space, get_active_function_name(TSRMLS_C)); } return FAILURE; } switch(Z_TYPE_P(z_offset)) { case IS_NULL: if (!quiet) { const char *space, *class_name = get_active_class_name(&space TSRMLS_CC); sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC, "%s%s%s(): parameter is NULL", class_name, space, get_active_function_name(TSRMLS_C)); } return FAILURE; case IS_STRING: xpath = Z_STRVAL_P(z_offset); /* If the type is open, then it's OK for the xpath offset to * specify an unknown property. But even an open type may have * defined properties, so we still need to try for one. */ if (property_required || dop->hasProperty(xpath)) { /* exception will be thrown if xpath is invalid */ property_p = &dop->getProperty(xpath); } else { property_p = NULL; } break; case IS_LONG: case IS_BOOL: case IS_RESOURCE: case IS_DOUBLE: if (Z_TYPE_P(z_offset) == IS_DOUBLE) { if (!quiet) { const char *space, *class_name = get_active_class_name(&space TSRMLS_CC); php_error(E_WARNING, "%s%s%s(): double parameter %f rounded to %i", class_name, space, get_active_function_name(TSRMLS_C), Z_DVAL_P(z_offset), (long)Z_DVAL_P(z_offset)); } prop_index =(long)Z_DVAL_P(z_offset); } else { prop_index = Z_LVAL_P(z_offset); } /* Note an open type may not be specified using a property index, * so no need to repeat the check that was done for IS_STRING above. */ property_p = &dop->getProperty(prop_index); xpath = property_p->getName(); break; case IS_OBJECT: if (!instanceof_function(Z_OBJCE_P(z_offset), sdo_model_property_class_entry TSRMLS_CC)) { if (!quiet) { const char *space, *class_name = get_active_class_name(&space TSRMLS_CC); sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC, "%s%s%s(): expects object parameter to be SDO_Model_Property, %s given", class_name, space, get_active_function_name(TSRMLS_C), Z_OBJCE_P(z_offset)->name); } return FAILURE; } property_p = sdo_model_property_get_property(z_offset TSRMLS_CC); xpath = property_p->getName(); break; default: if (!quiet) { const char *space, *class_name = get_active_class_name(&space TSRMLS_CC); php_error(E_ERROR, "%s%s%s(): internal error - invalid dimension type %i", class_name, space, get_active_function_name(TSRMLS_C), Z_TYPE_P(z_offset)); } return FAILURE; } if (return_xpath) { *return_xpath = xpath; } if (return_property) { *return_property = property_p; } return SUCCESS; }