Koha-clms/t/db_dependent/Koha
Martin Renvoize 6a4a92f08d
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>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit ed0a3ebd82)
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
2026-09-11 12:45:27 +00:00
..
Account Bug 29923: Prevent overpayment credit when written-off accruing fine is adjusted on check-in 2026-04-13 14:04:54 +01:00
Acquisition Bug 41076: [25.11.x] Adjust perl tidiness for v20250105 2026-03-16 13:23:08 +00:00
Auth Bug 33782: (QA follow-up) Fix qa issues 2026-03-23 12:05:03 +00:00
BackgroundJob Bug 40846: Improve handling of ignored records 2026-02-16 14:43:00 +00:00
BackgroundJobs Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Biblio Bug 41031: Fix the subtest check_fixed_length in MARC21.t 2025-12-01 12:53:43 -07:00
Cash Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Charges Bug 41076: [25.11.x] Adjust perl tidiness for v20250105 2026-03-16 13:23:08 +00:00
Checkouts Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
CirculationRules Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Club Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Config Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Database Bug 42103: (follow-up) Fix failing test 2026-05-24 13:42:25 +01:00
ERM Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Edifact Bug 42010: Escape EDIFACT special characters in BGM purchase order number 2026-05-24 13:42:13 +01:00
File Bug 38489: Add rename_file method to transport system and Local transport class 2025-10-14 14:51:47 -06:00
Filter Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ILL Bug 41076: [25.11.x] Adjust perl tidiness for v20250105 2026-03-16 13:23:08 +00:00
Import Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Item Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Items Bug 41884: Adjust tests 2026-05-24 13:42:17 +01:00
Library Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Notice Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
OAI/Server Bug 37713: (QA follow-up) Add unit tests 2026-05-24 13:42:20 +01:00
Object Bug 32370: (QA follow-up) Add https to license url, use Test::NoWarnings 2026-02-16 15:20:24 +00:00
Objects Bug 35451: Fix test data 2025-11-07 10:54:06 -07:00
Old Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Patron Bug 41818: Add unit tests 2026-04-13 08:45:24 +01:00
Patrons Bug 41145: Add unit test coverage for stopping duplicated borrowerslog logging due to extended patron attributes being deleted on import 2026-01-16 12:59:57 +00:00
Plugins Bug 42430: (QA follow-up) Fix nested plugin package corruption on reload 2026-09-11 12:45:27 +00:00
Policy Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Preservation Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
REST Bug 42430: (QA follow-up) Fix nested plugin package corruption on reload 2026-09-11 12:45:27 +00:00
SIP2 Bug 42664: Reload SIP2 configuration in every worker process 2026-09-11 12:22:48 +00:00
SMTP Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
SearchEngine Bug 42485: (QA follow-up) Add explicit JSON::PP import and test coverage 2026-07-29 16:00:51 +00:00
Subscription Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Tags Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Template/Plugin Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
Ticket Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
UI/Form/Builder Bug 41076: [25.11.x] Adjust perl tidiness for v20250105 2026-03-16 13:23:08 +00:00
XSLT Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Z3950Responder Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
Account.t Bug 41076: [25.11.x] Adjust perl tidiness for v20250105 2026-03-16 13:23:08 +00:00
ActionLogs.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
AdditionalContents.t Bug 42866: Prevent SQL injection in Koha::AddtionalContents->search_for_display 2026-07-30 08:22:25 +00:00
AdditionalField.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
ApiKey.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ArticleRequest.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ArticleRequests.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Authorities.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Authority.t Bug 41843: Gracefully handle XML errors during authority deletion 2026-05-24 13:42:17 +01:00
BackgroundJob.t Bug 40943: Fix Koha/BackgroundJob.t 2025-11-04 07:15:11 -07:00
BackgroundJobs.t Bug 42394: (QA follow-up) Clean up test 2026-05-24 13:42:19 +01:00
Biblio.t Bug 42159: Unit tests 2026-09-11 12:16:09 +00:00
BiblioFrameworks.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Biblios.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Booking.t Bug 41887: Skip clash detection on terminal status transition 2026-04-13 09:21:08 +01:00
Bookings.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Calendar.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Checkout.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Checkouts.t Bug 41076: [25.11.x] Adjust perl tidiness for v20250105 2026-03-16 13:23:08 +00:00
CirculationRules.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Cities.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ClassSortRules.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ClassSources.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ClassSplitRules.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Course.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Courses.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
CoverImages.t Bug 33857: Avoid increasing file size while uploading image 2026-05-24 13:42:12 +01:00
CsvProfiles.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
CurbsidePickups.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Database.t Bug 38384: Refactor plugin loading to use lightweight Koha::Plugins::Loader 2026-04-10 14:18:48 +01:00
Desks.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
EDI.t Bug 20253: (follow-up) Fix undefined variable $b and test plan count 2025-11-03 14:13:40 -07:00
Encryption.t Bug 40444: Add a test to ensure all Perl test files use Test::NoWarnings 2025-07-28 16:26:36 -06:00
Hold.t Bug 42578: Prevent Koha/Hold.t to fail on date comparison 2026-05-24 13:42:52 +01:00
Holds.t Bug 23269: (RM follow-up): Tidy 2026-05-24 13:42:11 +01:00
ImportBatch.t Bug 41036: (QA follow-up) use nowarnings 2026-04-13 08:46:34 +01:00
Installer.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Item.t Bug 41510: (RM follow-up) Perltidy a missed file at merge time 2026-05-24 13:42:10 +01:00
ItemTypes.t Bug 39745: Fix wrong system preference 'language' in test suite (mock_preference) 2026-03-14 12:21:04 +00:00
Items.t Bug 41298: Fix filtering items by in transit 2025-12-01 08:34:04 -07:00
KeyboardShortcuts.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Libraries.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Library.t Bug 39482: (follow-up) Adjust tests 2026-01-16 17:00:12 +00:00
MarcOrder.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
MarcSubfieldStructures.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Notice_Util.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Notices.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
OAIHarvester.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
OAIServers.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Object.t Bug 35380: Unit tests 2026-05-24 13:42:13 +01:00
Objects.t Bug 41076: [25.11.x] Adjust perl tidiness for v20250105 2026-03-16 13:23:08 +00:00
Old.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Patron.t Bug 41954: Update existing tests 2026-05-24 13:42:19 +01:00
Patron_generate_userid.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Patrons.t Bug 39748: (follow-up) Update number of tests 2026-05-24 13:42:20 +01:00
Pseudonymization.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
PseudonymizedTransaction.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Quotes.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Ratings.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Recall.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Recalls.t Bug 39985: Set items.onloan when recall adjusts checkout due date 2025-12-01 08:34:05 -07:00
RecordSource.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Reports.t Bug 39164: Add max_statement_time to SQL report queries 2026-05-24 13:42:19 +01:00
Reviews.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
SMS_Providers.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
SearchField.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
SearchFilters.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Session.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
SharedContent.t Bug 39745: Fix wrong system preference 'language' in test suite (mock_preference) 2026-03-14 12:21:04 +00:00
Statistic.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Statistics.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Subscription.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Suggestion.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Suggestions.t Bug 42030: Populate diff column for suggestion CREATE/MODIFY/DELETE logs 2026-05-24 13:42:23 +01:00
Tags.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Ticket.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Virtualshelf.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Virtualshelves.t Bug 39145: (follow-up) Tidy files 2025-09-29 14:02:26 -06:00
Z3950Servers.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00