-
Bug
-
Resolution: Fixed
-
Minor
-
3.9.11, 3.10.8, 3.11.4, 4.0
-
MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
-
MOODLE_311_STABLE
-
This is part of the php80 epic (MDL-70745) because it was discovered when looking for not working stuff with that new version.
Looking for each() uses in codebase (that was deprecated in php72 and has been removed in php80) only one real use was found, so far:
$ ag '\beach\(' --php
|
mnet/xmlrpc/serverlib.php
|
533: @list($wwwroot, $pubkey, $application) = each($params);
|
...
|
(there is another in a lib/tcpdf/tcpdf.php comment, but it doesn't matter)
The point about that line is that is, simply, plain wrong, and it never has worked. $params is an array with 3 elements, non-associative, with values being caller wwwroot, caller pubkey and caller application type. And the use of each() there, simply makes no sense. You can see it in action @ https://3v4l.org/tMK3aj
So the proposal, is to just change that bogus line by:
list($wwwroot, $pubkey, $application) = $params;
|
And done!
But then, when testing the results... it was discovered that, also... when a moodle site is set in "promiscuous mode" (that means that it registers all callers as mnet peers automatically, instead of having to create them manually)... it's not working at all either. And tracing that down... it's because the mnet_peer::bootstrap() method, that returns true on success (if the caller is correct) or false on failure (if the caller url, pubkey, application aren't good) is missing a return true; at the end of the method, when everything has been verified.
Hence, we need to, also, add that missing return. That way, the server in promiscuous mode will, automatically, add the caller to its list of peers.
So, summary, with the changes here (2 lines of code), we solve 3 problems:
- php80 compatibility, removing the only remaining each() use in codebase.
- fix a mnet old bug (> 10y) where the parameters were being handled incorrectly.
- make promiscuous mode to work as expected, it never has worked ok with current code.
- is duplicated by
-
MDL-73522 remove deprecated each() from mnet xmlrpc code
- Closed