]> granicus.if.org Git - php/commitdiff
Avoid using E_CORE_* errorlevels in any place which is not in the global startup...
authorZeev Suraski <zeev@php.net>
Mon, 12 Jun 2000 20:22:17 +0000 (20:22 +0000)
committerZeev Suraski <zeev@php.net>
Mon, 12 Jun 2000 20:22:17 +0000 (20:22 +0000)
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_builtin_functions.c
ext/standard/dl.c
main/fopen_wrappers.c
main/main.c

index 10543b686b21401336250cf89fd29e4b686e17e3..984ac63c19b8473fa5d9ad0170c529244e6df5c8 100644 (file)
@@ -188,7 +188,7 @@ ZEND_API inline int _array_init(zval *arg ZEND_FILE_LINE_DC)
        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;
@@ -707,15 +707,22 @@ ZEND_API int zend_startup_module(zend_module_entry *module)
 
 
 /* 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);
        }
@@ -726,7 +733,7 @@ int zend_register_functions(zend_function_entry *functions, HashTable *function_
                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;
                }
@@ -740,7 +747,7 @@ int zend_register_functions(zend_function_entry *functions, HashTable *function_
        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++;
                }
@@ -782,7 +789,7 @@ ZEND_API int zend_register_module(zend_module_entry *module)
 #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;
        }
@@ -908,7 +915,7 @@ ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_
 
 
        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 **) &register_class);
@@ -973,5 +980,5 @@ ZEND_API int zend_disable_function(char *function_name, uint function_name_lengt
                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);
 }
index 8dace5824bfe620138a702c655f85a9eb143fd41..0b3bce4c07ff7702b756c4f11d177301f7d44dd3 100644 (file)
@@ -108,7 +108,7 @@ ZEND_API int zend_get_parameters_array_ex(int param_count, zval ***argument_arra
 
 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);
 
index c149dd82d54a7d40d361aee74026556d2392ef03..0c3d48eac98230fa6423c9d4abac6fc74d94f336 100644 (file)
@@ -107,7 +107,7 @@ static zend_function_entry builtin_functions[] = {
 
 int zend_startup_builtin_functions()
 {
-       return zend_register_functions(builtin_functions, NULL);
+       return zend_register_functions(builtin_functions, NULL, MODULE_PERSISTENT);
 }
 
 
index 978ae54e9056b59aba77ae2a618a45c5b862fec2..0da5875d9e15c499014e8edee8d8de86c4fb624a 100644 (file)
 #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)
@@ -60,7 +63,7 @@ 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);
        }
 }
 
@@ -78,15 +81,22 @@ PHP_FUNCTION(dl)
 #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));
 
@@ -104,21 +114,8 @@ void php_dl(pval *file,int type,pval *return_value)
        /* 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;
        }
 
@@ -138,13 +135,13 @@ void php_dl(pval *file,int type,pval *return_value)
 
        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"
@@ -158,7 +155,7 @@ void php_dl(pval *file,int type,pval *return_value)
        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;
                }
@@ -167,15 +164,15 @@ void php_dl(pval *file,int type,pval *return_value)
 
        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;
@@ -191,9 +188,9 @@ PHP_MINFO_FUNCTION(dl)
 
 #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;
 }
 
index 1fad046d102283d986838113566f9ddb7d16a44b..18129fb0f26e654076543236c448b6ada592c393 100644 (file)
@@ -361,7 +361,7 @@ PHPAPI FILE *php_fopen_primary_script(void)
                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;
        }
index 11887c199ffd73de620d9ab8538f2737283714a2..2e15f8d0a3eb6f2a8f225da770a3b34a7d8b9aa2 100644 (file)
@@ -364,29 +364,27 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
                        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
@@ -1034,7 +1032,7 @@ static int php_hash_environment(ELS_D SLS_DC PLS_DC)
                                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':