Navigation Menu

Skip to content

Commit

Permalink
Minor updates for the Cookie/Sessions changes
Browse files Browse the repository at this point in the history
For install
  • Loading branch information
brendo committed Jun 28, 2016
1 parent 5b77757 commit 87f5cf8
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 26 deletions.
16 changes: 15 additions & 1 deletion install/migrations/3.0.0.php
Expand Up @@ -22,7 +22,21 @@ static function upgrade()
ADD `order` int(11) SIGNED NOT NULL DEFAULT '0',
");
}
catch (Exception $ex) {}
catch (Exception $ex) {

}

// Add in new Session configuration options, RE: #2135
Symphony::Configuration()->setArray(array(
'session' => array(
'admin_session_name' => 'symphony_admin',
'public_session_name' => 'symphony_public',
'admin_session_expires' => '2 weeks',
'public_session_expires' => '2 weeks',
'session_gc_probability' => '1',
'session_gc_divisor' => Symphony::Configuration()->get('session_gc_divisor', 'symphony')
)
));

// Update the version information
return parent::upgrade();
Expand Down
1 change: 0 additions & 1 deletion symphony/content/content.ajaxquery.php
Expand Up @@ -6,7 +6,6 @@
* The AjaxQuery returns an JSON array of entries, associations and other
* static values, depending on the parameters received.
*/

class contentAjaxQuery extends JSONPage
{
public function view()
Expand Down
2 changes: 0 additions & 2 deletions symphony/lib/core/class.cookies.php
Expand Up @@ -3,8 +3,6 @@
* @package core
*/

require_once CORE . '/class.container.php';

/**
* Cookies is a collection of currently set cookies, and user set cookies for
* this request.
Expand Down
4 changes: 2 additions & 2 deletions symphony/lib/core/class.databasesessionhandler.php
Expand Up @@ -43,12 +43,12 @@ class DatabaseSessionHandler implements SessionHandlerInterface
* Constructor
* @param array $settings
*/
public function __construct($database, array $settings = array())
public function __construct($database, array $settings = array(), $key = 'symphony')
{
$this->database = $database;

$this->settings = array_merge([
'session_name' => 'symphony_session',
'session_name' => $key,
'session_lifetime' => ini_get('session.gc_maxlifetime'),
], $settings);

Expand Down
2 changes: 0 additions & 2 deletions symphony/lib/core/class.session.php
Expand Up @@ -3,8 +3,6 @@
* @package core
*/

require_once CORE . '/class.container.php';

/**
* Session
*/
Expand Down
2 changes: 1 addition & 1 deletion symphony/lib/core/class.sessionflash.php
Expand Up @@ -31,7 +31,7 @@ class SessionFlash
* @param Session $session
* @param string $key
*/
public function __construct(Session $session, $key = 'flash')
public function __construct(Session $session, $key = 'symphony_flash')
{
$this->session = $session;
$this->key = $key;
Expand Down
27 changes: 11 additions & 16 deletions symphony/lib/core/class.symphony.php
Expand Up @@ -55,24 +55,17 @@ abstract class Symphony implements Singleton
*/
private static $namespace = false;

/**
* A previous exception that has been fired. Defaults to null.
* @since Symphony 2.3.2
* @var Exception
*/
private $exception = null;

/**
* An instance of the Cookies class
* @var Cookies
*/
public $Cookies = null;
public static $Cookies = null;

/**
* An instance of the Session class
* @var Session
*/
public $Session = null;
public static $Session = null;

/**
* An instance of the SessionFlash class
Expand Down Expand Up @@ -274,8 +267,8 @@ public static function Log()

/**
* Setter for `$Session`. This will use PHP's parse_url
* function on the current URL to set a session using the *_session_name
* defined in the Symphony configuration. The * is either admin or public.
* function on the current URL to set a session using the `session_name`
* defined in the Symphony configuration. The is either admin or public.
* The session will last for the time defined in configuration.
*
* @since Symphony 3.0
Expand All @@ -286,21 +279,24 @@ public function initialiseSessionAndCookies()
$timeout = $this->getSessionTimeout();
$cookie_path = DIRROOT === '' ? '/' : DIRROOT;

$name = null;
if (class_exists('Administration', false)) {
$name = self::Configuration()->get('admin_session_name', 'session');
} else {
$name = self::Configuration()->get('public_session_name', 'session');
}

if (is_null($name)) {
$name = 'symphony';
}

// The handler accepts a database in a move towards dependency injection
$handler = new DatabaseSessionHandler(self::Database(), array(
'session_name' => $name,
'session_lifetime' => $timeout
));
), $name);

// The session accepts a handler in a move towards dependency injection
self::$Session = new Session($handler, array(
'session_name' => $name,
'session_gc_probability' => self::Configuration()->get('session_gc_probability', 'session'),
'session_gc_divisor' => self::Configuration()->get('session_gc_divisor', 'session'),
'session_gc_maxlifetime' => $timeout,
Expand All @@ -309,8 +305,7 @@ public function initialiseSessionAndCookies()
'session_cookie_domain' => null,
'session_cookie_secure' => (defined(__SECURE__) ? true : false),
'session_cookie_httponly' => true

));
), $name);

// Initialise the cookie handler
self::$Cookies = new Cookies(array(
Expand Down
6 changes: 5 additions & 1 deletion vendor/composer/autoload_classmap.php
Expand Up @@ -15,11 +15,13 @@
'CacheDatabase' => $baseDir . '/symphony/lib/toolkit/cache/cache.database.php',
'Cacheable' => $baseDir . '/symphony/lib/core/class.cacheable.php',
'Configuration' => $baseDir . '/symphony/lib/core/class.configuration.php',
'Cookie' => $baseDir . '/symphony/lib/core/class.cookie.php',
'Container' => $baseDir . '/symphony/lib/core/class.container.php',
'Cookies' => $baseDir . '/symphony/lib/core/class.cookies.php',
'Cryptography' => $baseDir . '/symphony/lib/toolkit/class.cryptography.php',
'Database' => $baseDir . '/symphony/lib/toolkit/class.database.php',
'DatabaseException' => $baseDir . '/symphony/lib/toolkit/class.database.php',
'DatabaseExceptionHandler' => $baseDir . '/symphony/lib/core/class.symphony.php',
'DatabaseSessionHandler' => $baseDir . '/symphony/lib/core/class.databasesessionhandler.php',
'Datasource' => $baseDir . '/symphony/lib/toolkit/class.datasource.php',
'DatasourceManager' => $baseDir . '/symphony/lib/toolkit/class.datasourcemanager.php',
'DateTimeObj' => $baseDir . '/symphony/lib/core/class.datetimeobj.php',
Expand Down Expand Up @@ -87,6 +89,8 @@
'SectionManager' => $baseDir . '/symphony/lib/toolkit/class.sectionmanager.php',
'SendmailGateway' => $baseDir . '/symphony/lib/toolkit/email-gateways/email.sendmail.php',
'Session' => $baseDir . '/symphony/lib/core/class.session.php',
'SessionFlash' => $baseDir . '/symphony/lib/core/class.sessionflash.php',
'SessionHandlerInterface' => $baseDir . '/symphony/lib/core/class.databasesessionhandler.php',
'Singleton' => $baseDir . '/symphony/lib/interface/interface.singleton.php',
'Sortable' => $baseDir . '/symphony/content/class.sortable.php',
'StaticXMLDatasource' => $baseDir . '/symphony/lib/toolkit/data-sources/class.datasource.static.php',
Expand Down

0 comments on commit 87f5cf8

Please sign in to comment.