Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.11.5
-
None
-
3.11.0.4
-
MOODLE_311_STABLE
-
MOODLE_311_STABLE, MOODLE_400_STABLE
Description
DESCRIPTION
If a new course is created using the Collapsed Topics course format, the following error is received upon creation if "Blocks to display" is empty.
Coding error detected, it must be fixed by a programmer: Block type has been disabled by the administrator.
|
|
Debug info:
|
Error code: codingerror
|
×Stack trace:
|
line 1019 of /lib/blocklib.php: coding_exception thrown
|
line 802 of /lib/blocklib.php: call to block_manager->check_known_block_type()
|
line 896 of /lib/blocklib.php: call to block_manager->add_block()
|
line 2576 of /lib/blocklib.php: call to block_manager->add_blocks()
|
line 2433 of /course/lib.php: call to blocks_add_default_course_blocks()
|
line 165 of /course/edit.php: call to create_course()
|
I am not a developer, so I'll apologize in advance if this assessment is off target, but I think the problem is in the get_default_blocks function. The function retrieves the value of the defaultdisplayblocks config and then runs the PHP explode function on the value. When there are no blocks selected in the config, the value of the config is empty string. Calling the explode function on empty string produces an array with one key containing empty string. This array is then passed onto the blocks_add_default_course_blocks function in /lib/blocklib.php which in turn calls add_blocks passing the empty string as the name of the block to add. To avoid the error, I think the get_default_blocks function needs to pass an empty array when the value of defaultdisplayblocks is empty string.
STEPS TO REPLICATE
- Go to Site administration > Plugins > Manage Blocks.
- Hide the following blocks:
Latest announcements (new_items)
Recent activity (recent_activity)
Search forums (search_forums)
Upcoming events (calendar_upcoming) - Go to Site administration > Plugins > Course formats > Collapsed Topics.
- Ensure that no values are selected in "Blocks to display".
- Go to Site administration > Courses > Add a new course.
- Enter a full name and short name for the course. Under Course format set the format to Collapsed Topics.
- Click Save and Return or Save and Display.
OBSERVED BEHAVIOR:
The course is created but an error is received stating, "Coding error detected, it must be fixed by a programmer: Block type has been disabled by the administrator."
EXPECTED BEHAVIOR:
The course is created without an error.
REPLICATION LOCATION
This issue was replicated on a site built on Moodle 3.11.3 using version 3.11.0.4 of the Collapsed Topics plugin. I have not tested version 3.11.0.5, but the function in question has not been updated between these versions.