#16 ✓resolved
Fabrice Luraine

Flash features does'nt applies while redirecting

Reported by Fabrice Luraine | July 24th, 2009 @ 04:22 PM | in Release 0.4 - Fresh Mint And Ginger

Flash feautures dosn't work when you use redirect_to() because flash_sweep() isn't called before redirecting. We need to exit properly application before redirecting.

stop_and_exit() will be called but without exiting, by patching it with an $exit optionnal parameter

/**
 * Stop and exit limonade application
 *
 * @access private 
 * @param boolean exit or not
 * @return void
 */
function stop_and_exit($exit = true)
{
  call_if_exists('before_exit');
  flash_sweep();
  if(defined('SID')) session_write_close();
  if($exit) exit;
}

Then we'll call it in the redirect_to:

/**
 * Http redirection
 *
 * @param string $params,... 
 * @return void
 */
function redirect_to($params)
{
  # [NOTE]: (from php.net) HTTP/1.1 requires an absolute URI as argument to » Location:
  # including the scheme, hostname and absolute path, but some clients accept
  # relative URIs. You can usually use $_SERVER['HTTP_HOST'],
  # $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative
  # one yourself.
  
  # TODO make absolute uri
  if(!headers_sent())
    {
    $uri = call_user_func_array('url_for', $params);
    stop_and_exit(false);
    header('Location: '.$uri);
    exit;
  }
}

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Limonade is a PHP micro-framework.

People watching this ticket

Referenced by

Pages