Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into rfc/escaper
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 32 changed files with 1,030 additions and 1,439 deletions.
14 changes: 8 additions & 6 deletions src/AbstractManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Session;

use Zend\Session\ManagerInterface as Manager,
Zend\Session\SaveHandler\SaveHandlerInterface as SaveHandler,
Zend\Session\Storage\StorageInterface as Storage,
Zend\Session\Configuration\ConfigurationInterface as Configuration;

/**
* Base Manager implementation
* Base ManagerInterface implementation
*
* Defines common constructor logic and getters for Storage and Configuration
*
Expand Down Expand Up @@ -76,7 +78,7 @@ abstract class AbstractManager implements Manager
*/
public function __construct(Configuration $config = null, Storage $storage = null, SaveHandler $saveHandler = null)
{
$this->setConfig($config);
$this->setOptions($config);
$this->setStorage($storage);
if ($saveHandler) {
$this->setSaveHandler($saveHandler);
Expand All @@ -89,7 +91,7 @@ public function __construct(Configuration $config = null, Storage $storage = nul
* @param null|Configuration $config
* @return void
*/
public function setConfig(Configuration $config = null)
public function setOptions(Configuration $config = null)
{
if (null === $config) {
$config = new $this->configDefaultClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Session;
namespace Zend\Session\Configuration;

/**
* Standard session configuration
Expand All @@ -31,15 +28,15 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Configuration
interface ConfigurationInterface
{
public function setOptions(array $options);
public function setOption($option, $value);
public function hasOption($option);
public function getOption($option);
public function toArray();

public function setSavePath($path);
public function setSavePath($savePath);
public function getSavePath();

public function setName($name);
Expand All @@ -53,10 +50,10 @@ public function setCookieDomain($cookieDomain);
public function getCookieDomain();
public function setCookieSecure($cookieSecure);
public function getCookieSecure();
public function setCookieHttponly($cookieHTTPOnly);
public function getCookieHTTPOnly();
public function setUseCookies($flag);
public function setCookieHttpOnly($cookieHttpOnly);
public function getCookieHttpOnly();
public function setUseCookies($useCookies);
public function getUseCookies();
public function setRememberMeSeconds($seconds);
public function setRememberMeSeconds($rememberMeSeconds);
public function getRememberMeSeconds();
}
80 changes: 43 additions & 37 deletions src/Configuration/SessionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Session\Configuration;

use Zend\Validator\Hostname\Hostname as HostnameValidator,
use Zend\Validator\Hostname as HostnameValidator,
Zend\Session\Exception;

/**
* Session configuration proxying to session INI options
* Session configuration proxying to session INI options
*
* @category Zend
* @package Zend_Session
Expand Down Expand Up @@ -86,44 +83,45 @@ class SessionConfiguration extends StandardConfiguration
/**
* Set storage option in backend configuration store
*
* Does nothing in this implementation; others might use it to set things
* Does nothing in this implementation; others might use it to set things
* such as INI settings.
*
* @param string $name
* @param mixed $value
* @return Zend\Session\Configuration\StandardConfiguration
*
* @param string $storageName
* @param mixed $storageValue
* @return SessionConfiguration
*/
public function setStorageOption($name, $value)
public function setStorageOption($storageName, $storageValue)
{
$key = false;
switch ($name) {
switch ($storageName) {
case 'remember_me_seconds':
// do nothing; not an INI option
return;
case 'url_rewriter_tags':
$key = 'url_rewriter.tags';
break;
default:
$key = 'session.' . $name;
$key = 'session.' . $storageName;
break;
}

ini_set($key, $value);
ini_set($key, $storageValue);
return $this;
}

/**
* Retrieve a storage option from a backend configuration store
*
* Used to retrieve default values from a backend configuration store.
*
* @param string $name
*
* @param string $storageOption
* @return mixed
*/
public function getStorageOption($name)
public function getStorageOption($storageOption)
{
$key = false;
$transform = false;
switch ($name) {
switch ($storageOption) {
case 'remember_me_seconds':
// No remote storage option; just return the current value
return $this->rememberMeSeconds;
Expand All @@ -135,11 +133,12 @@ public function getStorageOption($name)
case 'use_cookies':
case 'use_only_cookies':
case 'use_trans_sid':
case 'cookie_httponly':
$transform = function ($value) {
return (bool) $value;
};
default:
$key = 'session.' . $name;
$key = 'session.' . $storageOption;
break;
}

Expand All @@ -152,9 +151,9 @@ public function getStorageOption($name)

/**
* Handle PHP errors
*
* @param int $code
* @param string $message
*
* @param int $code
* @param string $message
* @return void
*/
protected function handleError($code, $message)
Expand All @@ -165,10 +164,10 @@ protected function handleError($code, $message)

/**
* Set session.save_handler
*
* @param string $phpSaveHandler
*
* @param string $phpSaveHandler
* @return SessionConfiguration
* @throws SessionException
* @throws Exception\InvalidArgumentException
*/
public function setPhpSaveHandler($phpSaveHandler)
{
Expand All @@ -186,10 +185,10 @@ public function setPhpSaveHandler($phpSaveHandler)

/**
* Set session.serialize_handler
*
* @param string $serializeHandler
*
* @param string $serializeHandler
* @return SessionConfiguration
* @throws SessionException
* @throws Exception\InvalidArgumentException
*/
public function setSerializeHandler($serializeHandler)
{
Expand All @@ -208,6 +207,13 @@ public function setSerializeHandler($serializeHandler)

// session.cache_limiter

/**
* Set cache limiter
*
* @param $cacheLimiter
* @return SessionConfiguration
* @throws Exception\InvalidArgumentException
*/
public function setCacheLimiter($cacheLimiter)
{
$cacheLimiter = (string) $cacheLimiter;
Expand All @@ -218,18 +224,18 @@ public function setCacheLimiter($cacheLimiter)
ini_set('session.cache_limiter', $cacheLimiter);
return $this;
}

/**
* Retrieve list of valid hash functions
*
*
* @return array
*/
protected function getHashFunctions()
{
if (empty($this->validHashFunctions)) {
/**
* @see http://php.net/manual/en/session.configuration.php#ini.session.hash-function
* "0" and "1" refer to MD5-128 and SHA1-160, respectively, and are
* "0" and "1" refer to MD5-128 and SHA1-160, respectively, and are
* valid in addition to whatever is reported by hash_algos()
*/
$this->validHashFunctions = array('0', '1') + hash_algos();
Expand All @@ -239,10 +245,10 @@ protected function getHashFunctions()

/**
* Set session.hash_function
*
* @param string|int $hashFunction
*
* @param string|int $hashFunction
* @return SessionConfiguration
* @throws SessionException
* @throws Exception\InvalidArgumentException
*/
public function setHashFunction($hashFunction)
{
Expand All @@ -259,10 +265,10 @@ public function setHashFunction($hashFunction)

/**
* Set session.hash_bits_per_character
*
* @param int $hashBitsPerCharacter
*
* @param int $hashBitsPerCharacter
* @return SessionConfiguration
* @throws SessionException
* @throws Exception\InvalidArgumentException
*/
public function setHashBitsPerCharacter($hashBitsPerCharacter)
{
Expand Down
Loading

0 comments on commit 4d8294f

Please sign in to comment.