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

Web service function names longer than 40 characters cause log errors

XMLWordPrintable

    • MOODLE_23_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • Hide

      Use this client: https://gist.github.com/jleyva/f6d0ef455a7c8717d6aa
      The curl.php file is here: https://github.com/moodlehq/sample-ws-clients/blob/master/PHP-REST/curl.php

      You need a token for the Mobile Service, you can create a token for the admin user:
      Create Token:
      Click on Site administration ► Plugins ► Web services ► Manage tokens
      Click add, select user and service (Mobile Service)

      2.7 Only:
      Enable legacy logging logstore_legacy (Home / ▶ Site administration / ▶ Plugins / ▶ Logging / ▶ Legacy log)

      1 Create a new course
      2 Enrol a couple of existing / new users
      3 Edit the client, change url, token, and the courseid and userid values for matching an existing user in the course
      4 Run the client in a browser or cli
      5 You should get a json with the user information

      For 2.6: Go to Home /Front page settings /Reports /Logs you should see a new log entry, check that the action field is:
      webservice moodle_user_get_course_participants_b... (with 3 dots at the end)

      For 2.7: Home / ▶ Site administration / ▶ Reports / ▶ Logs choose Legacylog you should see a new log entry, check that the event name field is:
      webservice_moodle_user_get_course_participants_b... (with 3 dots at the end)

      Show
      Use this client: https://gist.github.com/jleyva/f6d0ef455a7c8717d6aa The curl.php file is here: https://github.com/moodlehq/sample-ws-clients/blob/master/PHP-REST/curl.php You need a token for the Mobile Service, you can create a token for the admin user: Create Token: Click on Site administration ► Plugins ► Web services ► Manage tokens Click add, select user and service (Mobile Service) 2.7 Only: Enable legacy logging logstore_legacy (Home / ▶ Site administration / ▶ Plugins / ▶ Logging / ▶ Legacy log) 1 Create a new course 2 Enrol a couple of existing / new users 3 Edit the client, change url, token, and the courseid and userid values for matching an existing user in the course 4 Run the client in a browser or cli 5 You should get a json with the user information For 2.6: Go to Home /Front page settings /Reports /Logs you should see a new log entry, check that the action field is: webservice moodle_user_get_course_participants_b... (with 3 dots at the end) For 2.7: Home / ▶ Site administration / ▶ Reports / ▶ Logs choose Legacylog you should see a new log entry, check that the event name field is: webservice_moodle_user_get_course_participants_b... (with 3 dots at the end)

      All web service calls are written to the log with the function used as the "action." By default the maximum length of "action" in prefix_log is 40 characters. However, there's nothing stopping you from creating a custom web service function with a longer name than that. Here's a sample stack trace illustrating the problem. My custom function was 45 characters long:

      [Fri Nov 16 13:56:25 2012] [error] [client xxx.xxx.xxx.xxx] Debugging: Error: Could not insert a new entry to the Moodle log. Data too long for column 'action' at row 1

      • line 1725 of /lib/datalib.php: call to debugging()
      • line 1523 of /webservice/lib.php: call to add_to_log()
      • line 46 of /webservice/rest/server.php: call to webservice_base_server->run()

      I think the right way would be to either impose a limit from the interface or truncate the function name in the log. Note that the web service will still work properly, it just won't log the action.

            jleyva Juan Leyva
            cfulton Charles Fulton
            Daniel Neis Araujo Daniel Neis Araujo
            Marina Glancy Marina Glancy
            Marina Glancy Marina Glancy
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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