Skip to content

[#529] Skip dependencies for disabled modules in ModuleLoader#530

Merged
armanist merged 4 commits into
softberg:masterfrom
armanist:issue/529-disabled-module-deps
May 27, 2026
Merged

[#529] Skip dependencies for disabled modules in ModuleLoader#530
armanist merged 4 commits into
softberg:masterfrom
armanist:issue/529-disabled-module-deps

Conversation

@armanist
Copy link
Copy Markdown
Member

@armanist armanist commented May 26, 2026

Fixes #529

Summary by CodeRabbit

  • Bug Fixes

    • Disabled modules now skip dependency registration, matching route loading behavior.
  • Tests

    • Improved test coverage for module dependency resolution when modules are disabled; added a test-only stub for disabled token handling.
  • Documentation

    • Changelog updated to include the fix for disabled-module dependency registration.
  • Chores

    • Adjusted Twig version constraint for compatibility.

Review Change Stack

@armanist armanist added the bug Something isn't working label May 26, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Warning

Review limit reached

@armanist, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 17 minutes and 17 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c6801bcc-26c0-44fa-90b3-b7d479d47961

📥 Commits

Reviewing files that changed from the base of the PR and between c357ca9 and 3bf88cc.

📒 Files selected for processing (3)
  • composer.json
  • src/Module/ModuleLoader.php
  • tests/Unit/Module/ModuleLoaderTest.php
📝 Walkthrough

Walkthrough

ModuleLoader now checks each module's enabled flag when loading dependencies and skips disabled modules. Tests add a DisabledTokenService fixture and assertions to verify disabled modules' dependencies are not registered. CHANGELOG and composer.json were updated.

Changes

Module Dependency Loading Fix

Layer / File(s) Summary
Core: Skip disabled modules during dependency loading
src/Module/ModuleLoader.php
loadModulesDependencies() now calls isModuleEnabled($options) inside its module iteration and skips loading/merging dependencies when enabled is false.
Test: Disabled module fixture and assertion
tests/_root/modules/Meme/Services/DisabledTokenService.php, tests/_root/modules/Meme/config/dependencies.php, tests/Unit/Module/ModuleLoaderTest.php
Adds DisabledTokenService and a Meme module dependency config that binds TokenServiceInterface to it; tests import the service and assert that TokenServiceInterface is not resolved to DisabledTokenService, confirming disabled modules' dependencies are skipped.
Documentation: Changelog update
CHANGELOG.md
Adds a "Fixed" entry noting ModuleLoader now avoids registering dependencies for modules with enabled: false.
Composer: twig version constraint change
composer.json
Changes twig/twig requirement from ^3.0 to >=3.0 <3.26.

Sequence Diagram

sequenceDiagram
  participant ModuleLoader
  participant ModuleConfig
  participant DependencyRegistry
  ModuleLoader->>ModuleConfig: iterate configured modules
  loop per module
    ModuleConfig-->>ModuleLoader: return module options (including enabled)
    alt enabled = false
      ModuleLoader->>ModuleLoader: continue (skip dependency loading)
    else enabled = true
      ModuleLoader->>DependencyRegistry: load & merge module dependencies
    end
  end
  ModuleLoader-->>DependencyRegistry: finalize merged dependencies
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • andrey-smaelov

Poem

🐰 A loader once missed the "enabled" cue,
Now peeks the flag before it binds anew.
Disabled modules dream in peaceful rest,
While enabled ones bring dependencies best.
Hoppity hops — tests confirm the quest.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The twig/twig version constraint change in composer.json (^3.0 to >=3.0 <3.26) appears unrelated to the module dependency loading fix and issue #529. Clarify whether the twig/twig version constraint change is necessary for this fix or belongs in a separate PR; if unrelated, revert the composer.json change.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[#529] Skip dependencies for disabled modules in ModuleLoader' directly and specifically describes the main change: skipping dependency registration for disabled modules.
Linked Issues check ✅ Passed The PR fulfills all coding requirements from issue #529: ModuleLoader now skips dependency registration for disabled modules [#529], includes test regression validation [#529], and preserves route-loading behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@armanist armanist added this to the 3.0.0 milestone May 26, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/Unit/Module/ModuleLoaderTest.php (1)

60-60: ⚡ Quick win

Tighten the Meme “disabled” assertion in ModuleLoaderTest

tests/_root/shared/config/modules.php sets 'Meme' => ['enabled' => false], and src/Module/ModuleLoader.php::loadModulesDependencies() skips disabled modules via isModuleEnabled(). ModuleLoaderTest::testLoadModulesDependencies() already guards this behavior indirectly by asserting TokenServiceInterface resolves to Quantum\Tests\_root\shared\Services\TokenService::class and is not DisabledTokenService::class.

Add an explicit assertion on the fixture config (e.g., getModuleConfigs()['Meme']['enabled'] === false) and/or require Meme’s config/dependencies.php exists, so the test can’t pass just because the Meme module/files are missing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/Unit/Module/ModuleLoaderTest.php` at line 60, Add an explicit check in
ModuleLoaderTest::testLoadModulesDependencies() to assert the fixture config
disables the Meme module and that its dependency file exists: verify
getModuleConfigs()['Meme']['enabled'] === false and assert the Meme module's
config/dependencies.php (or equivalent fixture path used by
ModuleLoader::loadModulesDependencies()/isModuleEnabled()) is present, so the
test fails if the Meme module/config is missing rather than silently skipped;
update assertions around TokenServiceInterface only after these explicit checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/Unit/Module/ModuleLoaderTest.php`:
- Line 60: Add an explicit check in
ModuleLoaderTest::testLoadModulesDependencies() to assert the fixture config
disables the Meme module and that its dependency file exists: verify
getModuleConfigs()['Meme']['enabled'] === false and assert the Meme module's
config/dependencies.php (or equivalent fixture path used by
ModuleLoader::loadModulesDependencies()/isModuleEnabled()) is present, so the
test fails if the Meme module/config is missing rather than silently skipped;
update assertions around TokenServiceInterface only after these explicit checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3a8f57a-1adf-45ac-9eaa-a6a8ce0ea2af

📥 Commits

Reviewing files that changed from the base of the PR and between e093e8b and 6c3eddb.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • src/Module/ModuleLoader.php
  • tests/Unit/Module/ModuleLoaderTest.php
  • tests/_root/modules/Meme/Services/DisabledTokenService.php
  • tests/_root/modules/Meme/config/dependencies.php

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@composer.json`:
- Line 40: composer.json currently pins "twig/twig" to ">=3.0 <3.26", but
upgrading to the security-patched 3.26+ requires PHP >=8.2; either update the
project's supported PHP versions in CI/config (bump matrix to PHP 8.2+) and
change the twig constraint to "^3.26" in composer.json, or keep PHP 7.4/8.0/8.1
support and change the twig constraint to the latest patched release that still
supports those PHP versions (identify and set the specific version instead of
^3.26); update composer.json accordingly and run composer update/test to verify
compatibility.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ca9d5afc-8f9b-4717-b93a-f21630d5f823

📥 Commits

Reviewing files that changed from the base of the PR and between 6c3eddb and c357ca9.

📒 Files selected for processing (1)
  • composer.json

Comment thread composer.json
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.88%. Comparing base (e093e8b) to head (3bf88cc).

Files with missing lines Patch % Lines
src/Module/ModuleLoader.php 90.90% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #530      +/-   ##
============================================
+ Coverage     90.86%   90.88%   +0.01%     
- Complexity     3078     3079       +1     
============================================
  Files           263      263              
  Lines          8115     8117       +2     
============================================
+ Hits           7374     7377       +3     
+ Misses          741      740       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@armanist armanist merged commit 121e789 into softberg:master May 27, 2026
7 checks passed
@armanist armanist deleted the issue/529-disabled-module-deps branch May 27, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[3.0.0] ModuleLoader registers dependencies from disabled modules

1 participant