Exception - Call to a member function modify() on bool

Exception - Call to a member function modify() on bool

av Michael Brown -
Antal svar: 8

I am trying to install Moodle 4.0.12 on Lunix with PHP 7.4 and Mariadb 10.5.26.

I get this error after I attempt to log into the Moodle site (home page comes up fine).  Any idea what could be the cause and solution to it?

Warning: DateTimeImmutable::setTimestamp() expects parameter 1 to be int, string given in /var/www/html/LMS/course/lib.php on line 4156

Error

Exception - Call to a member function modify() on bool
Debug info:
Error code: generalexceptionmessage
Stack trace:
  • line 4156 of /course/lib.php: Error thrown
  • line 4124 of /course/lib.php: call to course_classify_end_date()
  • line 3195 of /lib/navigationlib.php: call to course_classify_for_timeline()
  • line 1459 of /lib/navigationlib.php: call to global_navigation->load_courses_enrolled()
  • line 4295 of /lib/navigationlib.php: call to global_navigation->initialise()
  • line 832 of /lib/pagelib.php: call to settings_navigation->__construct()
  • line 957 of /lib/pagelib.php: call to moodle_page->magic_get_settingsnav()
  • line 761 of /lib/classes/navigation/views/secondary.php: call to moodle_page->__get()
  • line 236 of /lib/classes/navigation/views/secondary.php: call to core\navigation\views\secondary->load_admin_navigation()
  • line 885 of /lib/pagelib.php: call to core\navigation\views\secondary->initialise()
  • line 957 of /lib/pagelib.php: call to moodle_page->magic_get_secondarynav()
  • line 80 of /theme/academi/layout/includes/layoutdata.php: call to moodle_page->__get()
  • line 27 of /theme/academi/layout/drawers.php: call to require_once()
  • line 1477 of /lib/outputrenderers.php: call to include()
  • line 1403 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
  • line 86 of /my/courses.php: call to core_renderer->header()
Genomsnitt av betyg: -
Som svar till Michael Brown

Re: Exception - Call to a member function modify() on bool

av Visvanath Ratnaweera -
Bild på Particularly helpful Moodlers Bild på Translators
Academi is not a standard theme. Switch to Boost and compare.

Hint: If the Moodle front-end doesn't come up, you can add the following line to moodle/config.php:
$CFG->theme='boost';
Som svar till Visvanath Ratnaweera

Re: Exception - Call to a member function modify() on bool

av Michael Brown -
Great suggestion, but that did not work.
I have the exact same code and database running on another Linux server and in a cloud environment. That makes me think that is it some library not installed or server configuration. I am thinking something along those lines.
Som svar till Michael Brown

Re: Exception - Call to a member function modify() on bool

av Visvanath Ratnaweera -
Bild på Particularly helpful Moodlers Bild på Translators
Site administration > Server > Environment is all green?
Som svar till Visvanath Ratnaweera

Re: Exception - Call to a member function modify() on bool

av Michael Brown -

I cannot login so I cannot go to that screen. 

Som svar till Michael Brown

Re: Exception - Call to a member function modify() on bool

av Ken Task -
Bild på Particularly helpful Moodlers

First line in debug

points to this section of code - the line ** below:

function course_classify_end_date($course) {
    global $CFG;
    $coursegraceperiodafter = (empty($CFG->coursegraceperiodafter)) ? 0 : $CFG->coursegraceperiodafter;
** line 4156    $enddate = (new \DateTimeImmutable())->setTimestamp($course->enddate)->modify("+{$coursegraceperiodafter} days");
    return $enddate->getTimestamp();
}

Suggest issues with timestamp which are epoch time stamps. Server clock/TZ settings/data?

The line above that might be the trigger.

Courses do have a duration setting.

'SoS', Ken

Som svar till Michael Brown

Re: Exception - Call to a member function modify() on bool

av Michael Brown -
SOLUTION.
I figured it out with the help of ideas in the discussion.

I moved the database over from another implementation. For some reason the dates in the course table got messed up. I did an update to the startdate and enddate to set new dates using the DATE() function and now it works.

I think that when moving the database, I used a different character set or something. Rookie mistake.

Thanks for providing ideas.