Skip to content

fix: store SPL closures in register() so unregister() can remove them#10097

Merged
michalsn merged 1 commit intocodeigniter4:developfrom
michalsn:fix/autoload-unregister
Apr 9, 2026
Merged

fix: store SPL closures in register() so unregister() can remove them#10097
michalsn merged 1 commit intocodeigniter4:developfrom
michalsn:fix/autoload-unregister

Conversation

@michalsn
Copy link
Copy Markdown
Member

@michalsn michalsn commented Apr 9, 2026

Description
Fixed a bug where Autoloader::unregister() could fail to remove handlers from the SPL autoload stack during tests. First-class callable syntax ($this->loadClass(...)) creates a new Closure object on each call, so the callbacks passed to spl_autoload_unregister() did not match the ones originally registered with spl_autoload_register(). As a result, autoload handlers accumulated on the SPL stack instead of being removed.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@michalsn michalsn added the bug Verified issues on the current code behavior or pull requests that will fix them label Apr 9, 2026
@michalsn michalsn merged commit 2aaf6b6 into codeigniter4:develop Apr 9, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants