Skip to content

Commit 80d8aef

Browse files
committed
Fix exception on editing a post
Cannot access private property mod_moodleoverflow\discussion\discussion::$userid line 69 of /mod/moodleoverflow/classes/anonymous.php: Error thrown line 582 of /mod/moodleoverflow/classes/post/post_control.php: call to mod_moodleoverflow\anonymous::is_post_anonymous() line 125 of /mod/moodleoverflow/post.php: call to mod_moodleoverflow\post\post_control->build_postform() Signed-off-by: Daniel Ziegenberg <[email protected]>
1 parent 990bfe5 commit 80d8aef

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

classes/anonymous.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
namespace mod_moodleoverflow;
2626

27+
use mod_moodleoverflow\discussion\discussion;
28+
2729
/**
2830
* Class for Moodleoverflow anonymity
2931
*
@@ -49,14 +51,14 @@ class anonymous {
4951
/**
5052
* Checks if post is anonymous.
5153
*
52-
* @param object $discussion moodleoverflow discussion
54+
* @param discussion $discussion moodleoverflow discussion
5355
* @param object $moodleoverflow
5456
* @param int $postinguserid user id of posting user
5557
*
5658
* @return bool true if user is not logged in, everything is marked anonymous
5759
* and if the question is anonymous and there are no answers yet, else false
5860
*/
59-
public static function is_post_anonymous($discussion, $moodleoverflow, $postinguserid): bool {
61+
public static function is_post_anonymous(discussion $discussion, $moodleoverflow, $postinguserid): bool {
6062
if ($postinguserid == 0) {
6163
return true;
6264
}
@@ -66,7 +68,7 @@ public static function is_post_anonymous($discussion, $moodleoverflow, $postingu
6668
}
6769

6870
if ($moodleoverflow->anonymous == self::QUESTION_ANONYMOUS) {
69-
return $discussion->userid == $postinguserid;
71+
return $discussion->get_userid() == $postinguserid;
7072
}
7173

7274
return false;

0 commit comments

Comments
 (0)