Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-52976

HTTP_RAW_POST_DATA is deprecated and still in use (backport of MDL-51162)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.9.4
    • Fix Version/s: 2.9.6
    • Component/s: MNet
    • Labels:
    • Testing Instructions:
      Hide
      1. Search for usages of the variables:

        $_GLOBALS["HTTP_RAW_POST_DATA"]
        $HTTP_RAW_POST_DATA
        

        Make sure the only usage is on Zend library and TinyMCE.

      2. Setup MNET, add a peer and make sure you don't get the error:

        Request for http://glux/mdk/mnet29b returned empty response
         
            line 134 of /mnet/lib.php: call to debugging()
            line 115 of /admin/mnet/peers.php: call to mnet_get_public_key()
        

        Would be really good, if someone that has php 5.6 and see if you get any HTTP_RAW_POST_DATA errors on AJAX web service requests.

      Show
      Search for usages of the variables: $_GLOBALS["HTTP_RAW_POST_DATA"] $HTTP_RAW_POST_DATA Make sure the only usage is on Zend library and TinyMCE . Setup MNET, add a peer and make sure you don't get the error: Request for http://glux/mdk/mnet29b returned empty response   line 134 of /mnet/lib.php: call to debugging() line 115 of /admin/mnet/peers.php: call to mnet_get_public_key() Would be really good, if someone that has php 5.6 and see if you get any HTTP_RAW_POST_DATA errors on AJAX web service requests.
    • Affected Branches:
      MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE
    • Pull from Repository:

      Description

      Summary: I would like the patch 4d16a2749f8b5d6dd2858106b5cae5e383256fa7 by Simey Lameze in MDL-51162 backported to pre-3.0 branches - or at least its MNet part. Without it, the XMLRPC communication in MNet does not work in certain situations as the XML payload is broken by prepended deprecation message.

      Details:

      While debugging some other issue in MNet, I realized that I am not able to add an MNet peer. What I saw was debugging message like

      Request for http://glux/mdk/mnet29b returned empty response
       
          line 134 of /mnet/lib.php: call to debugging()
          line 115 of /admin/mnet/peers.php: call to mnet_get_public_key()
      

      I was able to trace it down to a place where the host attempts to call

      $res = xmlrpc_decode(curl_exec($ch));
      

      in mnet_get_public_key(). The trouble is that the response returned by curl_exec() contained the debugging message:

      PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0

      which breaks the XML structure and xmlrpc_decode() returns empty string:

      This deprecation warning is raised in PHP 5.6 and in PHP 7.0 the functionality is completely removed. It was already noticed by Andrew Nicols and the legacy global variable was replaced in Moodle 3.0 in MDL-51162.

      I believe we should backport that fix though as this effectively makes MNet unusable on PHP 5.6 sites with some level of debugging enabled. It probably does not affect production sites that have debugging disabled.

      Some users are experiencing the HTTP_RAW_POST_DATA related errors:

      Request for http://glux/mdk/mnet29b returned empty response
       
          line 134 of /mnet/lib.php: call to debugging()
          line 115 of /admin/mnet/peers.php: call to mnet_get_public_key()
      

      If you are experiencing the error above, please add the setting always_populate_raw_post_data = -1 to your php.ini.
      For more information see: https://docs.moodle.org/29/en/PHP#HTTP_RAW_POST_DATA_errors

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/May/16