cvs: php4 /ext/standard/ dl.c /main/ fopen-wrappers.c main.c
| From: | Zeev Suraski | Date: | Mon, 12 Jun 2000 20:22:17 +0000 |
| Subject: | cvs: php4 /ext/standard/ dl.c /main/ fopen-wrappers.c main.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-203@lists.php.net to get a copy of this message | ||
zeev Mon Jun 12 13:22:17 2000 EDT
Modified files:
/php4/ext/standard dl.c
/php4/main fopen-wrappers.c main.c
Log:
Avoid using E_CORE_* errorlevels in any place which is not in the global startup sequence
Index: php4/ext/standard/dl.c
diff -u php4/ext/standard/dl.c:1.43 php4/ext/standard/dl.c:1.44
--- php4/ext/standard/dl.c:1.43 Thu Jun 8 17:43:43 2000
+++ php4/ext/standard/dl.c Mon Jun 12 13:22:16 2000
@@ -35,12 +35,15 @@
#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 @@
} 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 @@
#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 @@
/* 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 @@
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 @@
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 @@
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 @@
#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: php4/main/fopen-wrappers.c
diff -u php4/main/fopen-wrappers.c:1.62 php4/main/fopen-wrappers.c:1.63
--- php4/main/fopen-wrappers.c:1.62 Fri Jun 9 06:50:39 2000
+++ php4/main/fopen-wrappers.c Mon Jun 12 13:22:17 2000
@@ -16,7 +16,7 @@
| Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: fopen-wrappers.c,v 1.62 2000/06/09 13:50:39 andrei Exp $ */
+/* $Id: fopen-wrappers.c,v 1.63 2000/06/12 20:22:17 zeev Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -361,7 +361,7 @@
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: php4/main/main.c
diff -u php4/main/main.c:1.267 php4/main/main.c:1.268
--- php4/main/main.c:1.267 Mon Jun 12 09:07:25 2000
+++ php4/main/main.c Mon Jun 12 13:22:17 2000
@@ -19,7 +19,7 @@
*/
-/* $Id: main.c,v 1.267 2000/06/12 16:07:25 zeev Exp $ */
+/* $Id: main.c,v 1.268 2000/06/12 20:22:17 zeev Exp $ */
#include <stdio.h>
@@ -364,29 +364,27 @@
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 @@
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':