Fatal error require_once(grade_object.php) No such file or directory...

Fatal error require_once(grade_object.php) No such file or directory...

by Paul Vasilauskis -
Number of replies: 2

Have version 1.9.4 in production, wanted to try out 2.0. IT person (who originally set up 1.8.3 later upgrading it to the 1.9.4) backed everything up, set up 2.0.2 with a copy of the database from the older running version (1.9.4) My initial quick look at 2.0 saw the courses were there, cool, I'll play with it later. About this same time our IT group upgraded PHP to 5.2.17 (I don't know what the original version of PHP was, maybe 5.2.1) Shortly after this I get reports of teachers being able to see their courses but if they go in to edit anything all they get is a white screen.

After Googling and searching forums I go and turn on debugging. Now I see the following errors:

Warning: require_once(fcFPP.php) [function.require-once]: failed to open stream: No such file or directory in �1��evweb/moodle/1.9.4/admin/fcFPP.php on line 20

Fatal error: require_once() [function.require]: Failed opening required 'fcFPP.php' (include_path='/a/devweb/moodle/1.9.4/lib/pear:.:/usr/csite/pubtools/php/5.2.17/lib/php') in �1��evweb/moodle/1.9.4/admin/fcFPP.php on line 20

Thinking it was looking for the fcFPP.php file in the admin directory and couldn't find it and that things might have gotten moved or deleted when they were messing with the servers I went and found it in the fc directory and copied it over to the admin directory. That fixed the problem with the teachers not being able to make edits. However, now I find if I go to certain Admin areas such as Notifications I get the same type of error except now it's looking for the grade_object.php file. I also find that the error is somewhat random. Sometimes it worked, sometimes it didn't. I copied grade_object.php from lib/grade to the lib/pear directory and that fixed that. Or so I thought.

 

Now I start playing around with 2.0.2 and everything looks ok until I go into the Admin sections. Just about any admin link results in the following error:

Warning: require_once(grade_object.php): failed to open stream: No such file or directory in ���evweb/moodle/2.0.2/lib/pear/grade_object.php on line 28

Fatal error: require_once(): Failed opening required 'grade_object.php' (include_path='/a/devweb/moodle/2.0.2/lib/zend:/a/devweb/moodle/2.0.2/lib/pear:.:/usr/csite/pubtools/php/5.2.17/lib/php') in on line 28

 

Again it is not consistant. At first I was getting the blank pages when I went to turn on debugging but after several attempts including logging out and back in I was finally able to turn on debugging to get the above error. It is quite repeatable on most links from site admin. Now I have this same type of error from two different versions of Moodle, something ain't right.

There are only four files that have require_once(grade_object.php) on line 28 they are grade_scale.php, grade_category.php, grade_grade.php and grade_outcome.php. grade_item.php hasit on line 27 and I have seen that error pop up on occasion. But why would any of that be called for admin actions?

I don't know where to go at this point. I'm pretty sure it's not a problem with files being moved. We're on an intranet with no outside access, it's a small user group and we're still only writing the material for the production version it's not really in use yet so I doubt we've been hacked.

Any ideas on what to look at? I'm thinking it has to do with the PHP upgrade. I looked at the PHPInfo (strangly that link doesn't error out) and I see nothing unusual but I am in no way knowledgeable in this area. Server -> Enviroment shows everything OK except for the php_extension and php_check_php533 which show as check but don't sound likely to be problems. Why would grade* be causing problems in admin functions? Unfortunately I don't have write permissions on the 2.0.2 files so I can't place an echo statement before line 28 of these files to see which one is pulling the error. Again, any ideas on which direction to go with this?

Average of ratings: -
In reply to Paul Vasilauskis

Re: Fatal error require_once(grade_object.php) No such file or directory...

by Paul Vasilauskis -

Nothing???

Here's what I have so far:

According to the initial debugging error from php:

Warning: require_once(grade_object.php): failed to open stream: No such file or directory in evweb/moodle/2.0.2/lib/pear/grade_object.php on line 28

Fatal error: require_once(): Failed opening required 'grade_object.php' (include_path='/a/devweb/moodle/2.0.2/lib/zend:/a/devweb/moodle/2.0.2/lib/pear:.:/usr/csite/pubtools/php/5.2.17/lib/php') in on line 28

it was failing looking for grade_object.php in a "require_once(grade_object.php)" command on line #28.

I found four files that had that command on line #28. In each of those files I surrounded the require_once with print statements showing the name of the file which is executing them. (the below example is from the grade_category.php file)

print "Pre-grade_category.php<br>";
require_once('grade_object.php');
print "Post-grade_category.php<br>";

This allowed me to see that the line immediately before the problem was executed, that it failed and the "Post..." line was not executed.

I found that grade_category.php seemed to almost always be the one where it failed printing just "Pre-grade_category.php" followed by the error statements but sometimes the second file (grade_item.php) would be the one to fail or nothing would fail and it would successfully go through all of the require_once statements with no problems.

So then I threw in: debug_print_backtrace()

print "Pre-grade_category.php<br>";
debug_print_backtrace();
require_once('grade_object.php');
print "Post-grade_category.php<br>";

This would show me the progression of what called what. Below are two separate runs. It starts at #5 and works back from there, things go bad at #2. There you'll notice the beginning of the path appears to be corrupted no longer "/a/devweb/moodle/2.0.2/...". The below come from selecting view -> Source from the browser.

Pre-grade_category.php<br>
#0 require_once() called at [:32]
#1 require_once() called at [x��evweb/moodle/2.0.2/lib/grade/grade_category.php:35]
#2 require_once(x��evweb/moodle/2.0.2/lib/grade/grade_category.php) called at [/a/devweb/moodle/2.0.2/mod/workshop/settings.php:32]
#3 include(/a/devweb/moodle/2.0.2/mod/workshop/settings.php) called at [/a/devweb/moodle/2.0.2/admin/settings/plugins.php:20]
#4 require(/a/devweb/moodle/2.0.2/admin/settings/plugins.php) called at [/a/devweb/moodle/2.0.2/lib/adminlib.php:5617]
#5 admin_get_root() called at [/a/devweb/moodle/2.0.2/admin/index.php:392]

Warning: require_once(grade_object.php): failed to open stream:...

Pre-grade_category.php<br>
#0 require_once() called at [:32]
#1 require_once() called at [rr�evweb/moodle/2.0.2/lib/grade/grade_category.php:35]
#2 require_once(rr�evweb/moodle/2.0.2/lib/grade/grade_category.php) called at [/a/devweb/moodle/2.0.2/mod/workshop/settings.php:32]
#3 include(/a/devweb/moodle/2.0.2/mod/workshop/settings.php) called at [/a/devweb/moodle/2.0.2/admin/settings/plugins.php:20]
#4 require(/a/devweb/moodle/2.0.2/admin/settings/plugins.php) called at [/a/devweb/moodle/2.0.2/lib/adminlib.php:5617]
#5 admin_get_root() called at [/usr/csite/WebServer/moodle/beta/admin/index.php:392]

Warning: require_once(grade_object.php): failed to open stream:...

Below is the view -> source of one that worked:

Pre-grade_category.php<br>
#0 require_once() called at [/a/devweb/moodle/2.0.2/lib/gradelib.php:32]
#1 require_once(/a/devweb/moodle/2.0.2/lib/gradelib.php) called at [/a/devweb/moodle/2.0.2/mod/workshop/locallib.php:35]
#2 require_once(/a/devweb/moodle/2.0.2/mod/workshop/locallib.php) called at [/a/devweb/moodle/2.0.2/mod/workshop/settings.php:32]
#3 include(/a/devweb/moodle/2.0.2/mod/workshop/settings.php) called at [/a/devweb/moodle/2.0.2/admin/settings/plugins.php:20]
#4 require(/a/devweb/moodle/2.0.2/admin/settings/plugins.php) called at [/a/devweb/moodle/2.0.2/lib/adminlib.php:5617]
#5 admin_get_root() called at [/a/devweb/moodle/2.0.2/admin/index.php:392]
Pre-grade_objectPost-grade_object<br>
Post-grade_category.php<br>
Pre-grade_item.php<br>
Post-grade_item.php<br>
Pre-grade_grade.php<br>
Post-grade_grade.php<br>
Pre-grade_scale.php<br>
Post-grade_scale.php<br>
Pre-grade_outcome.php<br>
Post-grade_outcome.php<br>

If I follow the code #5 comes from line #392 in admin/index.php


$adminroot = admin_get_root();

That function is defined in lib/adminlib.php starting on line 5588 where at line 5617 we get #4


require($CFG->dirroot.'/'.$CFG->admin.'/settings/plugins.php');

$CFG->dirroot = "/a/devweb/moodle/2.0.2" and $CFG->admin = "admin".


In plugins.php it loops through all the modules each executing an include which is where #3 comes from.

include($CFG->dirroot.'/mod/'.$modulename.'/settings.php');

The $modulename = "workshop". For #2 in the /workshop/settings.php file at line #32 we should be executing the line:

require_once($CFG->dirroot.'/mod/workshop/locallib.php');

which in the above correct run you see that it does. What I don't understand is how in the bad runs it shows it as something else.

If everything goes right locallib.php at line #35 executes.

require_once($CFG->libdir . '/gradelib.php');
gradelib.php starts with a bunch of require_once() commands with the second one being the one that requires the grade_category.php file
where we have the debug_print_backtrace().

require_once($CFG->libdir . '/grade/constants.php');

require_once($CFG->libdir . '/grade/grade_category.php');
require_once($CFG->libdir . '/grade/grade_item.php');
require_once($CFG->libdir . '/grade/grade_grade.php');
require_once($CFG->libdir . '/grade/grade_scale.php');
require_once($CFG->libdir . '/grade/grade_outcome.php');

It's like part of the code gets skipped. Instead of require_once getting locallib.php, that is skipped along with gradelib.php and we jump right into
the require_once in grade_category.php where it looks to include grade_object.php but can't find it cause the path is all messed up. The way
stuff is getting corrupted and out of place it's like a memory or stack issue? Is there a php config setting or so that is too small since we've
sorta nested down several layers of require_onces calling files with more requires...???

In reply to Paul Vasilauskis

Re: Fatal error require_once(grade_object.php) No such file or directory...

by Paul Vasilauskis -

Well I fixed it or at least it appears to be working.

The fix is to go to the directory /lib/grade and into grade_category.php, grade_item.php, grade_grade.php, grade_scale.php and grade_outcome.php and change the line at the beginning of each

require_once('grade_object.php');

to

require_once($CFG->libdir . '/grade/grade_object.php');

Everything I read online indicated it should have worked as is since all of the files are in the same directory which should have been the first place the require_once() looked.

I also wonder why the debug_print_backtrace() showed bad path names being used in the require_once() calls starting at line #2 when it clearly was able to contine another two steps executing two more require_once() commands beyond that before the one that fails.

Don't exactly have a warm fuzzy feeling the underlying problem is solved only put off by fully describing the path to the file.