10000 Session cleanup by stof · Pull Request #3333 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Session cleanup #3333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 12, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AttributeBag implements AttributeBagInterface
/**
* Constructor.
*
* @param type $storageKey The key used to store flashes in the session.
* @param string $storageKey The key used to store flashes in the session.
*/
public function __construct($storageKey = '_sf2_attributes')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ function replace(array $attributes);
* Removes an attribute.
*
* @param string $name
*
* @return mixed The removed value
*/
function remove($name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class NamespacedAttributeBag extends AttributeBag
/**
* Constructor.
*
* @param type $storageKey Session storage key.
* @param type $namespaceCharacter Namespace character to use in keys.
* @param string $storageKey Session storage key.
* @param string $namespaceCharacter Namespace character to use in keys.
*/
public function __construct($storageKey = '_sf2_attributes', $namespaceCharacter = '/')
{
Expand Down Expand Up @@ -70,25 +70,6 @@ public function set($name, $value)
$attributes[$name] = $value;
}

/**
* {@inheritdoc}
*/
public function all()
{
return $this->attributes;
}

/**
* {@inheritdoc}
*/
public function replace(array $attributes)
{
$this->attributes = array();
foreach ($attributes as $key => $value) {
$this->set($key, $value);
}
}

/**
* {@inheritdoc}
*/
Expand All @@ -105,17 +86,6 @@ public function remove($name)
return $retval;
}

/**
* {@inheritdoc}
*/
public function clear()
{
$return = $this->attributes;
$this->attributes = array();

return $return;
}

/**
* Resolves a path in attributes property and returns it as a reference.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AutoExpireFlashBag implements FlashBagInterface
/**
* Constructor.
*
* @param type $storageKey The key used to store flashes in the session.
* @param string $storageKey The key used to store flashes in the session.
*/
public function __construct($storageKey = '_sf2_flashes')
{
Expand Down
EDBE
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FlashBag implements FlashBagInterface
/**
* Constructor.
*
* @param type $storageKey The key used to store flashes in the session.
* @param string $storageKey The key used to store flashes in the session.
*/
public function __construct($storageKey = '_sf2_flashes')
{
Expand Down
94 changes: 33 additions & 61 deletions src/Symfony/Component/HttpFoundation/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,114 +50,71 @@ public function __construct(SessionStorageInterface $storage, AttributeBagInterf
}

/**
* Starts the session storage.
*
* @return boolean True if session started.
*
* @api
* {@inheritdoc}
*/
public function start()
{
return $this->storage->start();
}

/**
* Checks if an attribute is defined.
*
* @param string $name The attribute name
*
* @return Boolean true if the attribute is defined, false otherwise
*
* @api
* {@inheritdoc}
*/
public function has($name)
{
return $this->storage->getBag('attributes')->has($name);
}

/**
* Returns an attribute.
*
* @param string $name The attribute name
* @param mixed $default The default value
*
* @return mixed
*
* @api
* {@inheritdoc}
*/
public function get($name, $default = null)
{
return $this->storage->getBag('attributes')->get($name, $default);
}

/**
* Sets an attribute.
*
* @param string $name
* @param mixed $value
*
* @api
* {@inheritdoc}
*/
public 1E0A function set($name, $value)
{
$this->storage->getBag('attributes')->set($name, $value);
}

/**
* Returns attributes.
*
* @return array Attributes
*
* @api
* {@inheritdoc}
*/
public function all()
{
return $this->storage->getBag('attributes')->all();
}

/**
* Sets attributes.
*
* @param array $attributes Attributes
*
* @api
* {@inheritdoc}
*/
public function replace(array $attributes)
{
$this->storage->getBag('attributes')->replace($attributes);
}

/**
* Removes an attribute.
*
* @param string $name
*
* @api
* {@inheritdoc}
*/
public function remove($name)
{
return $this->storage->getBag('attributes')->remove($name);
}

/**
* Clears all attributes.
*
* @api
* {@inheritdoc}
*/
public function clear()
{
$this->storage->getBag('attributes')->clear();
}

/**
* Invalidates the current session.
*
* Clears all session attributes and flashes and regenerates the
* session and deletes the old session from persistence.
*
* @return boolean True if session invalidated, false if error.
*
* @api
* {@inheritdoc}
*/
public function invalidate()
{
Expand All @@ -167,14 +124,7 @@ public function invalidate()
}

/**
* Migrates the current session to a new session id while maintaining all
* session attributes.
*
* @param boolean $destroy Whether to delete the old session or leave it to garbage collection.
*
* @return boolean True if session migrated, false if error
*
* @api
* {@inheritdoc}
*/
public function migrate($destroy = false)
{
Expand Down Expand Up @@ -204,7 +154,7 @@ public function getId()
/**
* Implements the \Serialize interface.
*
* @return SessionStorageInterface
* @return string
*/
public function serialize()
{
Expand All @@ -214,6 +164,8 @@ public function serialize()
/**
* Implements the \Serialize interface.
*
* @param string $serialized
*
* @throws \InvalidArgumentException If the passed string does not unserialize to an instance of SessionStorageInterface
*/
public function unserialize($serialized)
Expand Down Expand Up @@ -261,6 +213,8 @@ public function getFlashBag()
// the following methods are kept for compatibility with Symfony 2.0 (they will be removed for Symfony 2.3)

/**
* @return array
*
* @deprecated since 2.1, will be removed from 2.3
*/
public function getFlashes()
Expand All @@ -269,6 +223,8 @@ public function getFlashes()
}

/**
* @param array $values
*
* @deprecated since 2.1, will be removed from 2.3
*/
public function setFlashes($values)
Expand All @@ -277,6 +233,11 @@ public function setFlashes($values)
}

/**
* @param string $name
* @param string $default
*
* @return string
*
* @deprecated since 2.1, will be removed from 2.3
*/
public function getFlash($name, $default = null)
Expand All @@ -285,6 +246,9 @@ public function getFlash($name, $default = null)
}

/**
* @param string $name
* @param string $value
*
* @deprecated since 2.1, will be removed from 2.3
*/
public function setFlash($name, $value)
Expand All @@ -293,6 +257,10 @@ public function setFlash($name, $value)
}

/**
* @param string $name
*
* @return Boolean
*
* @deprecated since 2.1, will be removed from 2.3
*/
public function hasFlash($name)
Expand All @@ -301,6 +269,8 @@ public function hasFlash($name)
}

/**
* @param string $name
*
* @deprecated since 2.1, will be removed from 2.3
*/
public function removeFlash($name)
Expand All @@ -309,6 +279,8 @@ public function removeFlash($name)
}

/**
* @return array
*
* @deprecated since 2.1, will be removed from 2.3
*/
public function clearFlashes()
Expand Down
Loading
0