Repository navigation
fix: harden console inspection, bundles.php loading and network-only activation - #39
Merged
Merged
Conversation
A cold boot required config/bundles.php twice: once in bundle discovery and once for the known environments in the kernel configuration. A bundles.php that declares a function or class failed with "Cannot redeclare". KernelConfigurationResolver now loads the file once and the kernel hands the result to BundleDiscovery through a new optional trailing constructor argument. Direct BundleDiscovery callers still get the file required for them.
On multisite, activate_plugin() activates a "Network: true" plugin network-wide without a capability check. Core's plugins.php refuses that outside the network admin (is_network_only_plugin()), but the package page only checked activate_plugins, so a site admin with the plugins menu enabled could activate such a SymPress package for the whole network. canRun() now mirrors core: it also requires the activate_plugin meta capability for the entry and rejects network-only plugins outside the network admin, which also hides the button.
App::boot() configures the builder only on a cache miss. After a warm hit the builder is the bootstrap stub, so container:dump and debug:container --parameters/--tag/--types/--env-vars showed almost nothing, and lint:container reported "valid" without compiling because a runtime container is always set after boot. The commands now use ConfiguredBuilder, which returns the live builder when it is configured and otherwise configures a fresh builder on a clone of the container, leaving the live one untouched. lint:container always compiles that builder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
From the Fable re-audit (2026-11-22) of
sympress/kernelv1.1.17:Container::builder()is only the bootstrap stub.container:dumpanddebug:container --parameters/--tag/--types/--env-varsshowed almost nothing, andlint:containeralways reported "valid" because a runtime container is always set after boot.config/bundles.phptwice, in discovery and inknownEnvironments(). Abundles.phpthat declares a function or class failed with "Cannot redeclare".activate_plugin()then activates it network-wide. Core'splugins.phpblocks this throughis_network_only_plugin().Fix
Console\ConfiguredBuilder: it returns the live builder when that builder is already configured. Otherwise it configures a fresh builder on a clone of the container viaKernelInterface::configureContainer(), so the live container is untouched. All three commands use it, andlint:containeralways compiles.KernelConfigurationResolver::bundlesConfiguration()requires the file once per resolver. The kernel passes the result toBundleDiscoverythrough a new optional trailing constructor argument (BC: direct callers still get the file required for them).PackageManagerActions::canRun('activate')also requirescurrent_user_can('activate_plugin', $entry), and it rejects network-only plugins outside the network admin. That also hides the button.Tests
Each test fails on
mainand passes on this branch:tests/Console/WarmCacheInspectionTest.php: after a warm hit,--parameterslistskernel.project_dir,--typesdescribesservices_resetter, the yaml dump contains the console services, lint passes, and the live builder stays unconfigured. Lint with a runtime container plus a broken definition now returns 1. Each assertion fails onmainon its own.ConfigPrecedenceTest::testColdBootRequiresBundlesConfigurationOnce:mainloads the file 2 times, this branch loads it once.PackageManagerPageTest::testSiteAdminCannotActivateNetworkOnlyPlugin: onmain, a site admin is allowed to activate a network-only plugin.composer qapasses: CS clean, PHPStan max clean, 114 tests, 1 FPM-only skip.composer validate --strictis valid.Release
Patch 1.1.18.
chore(release): prepare kernel v1.1.18adds the CHANGELOG entry. It covers this PR, #38 (cache fixes, merge first) and the unreleased CI commit4ef88cf. No other version files exist.