sniper          Mon Aug 25 22:03:42 2003 EDT

  Modified files:              
    /php-src/ext/session        session.c 
  Log:
  - Prevent crash if non-existing save/serializer handler is tried to be used
  - Added the registered serializers information to MINFO.
  
  
Index: php-src/ext/session/session.c
diff -u php-src/ext/session/session.c:1.371 php-src/ext/session/session.c:1.372
--- php-src/ext/session/session.c:1.371 Wed Aug 13 21:30:06 2003
+++ php-src/ext/session/session.c       Mon Aug 25 22:03:41 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: session.c,v 1.371 2003/08/14 01:30:06 iliaa Exp $ */
+/* $Id: session.c,v 1.372 2003/08/26 02:03:41 sniper Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -92,17 +92,11 @@
                return FAILURE;
        }
        PS(mod) = _php_find_ps_module(new_value TSRMLS_CC);
-/*
- * Following lines are commented out to prevent bogus error message at
- * start up. i.e. Save handler modules are not initilzied before Session
- * module.
- */
 
-#if 0
-       if(!PS(mod)) {
+       if (PG(modules_activated) && !PS(mod)) {
                php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot find save handler 
%s", new_value);
        }
-#endif
+
        return SUCCESS;
 }
 
@@ -113,17 +107,11 @@
                return FAILURE;
        }
        PS(serializer) = _php_find_ps_serializer(new_value TSRMLS_CC);
-/*
- * Following lines are commented out to prevent bogus error message at
- * start up. i.e. Serializer modules are not initilzied before Session
- * module.
- */
 
-#if 0
-       if(!PS(serializer)) {
+       if (PG(modules_activated) && !PS(serializer)) {
                php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot find serialization 
handler %s", new_value);
        }
-#endif
+
        return SUCCESS;
 }
 
@@ -1749,26 +1737,46 @@
 PHP_MINFO_FUNCTION(session)
 {
        ps_module **mod;
-       smart_str handlers = {0};
+       ps_serializer *ser;
+       smart_str save_handlers = {0};
+       smart_str ser_handlers = {0};
        int i;
        
+       /* Get save handlers */
        for (i = 0, mod = ps_modules; i < MAX_MODULES; i++, mod++) {
                if (*mod && (*mod)->s_name) {
-                       smart_str_appends(&handlers, (*mod)->s_name);
-                       smart_str_appendc(&handlers, ' ');
+                       smart_str_appends(&save_handlers, (*mod)->s_name);
+                       smart_str_appendc(&save_handlers, ' ');
+               }
+       }
+
+       /* Get serializer handlers */
+       for (i = 0, ser = ps_serializers; i < MAX_SERIALIZERS; i++, ser++) {
+               if (ser && ser->name) {
+                       smart_str_appends(&ser_handlers, ser->name);
+                       smart_str_appendc(&ser_handlers, ' ');
                }
        }
        
        php_info_print_table_start();
        php_info_print_table_row(2, "Session Support", "enabled" );
 
-       if (handlers.c) {
-               smart_str_0(&handlers);
-               php_info_print_table_row(2, "Registered save handlers", handlers.c);
-               smart_str_free(&handlers);
+       if (save_handlers.c) {
+               smart_str_0(&save_handlers);
+               php_info_print_table_row(2, "Registered save handlers", 
save_handlers.c);
+               smart_str_free(&save_handlers);
        } else {
                php_info_print_table_row(2, "Registered save handlers", "none");
        }
+
+       if (ser_handlers.c) {
+               smart_str_0(&ser_handlers);
+               php_info_print_table_row(2, "Registered serializer handlers", 
ser_handlers.c);
+               smart_str_free(&ser_handlers);
+       } else {
+               php_info_print_table_row(2, "Registered serializer handlers", "none");
+       }
+
        php_info_print_table_end();
 
        DISPLAY_INI_ENTRIES();

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to