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

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

by Michael Brown -
Number of replies: 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()
Average of ratings: -
In reply to Michael Brown

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

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of 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';
In reply to Visvanath Ratnaweera

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

by 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.
In reply to Michael Brown

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

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Site administration > Server > Environment is all green?
In reply to Visvanath Ratnaweera

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

by Michael Brown -

I cannot login so I cannot go to that screen. 

In reply to Michael Brown

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

by Ken Task -
Picture of 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

In reply to Michael Brown

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

by 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.
In reply to Michael Brown

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

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators

Good that you could SOLVE it! The community here had no chance. For us Installing Moodle and Moodle migration are two different things. "moved the database over from another implementation" is a part of Moodle migration.