We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Bug: Error when AJAX request encounters the redirect function

Developer Preview

Electric Putty's avatar
Electric Putty
88 posts
14 years ago
Electric Putty's avatar Electric Putty

We are running an AJAX process which saves the current entry content from the publish page. This was working fine in 2.1.5. Now we are getting this error:

Fatal error: Call to protected method EE_Session::_age_flashdata() from context ‘EE_Functions’ in /home/epwebsit/public_html/twotwo/admin/expressionengine/libraries/Functions.php on line 373

The refers to the redirect method in functions.php and the call to this is not within our code. It looks like the redirect in question is the one at the end of the _save() method in the content_publish.php (If we comment this out the AJAX returns without error).

The redirect function looks like this:

function redirect($location, $method = FALSE)
{
    $location = str_replace('&', '&', $this->insert_action_ids($location));

    if (count($this->EE->session->flashdata))
    {            
        // Ajax requests don't redirect - serve the flashdata

        if ($this->EE->input->is_ajax_request())
        {
            // We want the data that would be available for the next request
            $this->EE->session->_age_flashdata();

            $this->EE->load->libarary('javascript');

                die($this->EE->javascript->generate_json(
                            $this->EE->session->flashdata));
        }
    }

    if ($method === FALSE)
    {
        $method = $this->EE->config->item('redirect_method');
    }        

    switch($method)
    {
        case 'refresh'    : header("Refresh: 0;url=$location");
            break;
        default            : header("Location: $location");
            break;
    }

    exit;
}

It looks like this method correctly recognises this as an AJAX call and then tries to fire the _age_flashdata() method which is throwing the error.

Even as a protected method shouldn’t this be available in this context?

Thanks, Malcolm

       
Robzor's avatar
Robzor
86 posts
14 years ago
Robzor's avatar Robzor

Anyone from EllisLab got a view on this? Bit worried about it as it causes problems with our preview in certain circumstances. (Updating an existing entry)

Thanks,

Rob

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
14 years ago
Sue Crocker's avatar Sue Crocker

Hi, guys. I’ll get someone from the dev team to take a look this morning. Beyond my paygrade. 😊 Thanks in advance for your patience.

       
Wes Baker's avatar
Wes Baker
343 posts
14 years ago
Wes Baker's avatar Wes Baker

Malcom and Rob,

It looks like Greg took care of this earlier today by changing _age_flashdata back to public. We’re looking at sending out another dev build before 2.2, hopefully sooner rather then later, so you should be able to test it out before the release.

Wes

       
Robzor's avatar
Robzor
86 posts
14 years ago
Robzor's avatar Robzor

Thanks Wes! (And of course, Greg)

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.