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

Course Category Block Producing Notices and Warnings

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.5
    • Fix Version/s: None
    • Component/s: Course, Libraries
    • Labels:
      None
    • Affected Branches:
      MOODLE_25_STABLE

      Description

      Without being logged in the Course Categories block lists all the categories in the site. If a category does not have any subcategories a php notice and warning is generated. This is with debugging turned on.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            brummie1 Matthew Cannings added a comment - - edited

            Getting the following notice/warning when debugging is turned on. These will not appear if debugging off/normal.

            Notice: Undefined property: stdClass::$categories in /srv/www/htdocs/student/course/lib.php on line 1496

            Warning: Invalid argument supplied for foreach() in /srv/www/htdocs/student/course/lib.php on line 1496

            adding an isset check to the function get_category_courses_array_recursively removes the errors

             
            function get_category_courses_array_recursively(array &$flattened, $category) {
                $flattened[$category->id] = $category->courses;
            	if (isset($category->categories)){
            		foreach ($category->categories as $childcategory) {
            			get_category_courses_array_recursively($flattened, $childcategory);
            		}
            	}
            }
            

            Show
            brummie1 Matthew Cannings added a comment - - edited Getting the following notice/warning when debugging is turned on. These will not appear if debugging off/normal. Notice: Undefined property: stdClass::$categories in /srv/www/htdocs/student/course/lib.php on line 1496 Warning: Invalid argument supplied for foreach() in /srv/www/htdocs/student/course/lib.php on line 1496 adding an isset check to the function get_category_courses_array_recursively removes the errors function get_category_courses_array_recursively(array &$flattened, $category) { $flattened[$category->id] = $category->courses; if (isset($category->categories)){ foreach ($category->categories as $childcategory) { get_category_courses_array_recursively($flattened, $childcategory); } } }
            Hide
            poltawski Dan Poltawski added a comment -

            Hi Matthew,

            Thanks for the report - which block do you mean by the Course category block? Is it in core?

            thanks,

            Dan

            Show
            poltawski Dan Poltawski added a comment - Hi Matthew, Thanks for the report - which block do you mean by the Course category block? Is it in core? thanks, Dan
            Hide
            brummie1 Matthew Cannings added a comment -

            Hi Dan,
            This is a little embarrassing as I can not say for certain. It is the "block" that appears on the from page when you select List Of Categories from Front Page Settings -> Frontpage. I do not think it is actually a real block.

            I have attached a screenshot that shows the settings

            Show
            brummie1 Matthew Cannings added a comment - Hi Dan, This is a little embarrassing as I can not say for certain. It is the "block" that appears on the from page when you select List Of Categories from Front Page Settings -> Frontpage. I do not think it is actually a real block. I have attached a screenshot that shows the settings
            Hide
            brummie1 Matthew Cannings added a comment -

            Screen shot of settings that trigger "block" on the first page

            Show
            brummie1 Matthew Cannings added a comment - Screen shot of settings that trigger "block" on the first page
            Hide
            poltawski Dan Poltawski added a comment -

            Ahha, I understand now thanks!

            Show
            poltawski Dan Poltawski added a comment - Ahha, I understand now thanks!
            Hide
            poltawski Dan Poltawski added a comment -

            Hi Matthew,

            I can't actually reproduce this, are you able to update to the latest master and see if its still an issue?

            Show
            poltawski Dan Poltawski added a comment - Hi Matthew, I can't actually reproduce this, are you able to update to the latest master and see if its still an issue?

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: