Topic: Headers already sent in plugin functions

First, I've installed pure GS 3.1 r646, w/o any plugins. The only change I made - enabled GSDEBUG in gsconfig.php.
Second, I've created simple plugin, with 1 line of code:

<?php
# get correct id for plugin
$thisfile = basename(__FILE__, ".php");

# register plugin
register_plugin(
    $thisfile, //Plugin id
    'Someplugin',     //Plugin name
    '0.1',         //Plugin version
    'Author Name',  //Plugin author (nickname: Zorato)
    'http://www.example.com/', //author website
    'Nothing special here', //Plugin description
    'Settings', //page type - on which admin tab to display
    'somefunction'  //main function (administration)
);

add_action('settings-sidebar','createSideMenu',array($thisfile,'Some Plugin'));

function somefunction(){
    error_reporting(E_ALL); //for debugging purposes
    header('Location: settings.php');
}
?>

With PHP 5.3.8 and PHP 5.3.9 (IMHO, PHP 5.3+) runs like clockwork.
The problem is, that I use header() function within my plugins on hosting with PHP 5.2.17 (IMHO, with any PHP >5.2 and <5.3)
I've got this:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/user21243/data/www/~/pure/admin/inc/template_functions.php:27) in /var/www/user21243/data/www/~/pure/plugins/someplugin.php on line 25

Any ideas?
As a temporary solution I use redirect($url) function from basic.php file, but it causes double page refresh and  it is not very comfortable to work like that.
I sniffed around, but didn't find any functions in load.php, common.php or template_functions.php that may work differently in PHP 5.3 and PHP 5.2

Just another Get Simple fan
Imagizer plugin
I18N language menu plugin

Re: Headers already sent in plugin functions

try taking away the ending ?>

might be some extra whitespace after the end tag... its ok to leave it out... (something I didn't know till I joined up here.. 8)

Currently working on The Matrix Plugin...

Re: Headers already sent in plugin functions

Nope, didn't help. The most strange thing is, that this code works 'as it is' on host with PHP 5.3+ and didn't work with PHP 5.2 (windows or linux doesn't matter)

Just another Get Simple fan
Imagizer plugin
I18N language menu plugin

Re: Headers already sent in plugin functions

The only way to output a HTTP header reliably in the backend is in the admin-pre-header action - and it only exists in GetSimple 3.1.
In all other actions and filters some HTML has already been output and you will get this error message.
The only way it would work is if output buffering is turned on in your PHP installation - maybe this is the default for PHP 5.3+ or at least your installations.

I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.

Re: Headers already sent in plugin functions

mvlcek wrote:

The only way to output a HTTP header reliably in the backend is in the admin-pre-header action - and it only exists in GetSimple 3.1.

Thanks, will try to add another action for plugin to implement that hook.

By the way, I've written plugin for personal use, that didn't store config and logs in XML files (.txt instead). I'm thinking about sharing it by uploading to Extend section. Should I re-write code for XML files due to GS ideology or I can post it without any restrictions even if doesn't use XML?

Just another Get Simple fan
Imagizer plugin
I18N language menu plugin