https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42430 --- Comment #12 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 201416 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201416&action=edit Bug 42430: (QA follow-up) Fix nested plugin package corruption on reload InstallPlugins forces every discovered plugin class to be deleted and re-required from disk on every call, so plugin_methods reflects the .pm file as it currently exists rather than whatever was already loaded into a long-lived Plack worker. That deletion used Symbol::delete_package, which clears the target package's whole symbol table -- including any already-loaded packages nested under it (e.g. a REST API controller a plugin bundles alongside itself, such as Koha/Plugin/Foo/Controller.pm). Those nested classes keep their own %INC entry, so they are never re-required afterwards and are left permanently blanked out for the rest of the worker's life. This was caught when running `prove -r t/db_dependent/Koha/Plugins/ t/db_dependent/Koha/REST/Plugin/` on top of the original patch. Tests fail several files that have nothing to do with the bug being fixed (Biblio_and_Items_plugin_hooks.t, Holds_hooks.t, TemplateIncludePathHook.t, REST/Plugin/PluginRoutes.t), because Koha::Plugin::Test::Controller (a bundled test-fixture controller living in t/lib/plugins/Koha/Plugin/Test/Controller.pm) gets its symbol table wiped as collateral damage every time Koha::Plugin::Test is reloaded. _forget_plugin_class() replaces the delete_package call with the same technique used by the CPAN module Class::Unload (not added as a dependency here, just the technique): only clear the target class's own symbols and reset its @ISA, explicitly leaving any nested package entries in its symbol table alone. Module::Pluggable discovers bundled nested classes as their own entries in the plugin list regardless, so they still get reloaded correctly on their own turn. I also annotate the no strict 'refs' block added by the previous commit with a '## no critic' justification, as flagged by koha-qa.pl. Test plan: 1. Confirm the bug exists without this patch: a) git checkout <previous commit> (drop this commit, keeping the first 3 commits of the bug applied) b) Inside KTD: prove -r t/db_dependent/Koha/Plugins/ t/db_dependent/Koha/REST/Plugin/ c) Observe failing files unrelated to this bug's own tests: Biblio_and_Items_plugin_hooks.t, Holds_hooks.t, TemplateIncludePathHook.t and REST/Plugin/PluginRoutes.t. 2. Confirm the fix: a) Re-apply this commit b) Re-run the same command from 1(b) -- all tests now pass 3. Confirm the original bug this branch set out to fix is still fixed, both via the manual UI steps from the first commit's test plan (install Batch Permission Modifier Plugin 1.3.1, upload 1.4.1 over it via Tools > Plugins, confirm the renamed method takes effect without restarting Plack) and via: prove t/db_dependent/Koha/Plugins/Plugins.t (see the 'InstallPlugins() reloads stale symbol tables tests' subtest) 4. Confirm QA tooling is clean: koha-qa.pl -c 4 => PASS for Koha/Plugins.pm and all touched test files, no critic or tidiness failures. Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.