Problem with system messages

Hello everyone, 

We have a problem with system message with the Elgg 2.3.3 versions, don't really know why, but works with Elgg 1.12.16.

On my development environment it's works (Wampserver 3.0.6 on Win10, with Apache 2.4.23 - PHP 5.6.25 - MySQL 5.7.14). That works too on my rapsberry pi with Raspbian + Lamp.

But not in our host provider, OVH (Pro hosting, PHP 5.6). Is there anyone that got the same problem. Thanks by advance.

  • By the way, I'm testing with 2 fresh install.

  • What exactly is the problem you have with the system messages then? Unfortunately, you haven't told us.

  • Sorry for that. 

    So the problem is that the message doeesn't appear for user. In my log file, there is a duplicated header.

    After investigation in Response.php in vendor/symfony there a function :

    public function sendHeaders()
        {
            // headers have already been sent by the developer
            if (headers_sent()) {
                return $this;
            }
    
            if (!$this->headers->has('Date')) {
                $this->setDate(\DateTime::createFromFormat('U', time()));
            }
    
            // headers
            foreach ($this->headers->allPreserveCase() as $name => $values) {
                foreach ($values as $value) {
                    header($name.': '.$value, true, $this->statusCode);
                }
            }

     

    if the header function, we pass the bolded value to "true" so the message system works.

    Is that a bug ?

  • Are the working and non-working Elgg installations really the same, e.g. the same plugins or better no 3rd party plugins enabled to see what's wrong?

    Where's the duplicate header coming from? Can you find that out? If a buggy 3rd party plugin interferes (or a plugin not compatible with Elgg 2.x) it might cause the issue. I don't know if there's a bug in the sendHeaders() functions. I would rather say there shouldn't be 2 headers in the first place. Also, if there would be a bug with system messages not displayed in a normal Elgg installation it would have been noticed already.

  • No I make a fresh install, just take the zip file install from elgg.org for testing. No 3rd party, only the default bundle plugins. I'm agree with you for the bug in the sender version and the duplicate header, but we have several Elgg instance on OVH servers and all with the 2.3.3 version are impacted and not the 1.12 instance.

    In my server log file:

    FastCGI: comm with server "myServer" aborted: error parsing headers: duplicate header 'content-type', referer:

     

  • Most of the time when there is an error 'Headers already sent', some plugin has a wrong file somewhere.

    For example a language file which starts with an empty line or a space before the first `<?php`.

    Try finding out which plugin is causing the error and see if it contains a wrong file

  • That weird because i've only unzip the elgg-2-3-3.zip from elgg and just follow the 6 step from Elgg installation. And that working on my local webserver. Production server => PHP 5.6.31, apache 2.4

    We see that append on some pages, not all.

    • If we restrict acces to loggin user.
    • logout
    • try to access the activity page

    No message is shown.

  • Do you get any log entries in the Apache and/or PHP error log at the time the system messages are not shown? You might need to enable debugging in the advanced site settings to get log entries. Or does the browser error console show any errors at that time indicating what might be wrong?

  • In my log phperror:

    [Tue Nov 14 09: 59: 19 2017][error][client 82.#.#.#][host devcon5.jade - rs.com]AH10157: FastCGI: An error happend on Fastcgi processing, fallback to CGI
    [Tue Nov 14 09: 59: 26 2017][error][client 82.#.#.#][host devcon5.jade - rs.com]AH10144: FastCGI: comm with server "/homez.370/#/#/#/index.php" aborted: error parsing headers: duplicate header 'Content-Type', referer: http: //#.#.com/
    

    In the session object (vendor/elgg/elgg/engine/classes/Elgg/systemMessageService.php) I put a dump =>

    It show 2 times like the engine make a redirection:

    [attributes] => Symfony \\ Component \\ HttpFoundation \\ Session \\ Attribute \\ AttributeBag Object
                (
                    [name: Symfony \\ Component \\ HttpFoundation \\ Session \\ Attribute \\ AttributeBag: private] => attributes
                    ted: error parsing headers: duplicate header 'content-type', referer: https: //jaders.jade-rs.com/activity
                       (
                        [0] => You must be logged in to view the requested page.)
                       )

    the second time, error message is void, and doesn't appear on screen.

     

    We fixed it with the Response.php like mentionned before, but that only a temporary solution.

    After investigation in Response.php in vendor/symfony there a function :

    public function sendHeaders()
        {
            // headers have already been sent by the developer
            if (headers_sent()) {
                return $this;
            }
    
            if (!$this->headers->has('Date')) {
                $this->setDate(\DateTime::createFromFormat('U', time()));
            }
    
            // headers
            foreach ($this->headers->allPreserveCase() as $name => $values) {
                foreach ($values as $value) {
                    header($name.': '.$value, true, $this->statusCode);
                }
            }

     

    if the header function, we pass the bolded value to "true" so the message system works.

    Is that a bug ?

  • It might be a bug in symphony that shows with FastCGI used (https://github.com/symfony/symfony/issues/21204).

    I guess for the time being you can only fix it manually in sendHeaders() or not use FastCGI.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking