Uploaded image for project: 'Moodle app'
  1. Moodle app
  2. MOBILE-1278

Invalid wwwroot in config.php can cause errors in sites already stored

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: None
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. Add a site to the app.
      2. Modify the Moodle's config.php and set an invalid wwwroot.
      3. Check that the app shows error messages when it can't load stuff and there are no weird behaviours (like storing a string as site info).
      Show
      Add a site to the app. Modify the Moodle's config.php and set an invalid wwwroot. Check that the app shows error messages when it can't load stuff and there are no weird behaviours (like storing a string as site info).
    • Affected Branches:
      MOODLE_25_STABLE

      Description

      Example:

      I have a site with wwwroot = 192.168.1.10/mymoodle. I add that site in the app, so it's stored with that URL. Then I change that value to localhost/mymoodle. The requests performed from the app from now on will have this answer:

      <!DOCTYPE html>
      <html  lang="en" xml:lang="en">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="refresh" content="3; url=http://192.168.1.48/moodlemaster" />
      <title>Redirect</title>
      </head><body><div style="margin-top: 6em; margin-left:auto; margin-right:auto; color:#990000; text-align:center; font-size:large; border-width:1px;
      border-color:black; background-color:#ffffee; border-style:solid; border-radius: 20px; border-collapse: collapse;
      width: 80%; -moz-border-radius: 20px; padding: 15px">
      Incorrect access detected, this server may be accessed only through "http://192.168.1.48/moodlemaster" address, sorry.<br />Please notify server administrator.
      </div><!DOCTYPE html>
      <html  lang="en" xml:lang="en">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
       
      <title>Redirect</title>
      </head><body><div style="margin-top: 3em; margin-left:auto; margin-right:auto; text-align:center;">This page should automatically redirect. If nothing is happening please use the continue link below.<br /><a href="http://192.168.1.48/moodlemaster">Continue</a></div></body></html></body></html>
      

      $mmWS doesn't detect this as an error, so this string is passed as the success of the call, causing some errors in the app. E.g. in $mmaCalendar#getEvents we perform courses.push with that response, so we get an exception because it's not an array. I also got an error like "Cannot read property length of undefined" when I restarted the app.

      The service performing the request needs to check if the returned data is valid, but maybe it'd be useful to detect this type of error in $mmWS if it's feasible.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dpalou Dani Palou
                Reporter:
                dpalou Dani Palou
                Peer reviewer:
                Frédéric Massart
                Integrator:
                Juan Leyva
                Tester:
                Juan Leyva
                Participants:
                Component watchers:
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: