ModernLMS / moodle-availability_othercompleted

This plugin allow to restrict access of activities and resources in your course based on other course completion.
6 stars 12 forks source link

Notice: Trying to get property 'id' of non-object condition.php on line 91 #10

Closed mlohoar closed 4 years ago

mlohoar commented 4 years ago

current line 91: if($user->id > 0 && $user->timecompleted != NULL){ line 88: $user = $DB->get_record('c..... returns an object or false.

Change line 91 to be: if($user!==false && $user->id > 0 && $user->timecompleted != NULL){

amarizaty commented 4 years ago

25 Feb 2020

sam-suresh commented 4 years ago

Fixed

kristian-94 commented 3 years ago

@sam-suresh Is this fixed? I'm still getting the error on master. There is no new commit there in 2020.

amarizaty commented 3 years ago

@kristian-94 can explain what error you face it?

kristian-94 commented 3 years ago

@amarizaty It fails on moodle 3.9 and php 7.4

vendor/bin/phpunit "availability_othercompleted_condition_testcase" availability/condition/othercompleted/tests/condition_test.php
Moodle 3.9.3+ (Build: 20201121), 2ace77b5495b63cdb7c2560ac3ed6090ab406274
Php: 7.4.3, pgsql: 9.6.17, OS: Linux 5.4.0-53-generic x86_64
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

E..E..                                                              6 / 6 (100%)

Time: 1.51 seconds, Memory: 80.50 MB

There were 2 errors:

1) availability_othercompleted_condition_testcase::test_in_tree
Trying to get property 'id' of non-object

/siteroot/availability/condition/othercompleted/classes/condition.php:91
/siteroot/availability/classes/condition.php:84
/siteroot/availability/classes/tree.php:265
/siteroot/availability/condition/othercompleted/tests/condition_test.php:77
/siteroot/lib/phpunit/classes/advanced_testcase.php:80

To re-run:
 vendor/bin/phpunit "availability_othercompleted_condition_testcase" availability/condition/othercompleted/tests/condition_test.php

2) availability_othercompleted_condition_testcase::test_usage
Trying to get property 'id' of non-object

/siteroot/availability/condition/othercompleted/classes/condition.php:91
/siteroot/availability/condition/othercompleted/tests/condition_test.php:187
/siteroot/lib/phpunit/classes/advanced_testcase.php:80

To re-run:
 vendor/bin/phpunit "availability_othercompleted_condition_testcase" availability/condition/othercompleted/tests/condition_test.php

ERRORS!
Tests: 6, Assertions: 13, Errors: 2.