Fix fatal error when activating plugin without composer dependencies #7
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
When activating the Redis Queue plugin without running
composer install, WordPress crashed with a fatal error:This occurs because:
composer.jsonvendor/directory is gitignoredRedis_Queueclass before checking if the autoloader was availableThis affects users who clone the repository directly or install without proper dependency setup.
Solution
Added defensive checks to gracefully handle missing composer dependencies:
1. Class existence check before instantiation
2. Helpful admin notice
When dependencies are missing, users with
activate_pluginscapability now see a clear error message:3. Updated helper functions
All helper functions now handle null instances gracefully:
redis_queue()returnsnullif class doesn't existredis_queue_enqueue_job()returnsfalseif instance is nullredis_queue_process_jobs()returnsfalseif instance is nullBenefits
✅ No fatal errors during plugin activation
✅ Clear, actionable error message for users
✅ Proper WordPress security (capability checks, escaping)
✅ Graceful degradation of functionality
✅ Minimal changes (22 additions, 4 deletions)
Installation Note
Users should either:
vendor/)composer installafter cloning the repositoryThe GitHub Actions workflow already runs
composer install --no-devduring release builds, so official releases are unaffected.Fixes the issue reported in the problem statement where plugin activation failed with "Class not found" error.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/a2db6871deec989a74e1f90fafc6d58ae526a879/usr/bin/php8.3 -n -c /tmp/9cKW49 /usr/bin/composer install(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Created from VS Code via the GitHub Pull Request extension.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.