ALLOC_HASHTABLE_REL(arg->value.ht);
if (!arg->value.ht || zend_hash_init(arg->value.ht, 0, NULL, ZVAL_PTR_DTOR, 0)) {
- zend_error(E_CORE_ERROR, "Cannot allocate memory for array");
+ zend_error(E_ERROR, "Cannot allocate memory for array");
return FAILURE;
}
arg->type = IS_ARRAY;
/* registers all functions in *library_functions in the function hash */
-int zend_register_functions(zend_function_entry *functions, HashTable *function_table)
+int zend_register_functions(zend_function_entry *functions, HashTable *function_table, int type)
{
zend_function_entry *ptr = functions;
zend_function function;
zend_internal_function *internal_function = (zend_internal_function *)&function;
int count=0,unload=0;
HashTable *target_function_table = function_table;
+ int error_type;
CLS_FETCH();
+ if (type==MODULE_PERSISTENT) {
+ error_type = E_CORE_WARNING;
+ } else {
+ error_type = E_WARNING;
+ }
+
if (!target_function_table) {
target_function_table = CG(function_table);
}
internal_function->arg_types = ptr->func_arg_types;
internal_function->function_name = ptr->fname;
if (!internal_function->handler) {
- zend_error(E_CORE_WARNING,"Null function defined as active function");
+ zend_error(error_type, "Null function defined as active function");
zend_unregister_functions(functions, count, target_function_table);
return FAILURE;
}
if (unload) { /* before unloading, display all remaining bad function in the module */
while (ptr->fname) {
if (zend_hash_exists(target_function_table, ptr->fname, strlen(ptr->fname)+1)) {
- zend_error(E_CORE_WARNING, "Function registration failed - duplicate name - %s",ptr->fname);
+ zend_error(error_type, "Function registration failed - duplicate name - %s",ptr->fname);
}
ptr++;
}
#if 0
zend_printf("%s: Registering module %d\n",module->name, module->module_number);
#endif
- if (module->functions && zend_register_functions(module->functions, NULL)==FAILURE) {
+ if (module->functions && zend_register_functions(module->functions, NULL, module->type)==FAILURE) {
zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load",module->name);
return FAILURE;
}
if (class_entry->builtin_functions) {
- zend_register_functions(class_entry->builtin_functions, &class_entry->function_table);
+ zend_register_functions(class_entry->builtin_functions, &class_entry->function_table, MODULE_PERSISTENT);
}
zend_hash_update(CG(class_table), lowercase_name, class_entry->name_length+1, class_entry, sizeof(zend_class_entry), (void **) ®ister_class);
return FAILURE;
}
disabled_function[0].fname = function_name;
- return zend_register_functions(disabled_function, CG(function_table));
+ return zend_register_functions(disabled_function, CG(function_table), MODULE_PERSISTENT);
}
ZEND_API int ParameterPassedByReference(int ht, uint n);
-int zend_register_functions(zend_function_entry *functions, HashTable *function_table);
+int zend_register_functions(zend_function_entry *functions, HashTable *function_table, int type);
void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table);
ZEND_API int zend_register_module(zend_module_entry *module_entry);
int zend_startup_builtin_functions()
{
- return zend_register_functions(builtin_functions, NULL);
+ return zend_register_functions(builtin_functions, NULL, MODULE_PERSISTENT);
}
#ifdef PHP_WIN32
#include "win32/param.h"
#include "win32/winutil.h"
+#define GET_DL_ERROR() php_win_err()
#else
#include <sys/param.h>
+#define GET_DL_ERROR() dlerror()
#endif
#endif
+
/* {{{ proto int dl(string extension_filename)
Load a PHP extension at runtime */
PHP_FUNCTION(dl)
} else if (PG(safe_mode)) {
php_error(E_ERROR, "Dynamically loaded extensions aren't allowed when running in SAFE MODE.");
} else {
- php_dl(*file,MODULE_TEMPORARY,return_value);
+ php_dl(*file, MODULE_TEMPORARY, return_value);
}
}
#define IS_SLASH(c) \
(((c)=='/') || ((c)=='\\'))
-void php_dl(pval *file,int type,pval *return_value)
+void php_dl(pval *file, int type, pval *return_value)
{
void *handle;
char *libpath;
zend_module_entry *module_entry,*tmp;
zend_module_entry *(*get_module)(void);
+ int error_type;
PLS_FETCH();
ELS_FETCH();
+ if (type==MODULE_TEMPORARY) {
+ error_type = E_WARNING;
+ } else {
+ error_type = E_CORE_WARNING;
+ }
+
if (PG(extension_dir) && PG(extension_dir)[0]){
int extension_dir_len = strlen(PG(extension_dir));
/* load dynamic symbol */
handle = DL_LOAD(libpath);
if (!handle) {
- int error_type;
-
- if (type==MODULE_TEMPORARY) {
- error_type = E_ERROR;
- } else {
- error_type = E_CORE_ERROR;
- }
-#ifdef PHP_WIN32
- php_error(error_type,"Unable to load dynamic library '%s'<br>\n%s",libpath,php_win_err());
-#else
- php_error(error_type,"Unable to load dynamic library '%s' - %s",libpath,dlerror());
-#endif
-
+ php_error(error_type, "Unable to load dynamic library '%s' - %s", libpath, GET_DL_ERROR());
efree(libpath);
-
RETURN_FALSE;
}
if (!get_module) {
DL_UNLOAD(handle);
- php_error(E_CORE_WARNING,"Invalid library (maybe not a PHP library) '%s' ",file->value.str.val);
+ php_error(error_type, "Invalid library (maybe not a PHP library) '%s' ", file->value.str.val);
RETURN_FALSE;
}
module_entry = get_module();
if ((module_entry->zend_debug != ZEND_DEBUG) || (module_entry->zts != USING_ZTS)
|| (module_entry->zend_api != ZEND_MODULE_API_NO)) {
- php_error(E_CORE_WARNING,
+ php_error(error_type,
"%s: Unable to initialize module\n"
"Module compiled with debug=%d, thread-safety=%d module API=%d\n"
"PHP compiled with debug=%d, thread-safety=%d module API=%d\n"
module_entry->module_number = zend_next_free_module();
if (module_entry->module_startup_func) {
if (module_entry->module_startup_func(type, module_entry->module_number ELS_CC)==FAILURE) {
- php_error(E_CORE_WARNING,"%s: Unable to initialize module",module_entry->name);
+ php_error(error_type, "%s: Unable to initialize module", module_entry->name);
DL_UNLOAD(handle);
RETURN_FALSE;
}
if ((type == MODULE_TEMPORARY) && module_entry->request_startup_func) {
if (module_entry->request_startup_func(type, module_entry->module_number ELS_CC)) {
- php_error(E_CORE_WARNING,"%s: Unable to initialize module",module_entry->name);
+ php_error(error_type, "%s: Unable to initialize module", module_entry->name);
DL_UNLOAD(handle);
RETURN_FALSE;
}
}
/* update the .request_started property... */
- if (zend_hash_find(&module_registry,module_entry->name,strlen(module_entry->name)+1,(void **) &tmp)==FAILURE) {
- php_error(E_ERROR,"%s: Loaded module got lost",module_entry->name);
+ if (zend_hash_find(&module_registry, module_entry->name, strlen(module_entry->name)+1,(void **) &tmp)==FAILURE) {
+ php_error(error_type,"%s: Loaded module got lost", module_entry->name);
RETURN_FALSE;
}
tmp->handle = handle;
#else
-void php_dl(pval *file,int type,pval *return_value)
+void php_dl(pval *file, int type, pval *return_value)
{
- php_error(E_WARNING,"Cannot dynamically load %s - dynamic modules are not supported",file->value.str.val);
+ php_error(E_WARNING,"Cannot dynamically load %s - dynamic modules are not supported", file->value.str.val);
RETURN_FALSE;
}
fp = NULL;
}
if (!fp) {
- php_error(E_CORE_ERROR, "Unable to open %s", fn);
+ php_error(E_ERROR, "Unable to open %s", fn);
STR_FREE(SG(request_info).path_translated); /* for same reason as above */
return NULL;
}
va_end(args);
buffer[sizeof(buffer) - 1] = 0;
- if (PG(log_errors) || (!module_initialized)) {
+ if (!module_initialized || PG(log_errors)) {
char log_buffer[1024];
+#ifdef PHP_WIN32
+ if (type==E_CORE_ERROR || type==E_CORE_WARNING) {
+ MessageBox(NULL, buffer, error_type_str, MB_OK);
+ }
+#endif
snprintf(log_buffer, 1024, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno);
php_log_err(log_buffer);
}
- if (PG(display_errors)) {
+ if (module_initialized && PG(display_errors)) {
char *prepend_string = INI_STR("error_prepend_string");
char *append_string = INI_STR("error_append_string");
-#ifdef PHP_WIN32
- if (type==E_CORE_ERROR || type==E_CORE_WARNING)
- MessageBox(NULL, buffer, error_type_str, MB_OK);
- else
-#endif
- {
- if (prepend_string) {
- PUTS(prepend_string);
- }
- php_printf("<br>\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br>\n", error_type_str, buffer, error_filename, error_lineno);
- if (append_string) {
- PUTS(append_string);
- }
+ if (prepend_string) {
+ PUTS(prepend_string);
+ }
+ php_printf("<br>\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br>\n", error_type_str, buffer, error_filename, error_lineno);
+ if (append_string) {
+ PUTS(append_string);
}
}
#if ZEND_DEBUG
if (have_variables_order) {
php_import_environment_variables(ELS_C PLS_CC);
} else {
- php_error(E_CORE_WARNING, "Unsupported 'e' element (environment) used in gpc_order - use variables_order instead");
+ php_error(E_WARNING, "Unsupported 'e' element (environment) used in gpc_order - use variables_order instead");
}
break;
case 's':