Add validation: Sandbox lang cannot be empty when creating a prototype #195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Richard,
We are seeing the following deprecation warnings on some of our questions. Warning is in the function
answerbox_attributes
, when$currentlanguage
is null anducwords
doesn't accept it.Deprecated: ucwords(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/moodle/question/type/coderunner/renderer.php on line 749
Have noticed that the questions with these warnings are all using user defined prototype templates (which seems to have been deleted on our systems). But the problem here is when I looked into the database table question_coderunner_options, the language for these user defined prototypes is set to null.
And I suppose, we should never have a user defined prototype template with empty sandbox language. Hence adding a validation to the sandbox language would prevent those issues. Though adding
ucwords($currentlanguage ?? '');
would fix the existing issues as well, I was not sure if that is the right thing to do and thought would be good to confirm before doing that change.Could you please have a look and suggest if I have understood it correctly and the fix is right?
I was able to reproduce this issue with the following steps:
Thanks,
Anupama