Moodle
  1. Moodle
  2. MDL-28481

Webservices cause header already sent warnings to fill up error_log

    Details

    • Rank:
      18225

      Description

      Web services attempt to send headers in instances where they've already been sent. Doesn't hurt functionally, but it does cause 4 warnings to goto the error_log each time a web service is called.

      Moodle should make a headers_sent() check before sending off the headers.

      Replication instructions:
      1. Turn up debugging to include PHP warnings.
      2. Make a webservice call
      3. Notice the warnings that appear in apaches error log.

        Activity

        Hide
        Adam Olley added a comment -

        Added link to github with a simple fix for this.

        Show
        Adam Olley added a comment - Added link to github with a simple fix for this.
        Hide
        Michael de Raadt added a comment -

        Thanks for reporting this and providing a solution.

        Show
        Michael de Raadt added a comment - Thanks for reporting this and providing a solution.
        Hide
        Jérôme Mouneyrac added a comment -

        I didn't test, but I know about this issue with SOAP server. The patch seems good to me, Mike, you can add to the next sprint and keep it assigned to me.

        Thank you Adam.

        Show
        Jérôme Mouneyrac added a comment - I didn't test, but I know about this issue with SOAP server. The patch seems good to me, Mike, you can add to the next sprint and keep it assigned to me. Thank you Adam.
        Hide
        Petr Škoda added a comment -

        Hello,
        I do not like this change much because it only hides the fact that some code is doing something wrong. I looked at the code and it seems that the headers are sent only once in all cases. Could you get me a stack trace of the first and second sending of headers?

        Petr

        Show
        Petr Škoda added a comment - Hello, I do not like this change much because it only hides the fact that some code is doing something wrong. I looked at the code and it seems that the headers are sent only once in all cases. Could you get me a stack trace of the first and second sending of headers? Petr
        Hide
        Adam Olley added a comment -

        Thanks for the comment Petr, it got me to look in the right place.

        I believe the issue is that the soap server is outputting content before the headers. Naturally as soon as you dump out content, headers are in effect sent.
        In webservice/lib.php's run(), $response = $this->zend_server->handle(); is called before $this->send_headers();. handle() will call dump(), which just echoes out data.

        I've changed my commit to what makes more sense given this. It moves the send_headers call before any output is possibly sent.

        Show
        Adam Olley added a comment - Thanks for the comment Petr, it got me to look in the right place. I believe the issue is that the soap server is outputting content before the headers. Naturally as soon as you dump out content, headers are in effect sent. In webservice/lib.php's run(), $response = $this->zend_server->handle(); is called before $this->send_headers();. handle() will call dump(), which just echoes out data. I've changed my commit to what makes more sense given this. It moves the send_headers call before any output is possibly sent.
        Hide
        Petr Škoda added a comment -

        makes sense, thanks!

        Show
        Petr Škoda added a comment - makes sense, thanks!
        Hide
        Petr Škoda added a comment -

        To integrators: please cherry pick to all 2.x branches

        Show
        Petr Škoda added a comment - To integrators: please cherry pick to all 2.x branches
        Hide
        Eloy Lafuente (stronk7) added a comment -

        (fixing repository and branch)

        Show
        Eloy Lafuente (stronk7) added a comment - (fixing repository and branch)
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Integrated, thanks! (backported to 20 and 21 stable)

        Show
        Eloy Lafuente (stronk7) added a comment - Integrated, thanks! (backported to 20 and 21 stable)
        Hide
        Rajesh Taneja added a comment -

        Works Great
        Thanks for fixing this Adam and Petr.

        Show
        Rajesh Taneja added a comment - Works Great Thanks for fixing this Adam and Petr.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Many thanks for the hard work, this has been sent upstream and is available in all the git and cvs repositories.

        Show
        Eloy Lafuente (stronk7) added a comment - Many thanks for the hard work, this has been sent upstream and is available in all the git and cvs repositories.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: