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

Prevent upgrade "Undefined property $reverseproxyignore" notice

XMLWordPrintable

    • MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • MDL-68125-regression
    • Easy
    • 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  

      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

            brendanheywood Brendan Heywood
            stronk7 Eloy Lafuente (stronk7)
            Dan Marsden Dan Marsden
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Janelle Barcega Janelle Barcega
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.