Skip to content

fix: prevent activation fatal when installed without vendor/ - #2

Merged
eulo merged 2 commits into
CodeDrips:mainfrom
mboss97:fix/missing-autoloader-fatal
Aug 19, 2026
Merged

eulo merged 2 commits into
CodeDrips:mainfrom
mboss97:fix/missing-autoloader-fatal

Conversation

@mboss97

@mboss97 mboss97 commented Jul 16, 2026

Copy link
Copy Markdown
Member

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.

Fixes #1

What does this PR do?

Related issue

Type of change

  • Bug fix
  • New feature
  • Refactor / internal
  • Documentation
  • Other:

Checklist

  • composer test passes locally
  • composer lint is clean for the code I changed
  • I added/updated tests (a bug fix includes a test that fails before the fix)
  • Any file-modifying/removing behaviour is reversible (quarantine or verified backup)
  • I updated docs / CHANGELOG where relevant

Notes for reviewers

mboss97 and others added 2 commits July 16, 2026 14:34
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.

Fixes CodeDrips#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 eulo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@eulo
eulo merged commit b4746c1 into CodeDrips:main Aug 19, 2026
3 of 4 checks passed
@mboss97 mboss97 mentioned this pull request Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fatal error upon install

2 participants