Moodle
  1. Moodle
  2. MDL-17031

Flat file enrolment : Unknown role in field2

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.9.3, 1.9.4, 1.9.5, 1.9.6, 1.9.7, 1.9.8, 1.9.9, 1.9.17
    • Fix Version/s: None
    • Component/s: Enrolments
    • Labels:
      None
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Rank:
      982

      Description

      Flat file enrolment don't work correctly.

      The enrolment file IS in the good place, IS processed by the cron job, BUT it returns (in the cron print) errors "Unknown role in field2" for each enrolment

      A solution i've found is to (as administrator) open the Flat File enrolment settings, and save them (without changing anything), just before running the cron. Doing so, it's well processed, without errors.

      Seems like some short role names wasn't well taken...

        Activity

        Hide
        Séverin Terrier added a comment -

        You can look at this discussion :
        http://moodle.org/mod/forum/discuss.php?d=106315

        Show
        Séverin Terrier added a comment - You can look at this discussion : http://moodle.org/mod/forum/discuss.php?d=106315
        Hide
        Séverin Terrier added a comment -

        It seems ok in (at least) latest 1.9.5+

        Show
        Séverin Terrier added a comment - It seems ok in (at least) latest 1.9.5+
        Hide
        Séverin Terrier added a comment -

        In fact, some days it's ok, and some other days no...
        I've not find why for the moment

        The role short name, and the role used in the flat file are always "student", and the flat file is always made the same way...

        Show
        Séverin Terrier added a comment - In fact, some days it's ok, and some other days no... I've not find why for the moment The role short name, and the role used in the flat file are always "student", and the flat file is always made the same way...
        Hide
        Séverin Terrier added a comment -

        You can also look at this discussion :
        http://moodle.org/mod/forum/discuss.php?d=106457

        Show
        Séverin Terrier added a comment - You can also look at this discussion : http://moodle.org/mod/forum/discuss.php?d=106457
        Hide
        Jeffery Watkins added a comment -

        Same problem. Same error.

        Any ideas on a fix for this?

        Show
        Jeffery Watkins added a comment - Same problem. Same error. Any ideas on a fix for this?
        Hide
        Dan Poltawski added a comment -

        Hi,

        Is this still an issue in 2.x? If so could you help me understand how to reproduce it?

        thanks,

        Dan

        Show
        Dan Poltawski added a comment - Hi, Is this still an issue in 2.x? If so could you help me understand how to reproduce it? thanks, Dan
        Hide
        Dan Poltawski added a comment -

        Closing, as I can't reproduce this issue.

        Show
        Dan Poltawski added a comment - Closing, as I can't reproduce this issue.
        Hide
        Séverin Terrier added a comment -

        Haven't (yet) tested in 2.x, but i'm now using Moodle 1.9.17+ (Build: 20120329), and looking at the recent cron logs, i still have this error (without changing Moodle site, or the way the enrolment flatfile is made) :

        moodle@Moodle-UT1 ~/log/cours $ tail cours.cron.2012-07-10.23h30.txt
        4931: add student 21200436 L1-Eco-Compta :Unknown role in field2 - ignoring line
        4932: add student 21200436 L1-MASS-Stat1 :Unknown role in field2 - ignoring line
        4933: add student 21200436 L1TSE-InformatiqueDocuments :Unknown role in field2 - ignoring line
        4934: add student 21200436 TSE-Stage :Unknown role in field2 - ignoring line
        4935: add student 21200437 L1-Droit-S1-Economie :Unknown role in field2 - ignoring line
        4936: add student 21200438 L1-Droit-S1-Economie :Unknown role in field2 - ignoring line
        4937: add student 21200439 L1-Droit-S1-Economie :Unknown role in field2 - ignoring line

        Cron script completed correctly
        Execution took 50.305859 seconds

        But when i look at cours.cron.2012-07-11.23h30.txt i find
        6625: add student 21200436 L1-Eco-Compta :OK
        6626: add student 21200436 L1-MASS-Stat1 :OK
        6627: add student 21200436 L1TSE-InformatiqueDocuments :OK
        6628: add student 21200436 TSE-Stage :OK
        6629: add student 21200437 L1-Droit-S1-Economie :OK
        6630: add student 21200438 L1-Droit-S1-Economie :OK
        6631: add student 21200439 L1-Droit-S1-Economie :OK

        Really don't understand what can be different from day to day...

        Show
        Séverin Terrier added a comment - Haven't (yet) tested in 2.x, but i'm now using Moodle 1.9.17+ (Build: 20120329), and looking at the recent cron logs, i still have this error (without changing Moodle site, or the way the enrolment flatfile is made) : moodle@Moodle-UT1 ~/log/cours $ tail cours.cron.2012-07-10.23h30.txt 4931: add student 21200436 L1-Eco-Compta :Unknown role in field2 - ignoring line 4932: add student 21200436 L1-MASS-Stat1 :Unknown role in field2 - ignoring line 4933: add student 21200436 L1TSE-InformatiqueDocuments :Unknown role in field2 - ignoring line 4934: add student 21200436 TSE-Stage :Unknown role in field2 - ignoring line 4935: add student 21200437 L1-Droit-S1-Economie :Unknown role in field2 - ignoring line 4936: add student 21200438 L1-Droit-S1-Economie :Unknown role in field2 - ignoring line 4937: add student 21200439 L1-Droit-S1-Economie :Unknown role in field2 - ignoring line Cron script completed correctly Execution took 50.305859 seconds But when i look at cours.cron.2012-07-11.23h30.txt i find 6625: add student 21200436 L1-Eco-Compta :OK 6626: add student 21200436 L1-MASS-Stat1 :OK 6627: add student 21200436 L1TSE-InformatiqueDocuments :OK 6628: add student 21200436 TSE-Stage :OK 6629: add student 21200437 L1-Droit-S1-Economie :OK 6630: add student 21200438 L1-Droit-S1-Economie :OK 6631: add student 21200439 L1-Droit-S1-Economie :OK Really don't understand what can be different from day to day...
        Hide
        Séverin Terrier added a comment -

        I've looked deep into all 2012 cron logs on my server, and i can tell one thing :

        ALL times the cron for flatfile enrolment failed with "Unknown role in field2" error, automatic backups was NOT executed, and forum RSS generation was NOT executed either !

        At the opposite, ALL times flatfile enrolments have been OK (without "Unknown role in field2" error), automatic backups AND forum RSS generation WAS executed !

        I don't understand exactly what this means, if one of these action make something like opening well a connexion for something... if someone has an idea, and what i could add to make flatfile enrolment work well each time...

        Show
        Séverin Terrier added a comment - I've looked deep into all 2012 cron logs on my server, and i can tell one thing : ALL times the cron for flatfile enrolment failed with "Unknown role in field2" error, automatic backups was NOT executed, and forum RSS generation was NOT executed either ! At the opposite, ALL times flatfile enrolments have been OK (without "Unknown role in field2" error), automatic backups AND forum RSS generation WAS executed ! I don't understand exactly what this means, if one of these action make something like opening well a connexion for something... if someone has an idea, and what i could add to make flatfile enrolment work well each time...
        Hide
        Dan Poltawski added a comment -

        Reopening this, since you still are having the problem.

        (sorry for the premature close)

        Show
        Dan Poltawski added a comment - Reopening this, since you still are having the problem. (sorry for the premature close)
        Hide
        Doug Walker added a comment - - edited

        I started having this issue this semester after having been on 1.9.12+ for a while. I'm not sure what changed. The maddening thing about this is that it seems to be inconsistent. I tried all of the various tricks but nothing seemed to consistently work.

        I added print_r statements in various places of the php to verify that the correct "shortname" and "id" were being returned from the _role table. Everything seemed to be fine.

        As a desperate act I ended up commenting out the following lines in flatfile/enrol.php

        /// check correct formatting of role field
        
            if (!isset($rolemap[$fields[1]]) && !isset($roles[$fields[1]])) {
        
                 $this->log .= "Unknown role in field2 - ignoring line\n";
        
                 continue;}
        

        Not the best solution ... but so far, it seems to work. I will probably continue to troubleshoot but 1) I'm not a php guru and 2) I'm the only sysadmin here and I have a lot going on right now so I won't be able to devote a lot of time.

        My thoughts are that there is a problem with the value-pair function in enrol.php or for some reason the arrays are returning empty at the time it is checking the correct formatting. However, if you echo out the arrays before and after the check they seem to be fine (at least on our set up).

        [EDIT: I had trouble getting the formatting to be correct in the php code snippet above. Sorry about that.]

        Show
        Doug Walker added a comment - - edited I started having this issue this semester after having been on 1.9.12+ for a while. I'm not sure what changed. The maddening thing about this is that it seems to be inconsistent. I tried all of the various tricks but nothing seemed to consistently work. I added print_r statements in various places of the php to verify that the correct "shortname" and "id" were being returned from the _role table. Everything seemed to be fine. As a desperate act I ended up commenting out the following lines in flatfile/enrol.php /// check correct formatting of role field if (!isset($rolemap[$fields[1]]) && !isset($roles[$fields[1]])) { $ this ->log .= "Unknown role in field2 - ignoring line\n" ; continue ;} Not the best solution ... but so far, it seems to work. I will probably continue to troubleshoot but 1) I'm not a php guru and 2) I'm the only sysadmin here and I have a lot going on right now so I won't be able to devote a lot of time. My thoughts are that there is a problem with the value-pair function in enrol.php or for some reason the arrays are returning empty at the time it is checking the correct formatting. However, if you echo out the arrays before and after the check they seem to be fine (at least on our set up). [EDIT: I had trouble getting the formatting to be correct in the php code snippet above. Sorry about that.]
        Hide
        Doug Walker added a comment -

        Well, I spoke too soon. It worked through yesterday. Now I get the error:

        "Unknown user idnumber in field 3 - ignoring line."

        No matter what I do, I can't get this to process the flat file correctly. I know that the user idnumbers are, in fact, correct.

        Show
        Doug Walker added a comment - Well, I spoke too soon. It worked through yesterday. Now I get the error: "Unknown user idnumber in field 3 - ignoring line." No matter what I do, I can't get this to process the flat file correctly. I know that the user idnumbers are, in fact, correct.
        Hide
        Séverin Terrier added a comment -

        In relation with my last comment, i've tried another thing :

        Seeing that RSS feeds had a relation (still don't understand why ???) with this error, i've modified information about cron for RSS, with a line like this :
        UPDATE mdl_block SET cron = 0 WHERE name = 'rss_client';

        And with that, the "Unknown role in field2" error has gone

        But, as then RSS feeds aren't updated (this can be a problem), i also change it back to it's default value with this line :
        UPDATE mdl_block SET cron = 300 WHERE name = 'rss_client';

        In fact, i've made a little script to make these changes, and i call it before and after the time my Moodle cron will take care of these flat file enrolments (with a cron on my server).

        It's not the simplest solution (i would have been interested to have one, and still am), but (at least) it seem's to work, since 3 days...
        Hope this helps

        Show
        Séverin Terrier added a comment - In relation with my last comment, i've tried another thing : Seeing that RSS feeds had a relation (still don't understand why ???) with this error, i've modified information about cron for RSS, with a line like this : UPDATE mdl_block SET cron = 0 WHERE name = 'rss_client'; And with that, the "Unknown role in field2" error has gone But, as then RSS feeds aren't updated (this can be a problem), i also change it back to it's default value with this line : UPDATE mdl_block SET cron = 300 WHERE name = 'rss_client'; In fact, i've made a little script to make these changes, and i call it before and after the time my Moodle cron will take care of these flat file enrolments (with a cron on my server). It's not the simplest solution (i would have been interested to have one, and still am), but (at least) it seem's to work, since 3 days... Hope this helps
        Hide
        Dan Poltawski added a comment -

        Sorry, haven't been following this issue that closely (been away), but Séverin, your latest comment makes me think one of your RSS feeds is preventing cron from completing? Do you have cron logging?

        Show
        Dan Poltawski added a comment - Sorry, haven't been following this issue that closely (been away), but Séverin, your latest comment makes me think one of your RSS feeds is preventing cron from completing? Do you have cron logging?
        Hide
        Séverin Terrier added a comment -

        Thanks Dan for your message.

        Yes, i'm logging cron, and i've checked all of 2012 (see my message from july 18) to find this relation, and all my cron completes OK !

        I think that it's not directly related to enrolment cron, but rather to other cron jobs, that are not always executed (and leave a bad state making enrolment to fail) ! This explains why sometimes execution is OK, and sometimes not (with the same data).

        The solution from august 31 IS working, even if it's complicated and not the best way to work.
        If someone has a good working solution, i'm interested...

        Show
        Séverin Terrier added a comment - Thanks Dan for your message. Yes, i'm logging cron, and i've checked all of 2012 (see my message from july 18) to find this relation, and all my cron completes OK ! I think that it's not directly related to enrolment cron, but rather to other cron jobs, that are not always executed (and leave a bad state making enrolment to fail) ! This explains why sometimes execution is OK, and sometimes not (with the same data). The solution from august 31 IS working, even if it's complicated and not the best way to work. If someone has a good working solution, i'm interested...
        Hide
        Doug Walker added a comment -

        Does anyone see a problem with moving the job that is causing problems (in this case "blocks") to the end of the cron job in cron.php? I've run it this was as a test and so far I have not had any problems that I can see. Enrolments processed properly.

        Show
        Doug Walker added a comment - Does anyone see a problem with moving the job that is causing problems (in this case "blocks") to the end of the cron job in cron.php? I've run it this was as a test and so far I have not had any problems that I can see. Enrolments processed properly.
        Hide
        Dan Poltawski added a comment -

        I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue.
        For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment

        Show
        Dan Poltawski added a comment - I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue. For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment

          People

          • Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated: