Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit some illogical code from #183 #184

Closed
stronk7 opened this issue Feb 15, 2022 · 0 comments · Fixed by #185
Closed

Revisit some illogical code from #183 #184

stronk7 opened this issue Feb 15, 2022 · 0 comments · Fixed by #185

Comments

@stronk7
Copy link
Member

stronk7 commented Feb 15, 2022

Form @ewallah, in recently fixed #179 (PR #183):

The loadCoreComponent function has to fail if dirroot is not set. First a new empty class is created, the next step evaluates the dirroot of this (empty) class. (/codechecker/moodle/Util/MoodleUtil.php)

if (!isset($CFG->dirroot)) { // No defined, let's start from scratch.
        $CFG = new \stdClass();
}
if ($CFG->dirroot !== $moodleRoot) { // Different, set the minimum required.

We need to revisit that "illogical" code (just noting that, normally it uses to be set, but should work if not, too).

Thanks for the report!

Ciao :-)

andrewnicols added a commit to andrewnicols/moodle-local_codechecker that referenced this issue Feb 16, 2022
In order to use the core_component functions, sensible defaults are
required.

These sensible defaults are available, but the check of `$CFG->dirroot`
when $CFG is empty lead to a php warning, causing phpcs failures.

Even if this error is fixed, the default values in $CFG are then set to
NULL after including core_component, which means that uses of it work
with null values and cause require errors.

Fixes moodlehq#184
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant