Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-34713

Undefined index in block blog menu

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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 Master Branch:
      wip-MDL-34713-master

      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);

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    18/Mar/13