0

I am trying to install Chamilo on my server but I get a warning and the install is cancelled... I thought warnings were not like errors and wouldn't make it fail, but either this warning is important or something else is wrong that I don't know of.

The warning is a "headers already sent". I have followed the steps to solve it to no avail (I commented the lines with echo, used ob functions and even php.ini buffer setting but it keeps displaying this exact same warning). It comes from script that otherwise work fine on my WAMP test server and I found no complaints about it on the chamilo threads... I'm not even sure this could make the whole install crash...

Warning:  Cannot modify header information - headers already sent by (output started at /var/www/new_chamilo/main/install/index.php:391) in /var/www/new_chamilo/main/inc/lib/template.lib.php on line 1038, referer: XXX/new_chamilo/main/install/index.php?running=1&installType=new&updateFromConfigFile=

[...] header() /var/www/new_chamilo/main/inc/lib/template.lib.php:1038

So the two lines mentioned here are :

header() /var/www/new_chamilo/main/inc/lib/template.lib.php:1038 (the closing })

  if ($sendHeaders) {
                header('Content-Type: text/html; 
    charset='.api_get_system_encoding());
                header(
                    'X-Powered-By: '.$_configuration['software_name'].' 
   '.substr($_configuration['system_version'], 0, 1)
                );
            }

and index.php line 390

success: function(datos) {
                        if (datos == 'required_field_error') {
                            message = "<?php echo get_lang('FormHasErrorsPleaseComplete') ?>";
                        } else if (datos == '1') {
                            message = "<?php echo get_lang('ContactInformationHasBeenSent') ?>";
                        } else {
                            message = "<?php echo get_lang('Error').': '.get_lang('ContactInformationHasNotBeenSent') ?>";
                        }
                        alert(message);
                        $('#license-next').trigger('click');
                        $('#loader-button').html('');
                    }

I have tried commenting these error echoes, buffering with the ob functions or with the php.ini, nothing works, I still get the warnings and the install fails (I am not sure the install fails because of it though, but I have no other message whatsoever). On a side note, the php.ini says display_errors = Off but I still get that

I have followed the headers sent tutorial even before posting here actualy, but it changed nothing. As you can see in the code, there is "echo" and I suspect it is the problem so I commented the whole function (it is only about sending contact information to chamilo so it's quite useless) but the exact same error, pointing to the commented lines, still occurs. I am wondering if my file hasn't been cached. Is there a way to force refresh of this file only ? I see that htcacheclean can clear a specific URL from the cache, but I don't find examples of how to do so. Anyone knows how to provide a URL as parameter to this command ? Actualy I know I had to install some extensions that caches scripts for more efficiency, because it's absence triggered many warnings. Is there more than one cache server side ?

Any insight about this would be very welcome... Thank you in advance for your time !

Zaelon
  • 1
  • 1
  • Possible duplicate of [How to fix "Headers already sent" error in PHP](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – Rajdeep Paul May 13 '17 at 08:17

1 Answers1

0

First of all, the Headers already sent message is usually symptomatic of something else that goes wrong. Indeed, Headers already sent only appears when something (in PHP) tries to send HTTP headers but... they were already sent. The issue is usually that the headers were sent when they shouldn't have, so looking at the place where the error triggers is usually incorrect.

Second, the display_errors = Off might actually be what's preventing you to see the real problem, although sending the headers is not always the result of an error.

If you have access to your server's error_log, it is probably much clearer about what the error is (usually, for Chamilo's installation process, a matter of the PHP version which should be 5.4 or higher, or of the date.timezone setting that would not have been set, or any dependency that would not be matched). It would also be interesting to know on which page of the installation process this appears. It might make it easier to debug. Given you mention the block with the AJAX call, it is probably linked to the contact form, which is not mandatory to fill and send (so you could skip it altogether).

The Headers already sent message is a warning, so it might not block the installation completely. Maybe you can just ignore it.

Finally, if you are upgrading from a previous version of Chamilo instead of installing a new one, you might want to clear the template cache (which you can do in version 1.10 and above with rm -rf app/cache/twig/*.

ywarnier
  • 210
  • 1
  • 8