Warning: 2.9.3 non-backwards-compatibility

Warning: 2.9.3 non-backwards-compatibility

by Tim Hunt -
Number of replies: 3
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Since we upgraded to Moodle 2.9.3, a bunch of our behat tests are failing because of MDL-51756, which is outputting a lot of developer debug warnings on some pages.

There was nothing aobut this in the release notes until I added an unhelpful warning just now.

I am hoping that someone involved in this change can explain this change, and what the correct fix is in our plugins.

Average of ratings: -
In reply to Tim Hunt

Re: Warning: 2.9.3 non-backwards-compatibility

by Dan Poltawski -

(I haven't refamiliarised with myself with it properly, just replying quickly from memory). The debug warning is to tell you that you've specified a function parameter as 'VALUE_OPTIONAL' but provided a default value. If you want it to fall back to a default value you should declare your function parameters as VALUE_DEFAULT.  See fixes in core: https://github.com/moodle/moodle/commit/4d9edf1b152f24a770c93b4debddad52d91c6557

We made this throw a debug warning because if you enabled that function in a webservice called with xmlrpc (and potentially other protocols) it would throw an exception and break the entire service including unrelated functions. It was extremely obtuse and difficult to spot where the problem was coming from and would be silent until you added that function to a service.

Note its a mischaracterisation to say this is non-backwards compatible, its a DEBUG_DEVELOPER warning and does not affect production environments. On the other hand, if one day you added one of those 'broken' services to an existing web-service it would break the entire web-service and not be at all obvious where the problem came from.

I'm sorry that this got missed from the release notes and the debug warning was not explanatory enough.

In reply to Dan Poltawski

Re: Warning: 2.9.3 non-backwards-compatibility

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Right, I added what you said to the release notes, though someone who actually knows what is going on should check.

Feel free to steal some of what I wrote to make the debugging output less cryptic.

In reply to Dan Poltawski

Re: Warning: 2.9.3 non-backwards-compatibility

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Dan, sorry, but your memory is not right.

Apparently where we are getting these errors, there are no defaul vaues set, so VALUE_DEFAULT is wrong.

So, I return to asking:

  • What does this debugging message mean?
  • What is the correct way to fix ones code when this message appears?