Browse Source

Remove duplicate code.

Use a shutdown function to close the session off.
This removes a bit of icky code and continues to allow
objects to be used as session handlers.
mark_story 14 years ago
parent
commit
f3464b002f

+ 0 - 4
lib/Cake/Controller/Controller.php

@@ -766,10 +766,6 @@ class Controller extends Object implements CakeEventListener {
 		$response = $event->result;
 		extract($this->_parseBeforeRedirect($response, $url, $status, $exit), EXTR_OVERWRITE);
 
-		if (function_exists('session_write_close')) {
-			session_write_close();
-		}
-
 		if ($url !== null) {
 			$this->response->header('Location', Router::url($url, true));
 		}

+ 3 - 1
lib/Cake/Model/Datasource/CakeSession.php

@@ -122,7 +122,7 @@ class CakeSession {
 	public static $requestCountdown = 10;
 
 /**
- * Constructor.
+ * Pseudo constructor.
  *
  * @param string $base The base path for the Session
  * @return void
@@ -136,6 +136,8 @@ class CakeSession {
 		}
 		self::_setPath($base);
 		self::_setHost(env('HTTP_HOST'));
+
+		register_shutdown_function('session_write_close');
 	}
 
 /**

+ 0 - 18
lib/Cake/Model/Datasource/Session/CacheSession.php

@@ -87,22 +87,4 @@ class CacheSession implements CakeSessionHandlerInterface {
 		return Cache::gc(Configure::read('Session.handler.config'), $expires);
 	}
 
-/**
- * Writes and closes a session
- * 
- * @return void 
- */
-	protected function _writeSession() {
-		session_write_close();
-	}
-
-/**
- * Closes the session before the objects handling it become unavailable
- *
- * @return void
- */
-	public function __destruct() {
-		$this->_writeSession();
-	}
-
 }

+ 0 - 18
lib/Cake/Model/Datasource/Session/DatabaseSession.php

@@ -141,22 +141,4 @@ class DatabaseSession implements CakeSessionHandlerInterface {
 		return $this->_model->deleteAll(array($this->_model->alias . ".expires <" => $expires), false, false);
 	}
 
-/**
- * Writes and closes a session
- * 
- * @return void 
- */
-	protected function _writeSession() {
-		session_write_close();
-	}
-
-/**
- * Closes the session before the objects handling it become unavailable
- *
- * @return void
- */
-	public function __destruct() {
-		$this->_writeSession();
-	}
-
 }