What's this? How do I fix it?

Fatal Error.

Redirect could not be issued due to headers already being sent. Halting execution for security. Search http://docs.elgg.org/ for more information.

SecurityException Object
(
[message:protected] => Redirect could not be issued due to headers already being sent. Halting execution for security. Search http://docs.elgg.org/ for more information.
[string:Exception:private] => exception 'SecurityException' with message 'Redirect could not be issued due to headers already being sent. Halting execution for security. Search http://docs.elgg.org/ for more information.' in /hsphere/local/home/focusweb/social.focusweb.com.ua/domino/engine/lib/elgglib.php:151
Stack trace:
#0 /hsphere/local/home/focusweb/social.focusweb.com.ua/domino/actions/login.php(66): forward('')
#1 /hsphere/local/home/focusweb/social.focusweb.com.ua/domino/engine/lib/actions.php(99): include('/hsphere/local/...')
#2 /hsphere/local/home/focusweb/social.focusweb.com.ua/domino/engine/handlers/action_handler.php(20): action('login')
#3 {main}
[code:protected] => 0
[file:protected] => /hsphere/local/home/focusweb/social.focusweb.com.ua/domino/engine/lib/elgglib.php
[line:protected] => 151
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /hsphere/local/home/focusweb/social.focusweb.com.ua/domino/actions/login.php
[line] => 66
[function] => forward
[args] => Array
(
[0] => 
)

)

[1] => Array
(
[file] => /hsphere/local/home/focusweb/social.focusweb.com.ua/domino/engine/lib/actions.php
[line] => 99
[args] => Array
(
[0] => /hsphere/local/home/focusweb/social.focusweb.com.ua/domino/actions/login.php
)

[function] => include
)

[2] => Array
(
[file] => /hsphere/local/home/focusweb/social.focusweb.com.ua/domino/engine/handlers/action_handler.php
[line] => 20
[function] => action
[args] => Array
(
[0] => login
)

)

)

[previous:Exception:private] => 
)

  • Hi, I'm passing trough the same problem.
    Already search   http://docs.elgg.org and could not solve the error.

  • Identify the offending plugin, then find what's being output before the redirect - usually whitespace after a php closing tag

  • I think usually such stuff happens on start.php inclusion or init system event. I'm thinking for some time if we could incorporate test for it to the core to pinpoint (and disable?) problematic plugin and inform in the error. What would you say for that? I think that figuring out exact reason such bugs is especially problematic for beginning elgg users.

    Testing for immediate problems in start.php is easy, but I don't have elegant idea for putting similar test between init, system callbacks. Thoughts?

  • usually caused by (a) whitespace situation (b) BOM (byte order mark); wikipedea says ' The byte order mark (BOM) is Unicode char used to signal endianness (byte order) of text file, stream ' blah.. techie.. blah...

    #b could happen if you've edited language files in the 'wrong' editor or with the wrong encoding!!
    #a - maybe slightly sloppy plugins' code..?!

    could be some effort to detect -- maybe using views hook to scan for the bom sequence and stripping it ? however.. this is all cleaning up afterwards; people will simply need learn to code or edit more carefully..

     

  • Views should not be problem here. Doing it for start.php and languages is easy. I'm just thinking of catching situation when we include bad file in plugin init, system handler.

    This problem is pretty often, making debugging it simplier is more friendly to the user and is good step to make ie. admin panel bulletproof against bad plugins.

  • I'm new on the elgg.
    I managed to find the piece of code, the method that displays the exception on the screen.
    Line 129 of file elgglib.php.

    function forward($location = "", $reason = 'system') {
    //echo "location = ".$location." reason =".$reason;
    global $CONFIG;
     
    //echo "\n config = ".$CONFIG;
     
    if (!headers_sent()) {
    if ($location === REFERER) {
    $location = $_SERVER['HTTP_REFERER'];
    }
     
    $location = elgg_normalize_url($location);
     
    // return new forward location or false to stop the forward or empty string to exit
    $current_page = current_page_url();
    $params = array('current_url' => $current_page, 'forward_url' => $location);
    $location = elgg_trigger_plugin_hook('forward', $reason, $params, $location);
     
    if ($location) {
    header("Location: {$location}");
    exit;
    } else if ($location === '') {
    exit;
    }
    } else {
    throw new SecurityException(elgg_echo('SecurityException:ForwardFailedToRedirect'));
     
    If I get the "!" of! headers_sent () will have some impact on the rest of the system? I'm beginning to understand a little of the operation and do not know what level of engagement.
    image
  • No, do not remove the "!" from headers_sent() - it will mess up your entire system.

    You need to identify what is causing headers to be sent prematurely, not trying to route around the security exception.

  • Are you using a theme?

    Rodolfo Hernandez

    Arvixe/Elgg Community Liaison