Commit e120d8fd authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1697909: 'custom_' unknown param not an exception in WS

If an LTI parameter is unknown and prefixed with 'custom_',
drop it from the data passed to the handler function.
Then if the site is in non-production mode,
also show this information.

behatnotneeded

Change-Id: I3fac19c27df2b9f072b8cdbcb8a2458c506c018e
parent 787ac996
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -280,6 +280,7 @@ $string['erroroptionalparamarray'] = 'The web service description parameter name
$string['errorresponsemissingkey'] = 'Error in response: Missing following required key in a single structure: %s';
$string['errorscalartype'] = 'Scalar type expected, array or object received.';
$string['errorunexpectedkey'] = 'Unexpected keys (%s) detected in parameter array.';
$string['errorunexpectedcustomkey'] = 'Unexpected custom keys (%s) detected in parameter array. They are being ignored by Mahara. This message is informational only so you can review the parameters and are aware that they are being ignored.';
$string['execute'] = 'Execute';
$string['expires'] = 'Expires';
$string['externalservice'] = 'External service';
+13 −2
Original line number Diff line number Diff line
@@ -601,11 +601,22 @@ class external_api {
            if (!empty($params)) {
                //list all unexpected keys
                $keys = '';
                $customkeys = '';
                foreach ($params as $key => $value) {
                    if (substr($key, 0, 7) === "custom_") {
                        $customkeys .= $key . ',';
                    }
                    else {
                        $keys .= $key . ',';
                    }
                }
                if (!empty($customkeys) && !get_config('productionmode')) {
                    log_info(get_string('errorunexpectedcustomkey', 'auth.webservice', $customkeys));
                }
                if (!empty($keys)) {
                    throw new WebserviceInvalidParameterException(get_string('errorunexpectedkey', 'auth.webservice', $keys));
                }
            }
            return $result;

        }