Installation help

 
 
Picture of Slobodan Jovcic
PHP Error During Database Update
 
Hi,

I'm upgrading from 1.5.2 to 1.5.3+ 2005060230 (latest CVS checkout from about an hour before this post). Database update fails on the second step with the error:

Fatal error: Call to undefined function category_parent_visible() in /web/moodle15/root/lib/datalib.php on line 2358

Page is admin/index.php. Hitting Refresh yields the same message. Update went through fine when I added:
include_once("../course/lib.php");

in the file lib/datalib.php (lines 2357 to 2359):
foreach ($categories as $key => $category) {
include_once("../course/lib.php");
if (!$category->visible || !category_parent_visible($category->parent)) {


Thoughts?
 
Average of ratings: -
Picture of Dan Eliot
Re: PHP Error During Database Update
 

I'm getting the exact same error.  I did a CVS update and now my Moodle is broken.  Students can't use the website, any thoughts??

Exact Error I'm getting:

Fatal error: Call to undefined function: category_parent_visible() in /home_dir_here/lib/datalib.php on line 2358

 
Average of ratings: -
Me and Ray
Re: PHP Error During Database Update
 
category_parent_visible should be in the same file so I guess that the file datalib.php was only partially downloaded, or at that moment in time there was a glitch with CVS.
 
Average of ratings: -
Picture of Patrick Li
Re: PHP Error During Database Update
Group Developers
That was my fault. Those functions are now moved to datalib.

A cvs update would fix this problem.
 
Average of ratings: -
Picture of Dan Eliot
Re: PHP Error During Database Update
 

A CVS update was how I **GOT** the problem smile

Dan

 
Average of ratings: -
Picture of Penny Leach
Re: PHP Error During Database Update
Group Developers
Unfortunately, there is a delay between developer CVS and anonymous CVS, so doing a CVS update right now is not going to solve anything. I'm not sure how long this delay is, but in the meantime, attached are the correct files (course/lib.php and lib/datalib.php) .. just unzip this file into your moodle directory.

 
Average of ratings: -
Picture of Dan Eliot
Re: PHP Error During Database Update
 

Ahhhh... Thank you very much Penny... much appreciated.  My students have access now smile

Dan

 
Average of ratings: -
Picture of Penny Leach
Re: PHP Error During Database Update
Group Developers
no problem smile

Next time you upgrade, run

cvs up -C course/lib.php lib/datalib.php

first, which will overwrite any local changes. Just in case cvs gets confused ;)

( -C means clobber )
 
Average of ratings: -
Picture of Dan Eliot
Re: PHP Error During Database Update
 

datalib.php is still Buggy.

Today, I created some new students and got the following error(s) at login:

<>

Warning

Dan


>: Invalid argument supplied for foreach()in /home/www/edhsonline/lib/datalib.php on line 2231
 
Average of ratings: -
Picture of Iñaki Arenaza
Re: PHP Error During Database Update
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers
I guess the problem is the new code that tries to hide courses marked as not visible. When the student is not enroled in any course (like your new student), that code produces the warning you are seeing (but is harmless otherwise).

I suppose something like the following might do the trick (just add the bold+underlined lines):
  if (!empty ($course)) {
      $courses = get_records_list('course', 'id', implode(',', $course));
      foreach ($courses as $k => $c) {
          if (empty($USER->admin) && (!$c->visible || !course_parent_visible($c))) {
              unset($course[$c->id]);
          }
      }
  }
Saludos. Iñaki.



 
Average of ratings: -
Picture of Penny Leach
Re: PHP Error During Database Update
Group Developers
I'm committing a patch to cvs shortly to fix this warning.

(It's benign, by the way)
 
Average of ratings: -
Picture of Iñaki Arenaza
Re: PHP Error During Database Update
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers
I think the fix you commited on CVS is wrong. It tests whether count($courses) is greater than 0, but you should be testing count($course), as this is the array we fill in above the test. $courses is set below the test, from the database query. So someone should apply this to CVS:
--- datalib.php.orig    2005-12-30 14:57:15.000000000 +0100
+++ datalib.php 2005-12-30 14:57:31.000000000 +0100
@@ -2227,7 +2227,7 @@
$course[$student->course] = $student->course;
}
}
- if (count($courses) > 0) {
+ if (count($course) > 0) {
$courses = get_records_list('course', 'id', implode(',', $course));
foreach ($courses as $k => $c) {
if (empty($USER->admin) && (!$c->visible || !course_parent_visible($c))) {

Saludos. Iñaki.
 
Average of ratings: -
Picture of Chin Yee
Re: PHP Error During Database Update
 

How about:

    $courses = get_records_list('course', 'id', implode(',', $course));
    if (is_array($courses)) {
foreach ($courses as $k => $c) { if (empty($USER->admin) && (!$c->visible || !course_parent_visible($c))) { unset($course[$c->id]); } } }


My additions underlined.

 
Average of ratings: -