Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 13, 2025

Problem

When activating the Redis Queue plugin without running composer install, WordPress crashed with a fatal error:

Fatal error: Uncaught Error: Class "Soderlind\RedisQueue\Core\Redis_Queue" not found
in redis-queue.php on line 58

This occurs because:

  • The plugin uses PSR-4 autoloading configured in composer.json
  • The vendor/ directory is gitignored
  • The code unconditionally tried to instantiate the Redis_Queue class before checking if the autoloader was available

This 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

if ( class_exists( 'Soderlind\RedisQueue\Core\Redis_Queue' ) ) {
    Soderlind\RedisQueue\Core\Redis_Queue::get_instance();
} else {
    // Show helpful admin notice
}

2. Helpful admin notice

When dependencies are missing, users with activate_plugins capability now see a clear error message:

Redis Queue: Plugin dependencies are missing. Please run "composer install" in the plugin directory, or download the plugin from the official release.

3. Updated helper functions

All helper functions now handle null instances gracefully:

  • redis_queue() returns null if class doesn't exist
  • redis_queue_enqueue_job() returns false if instance is null
  • redis_queue_process_jobs() returns false if instance is null

Benefits

✅ 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:

  1. Download from GitHub Releases (includes vendor/)
  2. Run composer install after cloning the repository

The GitHub Actions workflow already runs composer install --no-dev during 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
    • Triggering command: /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

Uncaught Error: Class "Soderlind\RedisQueue\Core\Redis_Queue" not found
in /Users/persoderlind/Sites/plugins/app/public/wp-content/plugins/redis-queue/redis-queue.php on line 58

Call stack:

include_once()
wp-admin/includes/plugin.php:2387
plugin_sandbox_scrape('redis-queue/redis-queue.php')
wp-admin/includes/plugin.php:673
activate_plugin('redis-queue/redis-queue.php', 'http://plugins.local...ue%2Fredis-queue.php', false)
wp-admin/plugins.php:60

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.

@soderlind soderlind marked this pull request as ready for review October 13, 2025 20:10
…ependencies

Co-authored-by: soderlind <1649452+soderlind@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix uncaught error for missing Redis_Queue class Fix fatal error when activating plugin without composer dependencies Oct 13, 2025
Copilot AI requested a review from soderlind October 13, 2025 20:21
@soderlind soderlind merged commit 7a90501 into main Oct 13, 2025
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.

2 participants