Remoting class: Order of function arguments & use of insertQuery/updateQuery
I came across two functions, in the remoting framework, that change the order of the arguments parsed.
mail_user_update($session_id, $client_id, $domain_id, $params) AND mail_fetchmail_update($session_id, $domain_id, $client_id, $params)
$domain_id and $client_id are sent in a different sequence and although this isn't strictly a bug it would be great to have this the same. Looking through the rest of the functions there are also some functions that parse confusing variable names to insertQuery and updateQuery. Example:
public function mail_fetchmail_add(session_id,
domain_id, $client_id, $params) {
...
$affected_rows = $this->insertQuery('../mail/form/mail_get.tform.php', $domain_id, $client_id, $params);
...
}
private function insertQuery($formdef_file, $client_id, $params) {}
In this example the arguments to function mail_fetchmail_add, from the SOAP client, would be: $session_id $client_id $params i.e. $res = $client->mail_fetchmail_add($session_id, $client_id, $params);
That would then be parsed to insertQuery as: $domain_id (actually $client_id) $client_id (actually $params) $params (null)
This is also happening in some other functions like mail_alias_update, and although I haven't tested it, it looks like the value for the primary id is being swapped with the client id.
I have create a patch file for remoting.inc.php (attached) that does three things:
- Remove the unnecessary argument to add functions (mostly $domain_id).
- Fix the order of the arguments to add and update functions.
- Use the variable name $primary_id instead of $domain_id to standardize the mail functions with others in the framework.