]> granicus.if.org Git - php/commitdiff
Provide a meaningful error message when registration fails
authorSara Golemon <pollita@php.net>
Wed, 17 Mar 2004 00:08:22 +0000 (00:08 +0000)
committerSara Golemon <pollita@php.net>
Wed, 17 Mar 2004 00:08:22 +0000 (00:08 +0000)
main/streams/userspace.c

index cf1c4d4c1e7e0dc4eafd67c634a2f62c127abf8d..5ed06d344bae596f7162ea330e57843d411f543a 100644 (file)
@@ -421,10 +421,17 @@ PHP_FUNCTION(stream_wrapper_register)
                uwrap->ce = *(zend_class_entry**)uwrap->ce;
                if (php_register_url_stream_wrapper(protocol, &uwrap->wrapper TSRMLS_CC) == SUCCESS) {
                        RETURN_TRUE;
+               } else {
+                       /* We failed.  But why? */
+                       if (zend_hash_exists(php_stream_get_url_stream_wrappers_hash(), protocol, protocol_len)) {
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Protocol %s:// is already defined.", protocol);
+                       } else {
+                               /* Should never happen */
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to register wrapper class %s to %s://", classname, protocol);
+                       }
                }
        } else {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "class '%s' is undefined",
-                               classname);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "class '%s' is undefined", classname);
        }
 
        zend_list_delete(rsrc_id);