Skip to content

Protection against non-existing property "hiddensections" in $COURSE - #7

Open
matcho wants to merge 1 commit into
davosmith:masterfrom
telabotanica:feat/hiddensections
Open

Protection against non-existing property "hiddensections" in $COURSE#7
matcho wants to merge 1 commit into
davosmith:masterfrom
telabotanica:feat/hiddensections

Conversation

@matcho

@matcho matcho commented Aug 1, 2016

Copy link
Copy Markdown
Contributor

Hi.
On my Moodle 3.0 instance, I get a warning about $COURSE->hiddensections not existing.
Here's a proposal to avoid this.
Thanks,
Mathias

Comment thread footer.php
$thissection = $sections[$mod->sectionnum];

if ($thissection->visible || !$COURSE->hiddensections ||
if ($thissection->visible || (property_exists($COURSE, "hiddensections") && !$COURSE->hiddensections) ||

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I'll have to look at this in more detail, but I'd be wanting to use isset(), not property_exists (possibly also wanting to use empty(), but would have to figure out the logic of the line of code first anyway).

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 this pull request may close these issues.

2 participants