]> granicus.if.org Git - php/commitdiff
Tests, fixes and optimisations
authorLeigh <leight@gmail.com>
Tue, 26 Jun 2012 13:57:10 +0000 (14:57 +0100)
committerArpad Ray <arraypad@gmail.com>
Thu, 27 Jun 2013 12:06:22 +0000 (13:06 +0100)
* Amended existing tests to cater for new functionality.
* Implemented fixes and optimisations recommended by NikiC
* Added create_sid to the registered interface. This was breaking
tests. It also now breaks BC for people implementing the interface
directly instead of extending the class.

ext/session/mod_user.h
ext/session/mod_user_class.c
ext/session/session.c
ext/session/tests/session_set_save_handler_class_002.phpt
ext/session/tests/session_set_save_handler_iface_001.phpt

index fd149ccff44fda0c4ecacdaa43d517189644b779..6b2998c42640081ed960fad2678b22eff85459a6 100644 (file)
@@ -24,6 +24,6 @@
 extern ps_module ps_mod_user;
 #define ps_user_ptr &ps_mod_user
 
-PS_FUNCS(user);
+PS_FUNCS_SID(user);
 
 #endif
index 340c2ca97acb17558b1131ac0606eede5a45080e..ea53af9ebe15a46bc6dda5bef4dd17db45410654 100644 (file)
@@ -148,12 +148,12 @@ PHP_METHOD(SessionHandler, create_sid)
 {
        char *id;
 
-       zend_parse_parameters_none();
+       if (zend_parse_parameters_none() == FAILURE) {
+           return;
+       }
 
        id = PS(default_mod)->s_create_sid(&PS(mod_data), NULL TSRMLS_CC);
 
-       RETVAL_STRING(id, 1);
-       efree(id);
-       return;
+       RETURN_STRING(id, 0);
 }
 /* }}} */
index 4b93ffa74ae7430c4087a3b40e8a73dd4696c761..d8de5769fc1d1e1e378939eaf379f3066f9eeec2 100644 (file)
@@ -2083,6 +2083,7 @@ static const zend_function_entry php_session_iface_functions[] = {
        PHP_ABSTRACT_ME(SessionHandlerInterface, write, arginfo_session_class_write)
        PHP_ABSTRACT_ME(SessionHandlerInterface, destroy, arginfo_session_class_destroy)
        PHP_ABSTRACT_ME(SessionHandlerInterface, gc, arginfo_session_class_gc)
+       PHP_ABSTRACT_ME(SessionHandlerInterface, create_sid, arginfo_session_class_create_sid)
        { NULL, NULL, NULL }
 };
 /* }}} */
@@ -2096,7 +2097,6 @@ static const zend_function_entry php_session_class_functions[] = {
        PHP_ME(SessionHandler, write, arginfo_session_class_write, ZEND_ACC_PUBLIC)
        PHP_ME(SessionHandler, destroy, arginfo_session_class_destroy, ZEND_ACC_PUBLIC)
        PHP_ME(SessionHandler, gc, arginfo_session_class_gc, ZEND_ACC_PUBLIC)
-/* Added to the class but not the interface, to maintain backwards compatibility */
        PHP_ME(SessionHandler, create_sid, arginfo_session_class_create_sid, ZEND_ACC_PUBLIC)
        { NULL, NULL, NULL }
 };
index 6fb831f6957a16ca638f3de74057d6d513ddb501..4195a163a73c86a8a9c03c0ed471e80162eb4f95 100644 (file)
@@ -53,6 +53,10 @@ class MySession2 extends SessionHandler {
                }
                return true;
        }
+       
+       public function create_sid() {
+               return parent::create_sid();
+       }
 }
 
 $handler = new MySession2;
index 39a4b9975b58966e99596d49fa431b7b1d331878..0576341a109f762f78d4d609776bfbb8352cd0de 100644 (file)
@@ -53,6 +53,10 @@ class MySession2 implements SessionHandlerInterface {
                }
                return true;
        }
+       
+       public function create_sid() {
+               return md5(mt_rand());
+       }
 }
 
 $handler = new MySession2;