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

Prevent upgrade "Undefined property $reverseproxyignore" notice

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      1) Setup pre upgrade config conditions. Run the following:

      php admin/cli/cfg.php --name=getremoteaddrconf --set=1
      php admin/cli/cfg.php --name=reverseproxyignore --unset
      

      2) Test file:  remoteip.php (create it @ the site dirroot):

      <?php
       
      require('config.php');
      echo getremoteaddr()."\n";
      

      3) Ensure that you have "debug" set to developer level enabled and "debugdisplay" also enabled (admin settings).

      4) Test curl and confirm you did NOT get this error (but just "1.2.3.4"):

      $ curl http://your.moodle.site/remoteip.php -H 'X-Forwarded-For: 1.2.3.4'
      <br />
      <b>Notice</b>: Undefined property: stdClass::$reverseproxyignore in <b>/var/www/moodle.local/lib/moodlelib.php</b> on line <b>9211</b><br />
      <br />
      <b>Notice</b>: Undefined property: stdClass::$reverseproxyignore in <b>/var/www/moodle.local/lib/moodlelib.php</b> on line <b>9211</b><br />
      1.2.3.4

       

      Show
      1) Setup pre upgrade config conditions. Run the following: php admin/cli/cfg.php --name=getremoteaddrconf --set=1 php admin/cli/cfg.php --name=reverseproxyignore --unset 2) Test file:  remoteip.php (create it @ the site dirroot): <?php   require('config.php'); echo getremoteaddr()."\n"; 3) Ensure that you have "debug" set to developer level enabled and "debugdisplay" also enabled (admin settings). 4) Test curl and confirm you did NOT get this error (but just "1.2.3.4"): $ curl http://your.moodle.site/remoteip.php -H 'X-Forwarded-For: 1.2.3.4' <br /> <b>Notice</b>: Undefined property: stdClass::$reverseproxyignore in <b>/var/www/moodle.local/lib/moodlelib.php</b> on line <b>9211</b><br /> <br /> <b>Notice</b>: Undefined property: stdClass::$reverseproxyignore in <b>/var/www/moodle.local/lib/moodlelib.php</b> on line <b>9211</b><br /> 1.2.3.4  
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • Pull 3.5 Branch:
      MDL-68125-regression-MOODLE_35_STABLE
    • Pull 3.8 Branch:
      MDL-68125-regression-MOODLE_38_STABLE
    • Pull Master Branch:
      MDL-68125-regression

      Description

      This is a fix for a little regression introduced @ MDL-67861. Applies to all current branches (35 and up).

      When these conditions happen:

      • The site has debugging set to high levels + display errors enabled.
      • The site has the handling of X-Forwarded-For headers enabled.
      • There are some headers coming in the requests.
      • The site is upgraded via web (CLI is immune to this).

      This notice is shown in the initial 3-4 pages (login, env, db upgrade...) until the new settings are saved to DB (then the notice disappears forever):

      Notice: Undefined property: stdClass::$reverseproxyignore in /opt/app/lib/moodlelib.php on line 9210"
      

      So, this issue is about to avoid that notice to be shown, just that.

      In the original issue, a simple change was proposed, FYC:

      Maybe we can just change:

      return !\core\ip_utils::is_ip_in_subnet_list($ip, $CFG->reverseproxyignore, ',');
      

      by

      return !\core\ip_utils::is_ip_in_subnet_list($ip, $CFG->reverseproxyignore ?? '', ',');
      

      And that's all. Note the notice doesn't lead to any malfunctioning, it's just "ugly" for the sites matching all the conditions above.

      CORRECTION TAKE#2 : Striking-through the previous -CORRECTION: it breaks login, so makes it imossible to upgrade sites through the Web UI.-

      Ciao

        Attachments

          Activity

            People

            Assignee:
            brendanheywood Brendan Heywood
            Reporter:
            stronk7 Eloy Lafuente (stronk7)
            Peer reviewer:
            Dan Marsden
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            Janelle Barcega
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/May/20

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 35 minutes
                35m