<commit_before><?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 <NAME> <<EMAIL>>
 * (c) 2004-2006 <NAME>.
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfSessionStorage allows you to store persistent symfony data in the user session.
 *
 * <b>Optional parameters:</b>
 *
 * # <b>auto_start</b>   - [Yes]     - Should session_start() automatically be called?
 * # <b>session_name</b> - [symfony] - The name of the session.
 *
 * @package    symfony
 * @subpackage storage
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id$
 */
class sfSessionStorage extends sfStorage
{
  /**
   * Initialize this Storage.
   *
   * @param Context A Context instance.
   * @param array   An associative array of initialization parameters.
   *
   * @return bool true, if initialization completes successfully, otherwise false.
   *
   * @throws <b>sfInitializationException</b> If an error occurs while initializing this Storage.
   */
  public function initialize ($context, $parameters = null)
  {
    // initialize parent
    parent::initialize($context, $parameters);

    // set session name
    $sessionName = $this->getParameterHolder()->get('session_name', 'symfony');

    session_name($sessionName);

    if ($this->getParameter('auto_start', true))
    {
      // start our session
      session_start();
    }
  }

  /**
   * Read data from this storage.
   *
   * The preferred format for a key is directory style so naming conflicts can be avoided.
   *
   * @param string A unique key identifying your data.
   *
   * @return mixed Data associated with the key.
   */
  public function & read ($key)
  {
    $retval = null;

    if (isset($_SESSION[$key]))
    {
      $retval =& $_SESSION[$key];
    }

    return $retval;
  }

  /**
   * Remove data from this storage.
   *
   * The preferred format for a key is directory style so naming conflicts can be avoided.
   *
   * @param string A unique key identifying your data.
   *
   * @return mixed Data associated with the key.
   */
  public function & remove ($key)
  {
    $retval = null;

    if (isset($_SESSION[$key]))
    {
      $retval =& $_SESSION[$key];
      unset($_SESSION[$key]);
    }

    return $retval;
  }

  /**
   * Execute the shutdown procedure.
   *
   * @return void
   */
  public function shutdown ()
  {
    // don't need a shutdown procedure because read/write do it in real-time
  }

  /**
   * Write data to this storage.
   *
   * The preferred format for a key is directory style so naming conflicts can
   * be avoided.
   *
   * @param string A unique key identifying your data.
   * @param mixed  Data associated with your key.
   *
   * @return void
   */
  public function write ($key, &$data)
  {
    $_SESSION[$key] =& $data;
  }
}

?><commit_msg>fixed non-cookie based sessions (patch from subzero2000)<commit_after><?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 <NAME> <<EMAIL>>
 * (c) 2004-2006 <NAME>.
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfSessionStorage allows you to store persistent symfony data in the user session.
 *
 * <b>Optional parameters:</b>
 *
 * # <b>auto_start</b>   - [Yes]     - Should session_start() automatically be called?
 * # <b>session_name</b> - [symfony] - The name of the session.
 *
 * @package    symfony
 * @subpackage storage
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id$
 */
class sfSessionStorage extends sfStorage
{
  /**
   * Initialize this Storage.
   *
   * @param Context A Context instance.
   * @param array   An associative array of initialization parameters.
   *
   * @return bool true, if initialization completes successfully, otherwise false.
   *
   * @throws <b>sfInitializationException</b> If an error occurs while initializing this Storage.
   */
  public function initialize ($context, $parameters = null)
  {
    // initialize parent
    parent::initialize($context, $parameters);

    // set session name
    $sessionName = $this->getParameterHolder()->get('session_name', 'symfony');

    session_name($sessionName);

    $use_cookies = (boolean) ini_get('session.use_cookies');
    if (!$use_cookies)
    {
      $sessionId = $context->getRequest()->getParameter($sessionName, '');

      if ($sessionId != '')
      {
        session_id($sessionId);
      }
    }

    if ($this->getParameter('auto_start', true))
    {
      // start our session
      session_start();
    }
  }

  /**
   * Read data from this storage.
   *
   * The preferred format for a key is directory style so naming conflicts can be avoided.
   *
   * @param string A unique key identifying your data.
   *
   * @return mixed Data associated with the key.
   */
  public function & read ($key)
  {
    $retval = null;

    if (isset($_SESSION[$key]))
    {
      $retval =& $_SESSION[$key];
    }

    return $retval;
  }

  /**
   * Remove data from this storage.
   *
   * The preferred format for a key is directory style so naming conflicts can be avoided.
   *
   * @param string A unique key identifying your data.
   *
   * @return mixed Data associated with the key.
   */
  public function & remove ($key)
  {
    $retval = null;

    if (isset($_SESSION[$key]))
    {
      $retval =& $_SESSION[$key];
      unset($_SESSION[$key]);
    }

    return $retval;
  }

  /**
   * Execute the shutdown procedure.
   *
   * @return void
   */
  public function shutdown ()
  {
    // don't need a shutdown procedure because read/write do it in real-time
  }

  /**
   * Write data to this storage.
   *
   * The preferred format for a key is directory style so naming conflicts can
   * be avoided.
   *
   * @param string A unique key identifying your data.
   * @param mixed  Data associated with your key.
   *
   * @return void
   */
  public function write ($key, &$data)
  {
    $_SESSION[$key] =& $data;
  }
}

?>
{'fraction_non_alphanumeric': 0.12261669953977647, 'fraction_numerical': 0.005917159763313609, 'mean_word_length': 2.6789600967351874, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4808592', 'n_tokens_mistral': 1855, 'n_tokens_neox': 1774, 'n_words': 612}