Closed michael-milette closed 8 years ago
Dear Michael,
We've tested it on Moodle 2.7 and Moodle 2.9 and didn't experience this issue that you posted. Can you please specify your PHP version and anything which help us to diagnose this issue?.
Regards, 3i Logic LMS Team
I really don't think this is a PHP version issue but perhaps a PHP configuration difference. I am not ready to troubleshoot your environment to figure out why you are not seeing the error at this time.
That said, I will be happy to provide you with an explanation of why the error is occurring as well as a solution.
If you look at your source code, you will notice that,on line 45 of block_learning_plan, you have:
$this->content = new stdClass;
Then on line 51, you are attempting to append to a string which has not yet been initialized.
$this->content->text .= html_writer::link(...
Hence, PHP gives you an Undefined Property notice. The solution of course is to simply initialize the string before you start appending to it. If you insert the following somewhere between line 45 and 51 (except inside the "if (!strpos($pageurl, '='))" section) , the error will go away:
$this->content->text = '';
Let me know if you have any questions or concerns.
Best regards,
Michael
An alternative solution is to simply remove the period on line 51:
Change:
$this->content->text .= html_writer::link(...
to:
$this->content->text = html_writer::link(...
Dear Michael,
We've tested it on PHP version 5.4 and 5.5 and its working fine on PHP version 5.4 but in 5.5 it showing notice. We've fixed this issue by initializing $this->content->text = ''; after object creation on line number 46.
Thank you for contribution.
Regards, 3i Logic LMS Team
Thank you!
When I go to the Front page with a learning plan block on it, I get the following error when debugging is set to developer mode:
Notice: Undefined property: stdClass::$text in /var/www/moodle/blocks/learning_plan/block_learning_plan.php on line 51
This is for version 2014082003 that I just downloaded from GitHub.