2.2 Flat File Cron Errors

2.2 Flat File Cron Errors

by John St -
Number of replies: 5

I'm running a fresh install of 2.2 and when trying to enroll via flatfile I get this error in the cron:

!!! Coding error detected, it must be fixed by a programmer: Could not load preference {$a}. Does the component and name you supplied to message_send() match a row in message_providers? Message providers must appear in the database so users can configure how they will be notified when they receive messages. !!!

This breaks the rest of the cron and no one gets enrolled. I have the flatfile enrol plugin set to not email anyone. Any ideas here? 

Average of ratings: -
In reply to John St

Re: 2.2 Flat File Cron Errors

by Steve Turley -

I'm having the same problem.  Please keep me posted if you find a solution.

In reply to John St

Re: 2.2 Flat File Cron Errors

by Jason Bittel -

I ran into this exact same problem and fixed it by going into Plugins -> Message outputs -> Default message outputs and clicking Save changes at the bottom, per the discussion in this thread: http://moodle.org/mod/forum/discuss.php?d=184927

That will populate the missing preferences and should resolve the error for you.

In reply to Jason Bittel

Re: 2.2 Flat File Cron Errors

by Dave O'Meara -

The solutions suggested on the http://moodle.org/mod/forum/discuss.php?d=184927 did not work for me.  I needed to get our students imported for the new semester, so I tracked down the buggy line of code.  It's in /lib/messagelib.php lines 127-134:

if (isset($defaultpreferences->{$defaultpreference})) {
            $permitted = $defaultpreferences->{$defaultpreference};
        } else {
            //MDL-25114 They supplied an $eventdata->component $eventdata->name combination which doesn't
            //exist in the message_provider table (thus there is no default settings for them)
            $preferrormsg = get_string('couldnotfindpreference', 'message', $preferencename); //TODO: undefined $preferencename
            //MIAD CHANGE MIAD CHANGE
            //echo the eventdata info and wrap the exception in an if to permit flatfile enrolments
            echo "\n component: ".$eventdata->component."\n name: ".$eventdata->name."\n"    ;
            if ($eventdata->name != "flatfile_enrolment"){
            throw new coding_exception($preferrormsg,'blah');
            }
        }

I changed it to:

if (isset($defaultpreferences->{$defaultpreference})) {
            $permitted = $defaultpreferences->{$defaultpreference};
        } else {
            //MDL-25114 They supplied an $eventdata->component $eventdata->name combination which doesn't
            //exist in the message_provider table (thus there is no default settings for them)
            $preferrormsg = get_string('couldnotfindpreference', 'message', $preferencename); //TODO: undefined $preferencename
            // wrap the exception in an if to permit flatfile enrolment
            if ($eventdata->name != "flatfile_enrolment"){
            throw new coding_exception($preferrormsg,'blah');
            }
        }

It also works if you just comment out the coding_exception line:

//throw new coding_exception($preferrormsg,'blah');

But I figured it was safer to wrap it in an if statement, in case this snippet gets called in some situation where it works.

 

 

In reply to Dave O'Meara

Re: 2.2 Flat File Cron Errors

by Cesar C -

Was an issue created in JIRA, providing this patch?

In reply to Cesar C

Re: 2.2 Flat File Cron Errors

by Greg Rodenhiser -

This problem still persists with the latest 2.2.2+ install on linux/mysql.  Is this close to being fixed in the code??  Would rather not apply a hack/work around that may break things later down the road as we use and patch.