Moodle
  1. Moodle
  2. MDL-3510

invalid argument and fatal error related to blocks

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: None
    • Component/s: Blocks
    • Labels:
      None
    • Environment:
      All
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_15_STABLE
    • Rank:
      10889

      Description

      I just upgraded to 1.5. When I change course settings, and save them, I suddenly get the following messages (the url displayed is http://www.glyphdoctors.com/course/edit.php):

      Warning: Invalid argument supplied for foreach() in /home/mine/public_html/lib/blocklib.php on line 168

      Fatal error: Cannot break/continue 1 level in /home/mine/public_html/lib/blocklib.php on line 188

      My changes are saved, but I don't know what to make of these messages. I haven't made any hacks to blocks or the blocklib.php file.

      I'm using Moodle latest downloaded today.

        Activity

        Hide
        Martin Dougiamas added a comment -

        From non non (nbhansen at midway.uchicago.edu) Wednesday, 15 June 2005, 03:33 AM:

        I spoke wrongly, the course changes are NOT saved. This means a course I made inaccessible before upgrade, I cannot make accessible again to the students.

        From Jon Papaioannou (pj at moodle.org) Wednesday, 15 June 2005, 04:40 AM:

        OK, here is what happened.

        One of the blocks you are using was not fully upgraded for 1.5. Specifically, the applicable_formats() method is not returning an array as per the latest specs (see the blocks HOWTO Appendix B for pointers on how it should be).

        This caused the warning you saw, which I did nothing to fix because with correct block code it should not happen, so I left it as an indicator. The side effect was that the block was deemed inappropriate for any course format, so after you saved the course settings Moodle thought that it should not be displayed anymore and tried to delete it.

        The deleting code hit a special case triggered by a combination of bad code (which I fixed) and the fact that this block seemed NOT to be registered with Moodle? I cannot get how this would happen, since if you deleted it from the Admin page it should have been automatically deleted from the course at that time.

        Anyway, the fatal error will not happen again. It's up to you to update the block and also fix the warning.

        From non non (nbhansen at midway.uchicago.edu) Wednesday, 15 June 2005, 06:15 AM:

        I deleted the offending block (possibly even before I got that message), but I'm still getting the error messages now.

        From Jon Papaioannou (pj at moodle.org) Wednesday, 15 June 2005, 07:54 AM:

        And this is with blocklib.php version 1.72.2.2?

        From non non (nbhansen at midway.uchicago.edu) Wednesday, 15 June 2005, 07:09 PM:

        No it's 1.7.2.1. Should I try replacing that file with 1.7.2.2?

        From non non (nbhansen at midway.uchicago.edu) Wednesday, 15 June 2005, 07:10 PM:

        Sorry I meant to say it is 1.72.2.1

        From Jon Papaioannou (pj at moodle.org) Wednesday, 15 June 2005, 10:29 PM:

        Of course. I guess that you didn't allow enough time for the change to propagate to public CVS and the download packages.

        From non non (nbhansen at midway.uchicago.edu) Thursday, 16 June 2005, 12:35 AM:

        OK, I upgraded to 1.74. I am now able to save my changes, but a message appears afterwards saying:

        Warning: Invalid argument supplied for foreach() in /home/mine/public_html/lib/blocklib.php on line 168

        From Jon Papaioannou (pj at moodle.org) Monday, 20 June 2005, 11:33 AM:

        There is probably something wrong with your applicable_formats() method. If you can't find out what (use the HOWTO), post it here.

        From non non (nbhansen at midway.uchicago.edu) Monday, 20 June 2005, 10:32 PM:

        Your last post makes no sense to me. I'm not a programmer. Can you put it in plain English?

        From Jon Papaioannou (pj at moodle.org) Monday, 20 June 2005, 10:53 PM:

        The block which is causing this warning has probably not been upgraded correctly for use with 1.5.

        Each block may override the default placement restrictions (which don't restrict anything, really) by defining an applicable_formats() method.

        You can find this piece of code (2-3 lines) in each block file by searching for function applicable_formats.

        One of your (custom?) blocks defines this method but returns an incorrect value, which causes blocklib to complain. Try to find which one it is and post it here.

        From Jon Papaioannou (pj at moodle.org) Wednesday, 6 July 2005, 08:26 AM:

        Reducing severity and priority. Is this still a problem?

        From non non (nbhansen at midway.uchicago.edu) Tuesday, 12 July 2005, 10:36 PM:

        I was still getting the error message, although it doesn't seem to have any negative consequences as far as I can tell.

        From Jon Papaioannou (pj at moodle.org) Saturday, 16 July 2005, 05:54 AM:

        Closing again, this remaining message has to do with one of the blocks in your installation not behaving correctly. The author should fix it.

        Show
        Martin Dougiamas added a comment - From non non (nbhansen at midway.uchicago.edu) Wednesday, 15 June 2005, 03:33 AM: I spoke wrongly, the course changes are NOT saved. This means a course I made inaccessible before upgrade, I cannot make accessible again to the students. From Jon Papaioannou (pj at moodle.org) Wednesday, 15 June 2005, 04:40 AM: OK, here is what happened. One of the blocks you are using was not fully upgraded for 1.5. Specifically, the applicable_formats() method is not returning an array as per the latest specs (see the blocks HOWTO Appendix B for pointers on how it should be). This caused the warning you saw, which I did nothing to fix because with correct block code it should not happen, so I left it as an indicator. The side effect was that the block was deemed inappropriate for any course format, so after you saved the course settings Moodle thought that it should not be displayed anymore and tried to delete it. The deleting code hit a special case triggered by a combination of bad code (which I fixed) and the fact that this block seemed NOT to be registered with Moodle? I cannot get how this would happen, since if you deleted it from the Admin page it should have been automatically deleted from the course at that time. Anyway, the fatal error will not happen again. It's up to you to update the block and also fix the warning. From non non (nbhansen at midway.uchicago.edu) Wednesday, 15 June 2005, 06:15 AM: I deleted the offending block (possibly even before I got that message), but I'm still getting the error messages now. From Jon Papaioannou (pj at moodle.org) Wednesday, 15 June 2005, 07:54 AM: And this is with blocklib.php version 1.72.2.2? From non non (nbhansen at midway.uchicago.edu) Wednesday, 15 June 2005, 07:09 PM: No it's 1.7.2.1. Should I try replacing that file with 1.7.2.2? From non non (nbhansen at midway.uchicago.edu) Wednesday, 15 June 2005, 07:10 PM: Sorry I meant to say it is 1.72.2.1 From Jon Papaioannou (pj at moodle.org) Wednesday, 15 June 2005, 10:29 PM: Of course. I guess that you didn't allow enough time for the change to propagate to public CVS and the download packages. From non non (nbhansen at midway.uchicago.edu) Thursday, 16 June 2005, 12:35 AM: OK, I upgraded to 1.74. I am now able to save my changes, but a message appears afterwards saying: Warning: Invalid argument supplied for foreach() in /home/mine/public_html/lib/blocklib.php on line 168 From Jon Papaioannou (pj at moodle.org) Monday, 20 June 2005, 11:33 AM: There is probably something wrong with your applicable_formats() method. If you can't find out what (use the HOWTO), post it here. From non non (nbhansen at midway.uchicago.edu) Monday, 20 June 2005, 10:32 PM: Your last post makes no sense to me. I'm not a programmer. Can you put it in plain English? From Jon Papaioannou (pj at moodle.org) Monday, 20 June 2005, 10:53 PM: The block which is causing this warning has probably not been upgraded correctly for use with 1.5. Each block may override the default placement restrictions (which don't restrict anything, really) by defining an applicable_formats() method. You can find this piece of code (2-3 lines) in each block file by searching for function applicable_formats. One of your (custom?) blocks defines this method but returns an incorrect value, which causes blocklib to complain. Try to find which one it is and post it here. From Jon Papaioannou (pj at moodle.org) Wednesday, 6 July 2005, 08:26 AM: Reducing severity and priority. Is this still a problem? From non non (nbhansen at midway.uchicago.edu) Tuesday, 12 July 2005, 10:36 PM: I was still getting the error message, although it doesn't seem to have any negative consequences as far as I can tell. From Jon Papaioannou (pj at moodle.org) Saturday, 16 July 2005, 05:54 AM: Closing again, this remaining message has to do with one of the blocks in your installation not behaving correctly. The author should fix it.
        Hide
        Michael Blake added a comment -

        Temporary transition to reassign bug to "pj".

        Show
        Michael Blake added a comment - Temporary transition to reassign bug to "pj".
        Hide
        Michael Blake added a comment -

        Re-closing bugs after re-assigning to "pj".

        Show
        Michael Blake added a comment - Re-closing bugs after re-assigning to "pj".

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: