Uh oh!
There was an error while loading. Please reload this page.
fix: prevent activation fatal when installed without vendor/ - #2
Conversation
The bootstrap loaded the PSR-4 AssetDrips\ namespace only through Composer's vendor/autoload.php, guarded by is_readable(). A distributed zip that shipped without a vendor/ directory therefore loaded no classes, and activation fataled: Uncaught Error: Class "AssetDrips\Db\Schema" not found in assetdrips.php:48 The plugin has no third-party runtime dependencies, so the autoloader's only runtime job is mapping AssetDrips\ -> src/. Register a minimal built-in PSR-4 autoloader as a fallback when vendor/autoload.php is absent, making the plugin self-contained regardless of how it is packaged. FixesCodeDrips#1
WPCS flags $class as a reserved keyword used as a parameter name (PHPCS: assetdrips.php:40). Pure identifier rename, no behaviour change; phpcs is now clean for this file.
eulo
left a comment
There was a problem hiding this comment.
Verified the fallback autoloader resolves all 89 classes under src/ with zero misses — src/ is fully PSR-4 clean and the plugin has no third-party runtime dependencies, so mapping AssetDrips\ -> src/ is genuinely all the runtime autoloader needs to do.
Unit tests pass on PHP 8.1/8.2/8.3. I pushed one follow-up commit renaming the closure parameter $class -> $class_name (WPCS flags $class as a reserved keyword used as a parameter name); phpcs is now clean for assetdrips.php.
For the record on root cause: the published v1.0.0 release asset does ship vendor/ and extracts to assetdrips/. The path in #1 was assetdrips-1.0.0/, which is GitHub's auto-generated "Source code (zip)" — same filename, but no vendor/ since it's gitignored. This change makes picking the wrong archive harmless, which is the right defensive fix. Renaming the release asset so the two are distinguishable is worth a separate follow-up.
Thanks for the clear report and the fix.
Uh oh!
There was an error while loading. Please reload this page.
The bootstrap loaded the PSR-4 AssetDrips\ namespace only through Composer's vendor/autoload.php, guarded by is_readable(). A distributed zip that shipped without a vendor/ directory therefore loaded no classes, and activation fataled:
The plugin has no third-party runtime dependencies, so the autoloader's only runtime job is mapping AssetDrips\ -> src/. Register a minimal built-in PSR-4 autoloader as a fallback when vendor/autoload.php is absent, making the plugin self-contained regardless of how it is packaged.
Fixes#1
What does this PR do?
Related issue
Type of change
Checklist
composer testpasses locallycomposer lintis clean for the code I changedNotes for reviewers