Fix Moodle 5.1+ compatibility for course request form#3076
Open
weilai-irl wants to merge 1 commit intoMOODLE_500_STABLEfrom
Open
Fix Moodle 5.1+ compatibility for course request form#3076weilai-irl wants to merge 1 commit intoMOODLE_500_STABLEfrom
weilai-irl wants to merge 1 commit intoMOODLE_500_STABLEfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes Moodle 5.1+ compatibility for the course request form by adapting to the relocation of the core course request form class in Moodle 5.1. In Moodle 5.1+, the course request form was moved from course/request_form.php (class course_request_form) to course/classes/form/request_course.php (class \core_course\form\request_course). The solution uses a file-existence check and class aliasing to maintain backward compatibility with pre-5.1 Moodle versions while supporting the new structure.
Changes:
- Implements version-agnostic compatibility using file_exists() checks to detect which Moodle version is in use
- Uses class_alias to create a common parent class reference (
parent_request_course) regardless of Moodle version - Updates the class inheritance to extend the aliased parent class instead of directly extending
course_request_form
Comments suppressed due to low confidence (1)
local/o365/classes/form/courserequestform.php:31
- Consider using more descriptive variable names for clarity. The current names
$pathbelowmoodle51and$pathsincemoodle51could be improved to something like$legacypathand$modernpath, or$pathpre51and$pathfrom51, which would be more intuitive and easier to understand at a glance.
$pathbelowmoodle51 = $CFG->dirroot . '/course/request_form.php';
$pathsincemoodle51 = $CFG->dirroot . '/course/classes/form/request_course.php';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.