Moodle
  1. Moodle
  2. MDL-34713

Undefined index in block blog menu

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.1, 2.3.5, 2.4.2
    • Fix Version/s: 2.3.6, 2.4.3
    • Component/s: Blocks, Blog
    • Labels:
    • Testing Instructions:
      Hide
      1. Go to a course and activate editing.
      2. Add a blog menu block.
      3. Configure the block to be displayed on all pages.
      4. Add a new activity to the course, for example an assignment.
      5. Add a blog menu block to the activity page.
      6. Configure the block to be displayed on just this page.
      7. Open the module and click "Add an entry about this [module name]" from the blog menu block.
      8. Create a new blog entry. After you have saved the blog entry it should be associated with the activity that you created in step 4.
      9. Click edit on your blog entry and save.
      10. Check that the blog entry is still associated with the same activity that you created in step 4 (not with the course).
      11. Repeat steps 4 to 8, choosing a different activity in step 4.
      Show
      Go to a course and activate editing. Add a blog menu block. Configure the block to be displayed on all pages. Add a new activity to the course, for example an assignment. Add a blog menu block to the activity page. Configure the block to be displayed on just this page. Open the module and click "Add an entry about this [module name] " from the blog menu block. Create a new blog entry. After you have saved the blog entry it should be associated with the activity that you created in step 4. Click edit on your blog entry and save. Check that the blog entry is still associated with the same activity that you created in step 4 (not with the course). Repeat steps 4 to 8, choosing a different activity in step 4.
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull 2.4 Branch:
      wip-MDL-34713-stable24
    • Pull Master Branch:
      wip-MDL-34713-master
    • Rank:
      43177

      Description

      I am not sure how to reproduce it, but I am pretty sure this follows the testing off MDL-34239.

      Notice: Undefined index: 5 in /home/fred/www/repositories/testing_master/moodle/blog/lib.php on line 604
      
      Call Stack:
          0.0002     655672   1. {main}() /home/fred/www/repositories/testing_master/moodle/mod/assign/view.php:0
          0.2669   51972224   2. assign->view() /home/fred/www/repositories/testing_master/moodle/mod/assign/view.php:53
          0.2669   51972960   3. assign->view_grading_page() /home/fred/www/repositories/testing_master/moodle/mod/assign/locallib.php:376
          0.2682   52191920   4. assign->view_grading_table() /home/fred/www/repositories/testing_master/moodle/mod/assign/locallib.php:1819
          0.2996   55078560   5. plugin_renderer_base->render() /home/fred/www/repositories/testing_master/moodle/mod/assign/locallib.php:1779
          0.2996   55078712   6. mod_assign_renderer->render_assign_header() /home/fred/www/repositories/testing_master/moodle/lib/outputrenderers.php:215
          0.3000   55099432   7. core_renderer->header() /home/fred/www/repositories/testing_master/moodle/mod/assign/renderer.php:205
          0.3055   55835208   8. core_renderer->render_page_layout() /home/fred/www/repositories/testing_master/moodle/lib/outputrenderers.php:710
          0.3057   55941680   9. include('/home/fred/www/repositories/testing_master/moodle/theme/base/layout/general.php') /home/fred/www/repositories/testing_master/moodle/lib/outputrenderers.php:763
          0.3359   57456456  10. block_manager->region_has_content() /home/fred/www/repositories/testing_master/moodle/theme/base/layout/general.php:6
          0.3360   57456456  11. block_manager->ensure_content_created() /home/fred/www/repositories/testing_master/moodle/lib/blocklib.php:352
          0.3360   57456768  12. block_manager->create_block_contents() /home/fred/www/repositories/testing_master/moodle/lib/blocklib.php:981
          0.8145   87189528  13. block_base->get_content_for_output() /home/fred/www/repositories/testing_master/moodle/lib/blocklib.php:929
          0.8145   87192232  14. block_base->formatted_contents() /home/fred/www/repositories/testing_master/moodle/blocks/moodleblock.class.php:232
          0.8145   87192232  15. block_blog_menu->get_content() /home/fred/www/repositories/testing_master/moodle/blocks/moodleblock.class.php:281
          0.8145   87192616  16. blog_get_all_options() /home/fred/www/repositories/testing_master/moodle/blocks/blog_menu/block_blog_menu.php:81
          0.8146   87193088  17. blog_get_options_for_module() /home/fred/www/repositories/testing_master/moodle/blog/lib.php:391
      
      
      Warning: Invalid argument supplied for foreach() in /home/fred/www/repositories/testing_master/moodle/blocks/blog_menu/block_blog_menu.php on line 90
      
      Call Stack:
          0.0002     655672   1. {main}() /home/fred/www/repositories/testing_master/moodle/mod/assign/view.php:0
          0.2669   51972224   2. assign->view() /home/fred/www/repositories/testing_master/moodle/mod/assign/view.php:53
          0.2669   51972960   3. assign->view_grading_page() /home/fred/www/repositories/testing_master/moodle/mod/assign/locallib.php:376
          0.2682   52191920   4. assign->view_grading_table() /home/fred/www/repositories/testing_master/moodle/mod/assign/locallib.php:1819
          0.2996   55078560   5. plugin_renderer_base->render() /home/fred/www/repositories/testing_master/moodle/mod/assign/locallib.php:1779
          0.2996   55078712   6. mod_assign_renderer->render_assign_header() /home/fred/www/repositories/testing_master/moodle/lib/outputrenderers.php:215
          0.3000   55099432   7. core_renderer->header() /home/fred/www/repositories/testing_master/moodle/mod/assign/renderer.php:205
          0.3055   55835208   8. core_renderer->render_page_layout() /home/fred/www/repositories/testing_master/moodle/lib/outputrenderers.php:710
          0.3057   55941680   9. include('/home/fred/www/repositories/testing_master/moodle/theme/base/layout/general.php') /home/fred/www/repositories/testing_master/moodle/lib/outputrenderers.php:763
          0.3359   57456456  10. block_manager->region_has_content() /home/fred/www/repositories/testing_master/moodle/theme/base/layout/general.php:6
          0.3360   57456456  11. block_manager->ensure_content_created() /home/fred/www/repositories/testing_master/moodle/lib/blocklib.php:352
          0.3360   57456768  12. block_manager->create_block_contents() /home/fred/www/repositories/testing_master/moodle/lib/blocklib.php:981
          0.8145   87189528  13. block_base->get_content_for_output() /home/fred/www/repositories/testing_master/moodle/lib/blocklib.php:929
          0.8145   87192232  14. block_base->formatted_contents() /home/fred/www/repositories/testing_master/moodle/blocks/moodleblock.class.php:232
          0.8145   87192232  15. block_blog_menu->get_content() /home/fred/www/repositories/testing_master/moodle/blocks/moodleblock.class.php:281
      

      Looks like this should fix it:

      diff --git a/blog/lib.php b/blog/lib.php
      index 764fc64..6e1469b 100644
      --- a/blog/lib.php
      +++ b/blog/lib.php
      @@ -601,7 +601,7 @@ function blog_get_options_for_module($module, $user=null) {
           }
           if (array_key_exists($key, $moduleoptions)) {
               // Serve from the cache so we don't have to regenerate
      -        return $moduleoptions[$module->id];
      +        return $moduleoptions[$key];
           }
       
           $modcontext = context_module::instance($module->id, IGNORE_MISSING);
      

        Issue Links

          Activity

          Hide
          Jason Fowler added a comment -

          Trying to reproduce this in master. Finding it a little difficult. Can you remember what you were doing Fred? I assume it had something to do with mod_assign ...

          Show
          Jason Fowler added a comment - Trying to reproduce this in master. Finding it a little difficult. Can you remember what you were doing Fred? I assume it had something to do with mod_assign ...
          Hide
          Jason Fowler added a comment -

          Even following the steps you mentioned from MDL-34239 I can't reproduce this error at all.

          Show
          Jason Fowler added a comment - Even following the steps you mentioned from MDL-34239 I can't reproduce this error at all.
          Hide
          Frédéric Massart added a comment -

          It appears that you need 2 Blog Menu blocks for the error to be displayed.

          Show
          Frédéric Massart added a comment - It appears that you need 2 Blog Menu blocks for the error to be displayed.
          Hide
          Jason Fowler added a comment -

          Will cherry pick once this passes peer review.

          Show
          Jason Fowler added a comment - Will cherry pick once this passes peer review.
          Hide
          Rajesh Taneja added a comment -

          Thanks Jason,

          Patch looks good to me.
          [y] Syntax
          [y] Output
          [y] Whitespace
          [-] Language
          [-] Databases
          [y] Testing
          [-] Security
          [-] Documentation
          [y] Git
          [y] Sanity check

          Show
          Rajesh Taneja added a comment - Thanks Jason, Patch looks good to me. [y] Syntax [y] Output [y] Whitespace [-] Language [-] Databases [y] Testing [-] Security [-] Documentation [y] Git [y] Sanity check
          Hide
          Rajesh Taneja added a comment -

          @Jason: You might want to give credit to Fred for his patch.

          Show
          Rajesh Taneja added a comment - @Jason: You might want to give credit to Fred for his patch.
          Hide
          Jason Fowler added a comment -

          Thanks Raj, cherry picked and pushed for integration.

          Show
          Jason Fowler added a comment - Thanks Raj, cherry picked and pushed for integration.
          Hide
          Damyon Wiese added a comment -

          Thanks Jason (and Fred!).

          The patch looks good and has been integrated to 23, 24 and master branches.

          Show
          Damyon Wiese added a comment - Thanks Jason (and Fred!). The patch looks good and has been integrated to 23, 24 and master branches.
          Hide
          Frédéric Massart added a comment -

          The test passes, however I don't understand what those testing instructions are. There is no check for the error that was reported, and the steps of creating blog entries are unrelated.

          I have test this:

          1. Add a blog menu block in a course page
          2. Set it to be displayed on Any page
          3. Go to an assignment
          4. Add another blog menu block
          5. Make sure
            • 2 blocks are displayed
            • No errors are shown
            • The content of the blocks are similar
          Show
          Frédéric Massart added a comment - The test passes, however I don't understand what those testing instructions are. There is no check for the error that was reported, and the steps of creating blog entries are unrelated. I have test this: Add a blog menu block in a course page Set it to be displayed on Any page Go to an assignment Add another blog menu block Make sure 2 blocks are displayed No errors are shown The content of the blocks are similar
          Hide
          Eloy Lafuente (stronk7) added a comment -

          This issue has been integrated upstream and is now available both via git and cvs (and in some hours, via mirrors and downloads).

          Thanks!

          PS: Yay, legacy template messages. Yes, you're ok, we don't have CVS anymore!

          Show
          Eloy Lafuente (stronk7) added a comment - This issue has been integrated upstream and is now available both via git and cvs (and in some hours, via mirrors and downloads). Thanks! PS: Yay, legacy template messages. Yes, you're ok, we don't have CVS anymore!

            People

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

              Dates

              • Created:
                Updated:
                Resolved: