install_blocktype_viewtypes_for_plugin() needs to check if block still exists

Bug #1971910 reported by Robert Lyon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Unassigned

Bug Description

If a blocktype is deleted then on upgrading to a newer version if we call install_blocktype_extras() for another block - it will cause errors / upgrade fail.

The install_blocktype_viewtypes_for_plugin() function should behave like the install_blocktype_categories_for_plugin() for calling the safe require()

To test:

1) Install a 21.10 site
2) Checkout main
3) Delete a blocktype plugin from codebase, eg rm -rf htdocs/blocktype/myfriends/
4) Run upgrade

Without patch - get errors:

[WAR] 47 (lib/mahara.php:1711) File htdocs/blocktype/myfriends/lib.php did not exist
Call stack (most recent first):
  * safe_require() at htdocs/lib/upgrade.php:1235
  * install_blocktype_viewtypes_for_plugin() at htdocs/lib/upgrade.php:1273
  * install_blocktype_extras() at htdocs/lib/db/upgrade.php:450
  * xmldb_core_upgrade() at htdocs/lib/upgrade.php:377
  * upgrade_core() at htdocs/lib/mahara.php:281
  * upgrade_mahara() at htdocs/admin/cli/upgrade.php:76

With patch should allow upgrade without errors

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/c/mahara/+/12721
Committed: https://git.mahara.org/mahara/mahara/commit/40acfd090364fd3cac998a2801addc6641de62ea
Submitter: "Robert Lyon <email address hidden>"
Branch: main

commit 40acfd090364fd3cac998a2801addc6641de62ea
Author: Robert Lyon <email address hidden>
Date: Fri May 6 13:36:00 2022 +1200

Bug 1971910: Check if blocktype still exsists before getting the viewtypes

So we don't throw error on upgrade when a plugin has been deleted

Change-Id: I2a31bdb6e9dbc73c4eac33169b22a298f151b09c
Signed-off-by: Robert Lyon <email address hidden>

Robert Lyon (robertl-9)
Changed in mahara:
milestone: none → 22.10.0
importance: Undecided → Medium
status: New → Fix Committed
Doris Tam (doristam)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.