pkp / browseBySection

This OJS 3 plugin adds support for browsing published articles by section.
GNU General Public License v2.0
2 stars 14 forks source link

BUG - if a section is deleted the frontend crashes #31

Open Nostrabramus opened 1 year ago

Nostrabramus commented 1 year ago

Context

I'm using OJS 3.3.0.10

Bug

Expected result

the primary navigation menu should be rendered without the nonexistent menu item and without crashing the rest of the page

Possible Fix

check if the section exists before returning a null element

I'm not sure if the problem belongs to the browseBySection extension rather than the default theme

ctgraham commented 1 year ago

Stack trace suggests this plugin as the likely culprit.

PHP Fatal error:  Uncaught Error: Call to a member function getData() on null in plugins/generic/browseBySection/BrowseBySectionPlugin.inc.php:267
Stack trace:
#0 lib/pkp/classes/plugins/HookRegistry.inc.php(107): BrowseBySectionPlugin->setMenuItemDisplayDetails()
#1 lib/pkp/classes/services/PKPNavigationMenuService.inc.php(362): HookRegistry::call()
#2 lib/pkp/classes/services/PKPNavigationMenuService.inc.php(438): PKP\\Services\\PKPNavigationMenuService->getDisplayStatus()
#3 lib/pkp/classes/services/PKPNavigationMenuService.inc.php(425): PKP\\Services\\PKPNavigationMenuService->loadMenuTreeDisplayState()
#4 lib/pkp/classes/template/PKPTemplateManager.inc.php(2062): PKP\\Services\\PKPNavigationMenuService->getMenuTree()
#5 plugins/generic/browseBySection/BrowseBySectionPlugin.inc.php on line 267
ctgraham commented 1 year ago

Mitigation could be here: https://github.com/pkp/browseBySection/blob/fcb80b608a25dd1b9243e616bf9c068002bbdc46/BrowseBySectionPlugin.inc.php#L267

With:

                        if (!$section) {
                                return false;
                        }

But perhaps the plugin should also hook the section delete to cleanup its data.