Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and adheres to Semantic Versioning.


## [1.2.0] - 2025-10-10
### Removed
- Dropped all legacy global class aliases (previous `class_alias` guards) now that backward compatibility is not required.
- Removed deprecated `includes/` directory and emptied legacy interface stubs.
- Removed legacy job_type inference variants (e.g. email_job, Email_Job, image_processing_job, api_sync_job); only canonical keys `email`, `image_processing`, `api_sync` are accepted now.
- Removed bootstrap fallback to legacy global `Sync_Worker` (namespaced worker is now required).
- Deleted development-only `debug.php` script (replaced by internal diagnostics via `Redis_Queue_Manager::diagnostic()`).
### Changed
- Codebase now exclusively uses namespaced classes; no global fallbacks remain.
- Documentation updated to remove legacy references (includes/ directory, global class name variants) and reflect canonical job type usage only.

## [1.0.2] - 2025-10-10
### Added
- GitHub updater integration and release workflows (`.github/workflows/*`, `includes/class-github-plugin-updater.php`).
- GitHub updater integration and release workflows (`.github/workflows/*`, `class-github-plugin-updater.php`).
- Funding configuration (`.github/FUNDING.yml`).
- Expanded root README with direct links to documentation set.
- Composer metadata: enriched description & keywords.
Expand Down
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,61 @@ Made with ❤️ by [Per Søderlind](https://soderlind.com)

---

For detailed usage, advanced features, troubleshooting, and performance tuning visit the [Usage guide](docs/usage.md). Additional topics: [Scaling](docs/scaling.md), [Maintenance](docs/maintenance.md).
For detailed usage, advanced features, troubleshooting, and performance tuning visit the [Usage guide](docs/usage.md). Additional topics: [Scaling](docs/scaling.md), [Maintenance](docs/maintenance.md).

## Namespacing & Backward Compatibility (Refactor Notes)

As of the latest refactor, all core classes have been migrated to the `Soderlind\\RedisQueueDemo` namespace and autoloaded via Composer PSR-4. Legacy global class names (`Redis_Queue_Demo`, `Redis_Queue_Manager`, `Job_Processor`, `Sync_Worker`, `REST_Controller`, `Admin_Interface`, job classes, etc.) are still available through `class_alias` so existing integrations that referenced the old globals continue to work without modification.

Removed legacy duplicate files:
```
admin/class-admin-interface.php
api/class-rest-controller.php
workers/class-sync-worker.php
```
Their logic now lives in:
```
src/Admin/Admin_Interface.php
src/API/REST_Controller.php
src/Workers/Sync_Worker.php
```

Helper functions (`redis_queue_demo()`, `redis_queue_enqueue_job()`, `redis_queue_process_jobs()`) remain unchanged for ergonomics.

If you previously required or included specific legacy files manually, you should remove those `require` statements—Composer autoload now handles class loading.

### Migrating Custom Integrations

If you instantiated legacy classes directly, both of the following are now equivalent:
```php
$manager = new Redis_Queue_Manager(); // legacy global (still works)
$manager = new \Soderlind\RedisQueueDemo\Core\Redis_Queue_Manager(); // namespaced
```

Custom job classes should adopt the namespace pattern and be placed under `src/YourNamespace/` with an appropriate `composer.json` autoload mapping, or hooked via the `redis_queue_demo_create_job` filter returning a namespaced job instance.

### Why This Change?

1. Autoload performance & structure clarity.
2. Avoiding global symbol collisions.
3. Easier extension via modern PHP tooling.
4. Future unit test isolation.

If you encounter any missing class errors after upgrading, clear WordPress object/opcode caches and run:
```bash
composer dump-autoload -o
```

Please report any backward compatibility regressions in the issue tracker.

### Admin Interface Inlining (UI Unchanged)

The legacy `admin/class-admin-interface.php` file was fully inlined into the namespaced `src/Admin/Admin_Interface.php` to remove manual `require` calls. To preserve the exact markup/CSS hooks, the original page layouts were ported as partial templates under:
```
src/Admin/partials/
dashboard-inline.php
jobs-inline.php
test-inline.php
settings-inline.php
```
These are loaded internally by the namespaced class; you should not include them directly. If you previously overrode or filtered admin output, existing selectors and element structures remain stable.
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,20 @@
/**
* Generic WordPress Plugin GitHub Updater
*
* A reusable class for handling WordPress plugin updates from GitHub repositories
* using the plugin-update-checker library.
* Moved from includes/ to plugin root in version 1.0.0.
*
* @package Soderlind\WordPress
* @version 1.0.0
* @author Per Soderlind
* @license GPL-2.0+
*/
class GitHub_Plugin_Updater {
/**
* @var string GitHub repository URL
*/
private $github_url;

/**
* @var string Branch to check for updates
*/
private $branch;

/**
* @var string Regex pattern to match the plugin zip file name
*/
private $name_regex;

/**
* @var string The plugin slug
*/
private $plugin_slug;

/**
* @var string The main plugin file path
*/
private $plugin_file;

/**
* @var bool Whether to enable release assets
*/
private $enable_release_assets;

/**
* Constructor
*
* @param array $config Configuration array with the following keys:
* - github_url: GitHub repository URL (required)
* - plugin_file: Main plugin file path (required)
* - plugin_slug: Plugin slug for updates (required)
* - branch: Branch to check for updates (default: 'main')
* - name_regex: Regex pattern for zip file name (optional)
* - enable_release_assets: Whether to enable release assets (default: true if name_regex provided)
*/
public function __construct( $config = array() ) {
// Validate required parameters
$required = array( 'github_url', 'plugin_file', 'plugin_slug' );
foreach ( $required as $key ) {
if ( empty( $config[ $key ] ) ) {
Expand All @@ -74,13 +36,9 @@ public function __construct( $config = array() ) {
? $config[ 'enable_release_assets' ]
: ! empty( $this->name_regex );

// Initialize the updater
add_action( 'init', array( $this, 'setup_updater' ) );
}

/**
* Set up the update checker using GitHub integration
*/
public function setup_updater() {
try {
$update_checker = PucFactory::buildUpdateChecker(
Expand All @@ -91,29 +49,16 @@ public function setup_updater() {

$update_checker->setBranch( $this->branch );

// Enable release assets if configured
if ( $this->enable_release_assets && ! empty( $this->name_regex ) ) {
$update_checker->getVcsApi()->enableReleaseAssets( $this->name_regex );
}

} catch (\Exception $e) {
// Log error if WordPress debug is enabled
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( 'GitHub Plugin Updater Error: ' . $e->getMessage() );
}
}
}

/**
* Create updater instance with minimal configuration
*
* @param string $github_url GitHub repository URL
* @param string $plugin_file Main plugin file path
* @param string $plugin_slug Plugin slug
* @param string $branch Branch name (default: 'main')
*
* @return GitHub_Plugin_Updater
*/
public static function create( $github_url, $plugin_file, $plugin_slug, $branch = 'main' ) {
return new self( array(
'github_url' => $github_url,
Expand All @@ -123,17 +68,6 @@ public static function create( $github_url, $plugin_file, $plugin_slug, $branch
) );
}

/**
* Create updater instance for plugins with release assets
*
* @param string $github_url GitHub repository URL
* @param string $plugin_file Main plugin file path
* @param string $plugin_slug Plugin slug
* @param string $name_regex Regex pattern for release assets
* @param string $branch Branch name (default: 'main')
*
* @return GitHub_Plugin_Updater
*/
public static function create_with_assets( $github_url, $plugin_file, $plugin_slug, $name_regex, $branch = 'main' ) {
return new self( array(
'github_url' => $github_url,
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@
"support": {
"issues": "https://github.com/soderlind/redis-queue-demo/issues"
},
"require": {}
"require": {},
"autoload": {
"psr-4": {
"Soderlind\\RedisQueueDemo\\": "src/"
}
}
}
2 changes: 0 additions & 2 deletions design.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,7 @@ redis-queue-demo/
├── redis-queue-demo.php # Main plugin file
├── uninstall.php # Cleanup on plugin removal
├── includes/ # Core functionality
│ ├── class-redis-queue-manager.php
│ ├── class-queue-worker.php
│ ├── class-job-processor.php
│ └── interfaces/
│ ├── interface-queue-job.php
│ └── interface-job-result.php
Expand Down
2 changes: 2 additions & 0 deletions docs/extending-jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This guide explains how to create custom background jobs by extending the base a

## Core Concepts

Important: The plugin now exclusively uses namespaced classes and only canonical job type identifiers you define (e.g. `email`, `image_processing`, `api_sync`, or your custom strings). Legacy/global class name variants (like `Email_Job`, `email_job`) are not auto-mapped.

A job represents a unit of work executed asynchronously by a worker. Each job class encapsulates:

- A unique job type identifier (string)
Expand Down
20 changes: 11 additions & 9 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,30 @@ curl -X POST "https://yoursite.com/wp-json/redis-queue/v1/jobs" \

### Creating & Enqueuing Jobs
```php
$redis_queue = redis_queue_demo();
use Soderlind\RedisQueueDemo\Jobs\Email_Job;

$email_job = new Email_Job([
'email_type' => 'single',
'to' => 'user@example.com',
'subject' => 'Welcome!',
'message' => 'Welcome to our site!'
'email_type' => 'single',
'to' => 'user@example.com',
'subject' => 'Welcome!',
'message' => 'Welcome to our site!'
]);

$email_job->set_priority(10);
$email_job->set_queue_name('emails');

$job_id = $redis_queue->queue_manager->enqueue($email_job);
$job_id = redis_queue_demo()->get_queue_manager()->enqueue( $email_job );
```

### Processing Jobs Manually
```php
use Soderlind\RedisQueueDemo\Workers\Sync_Worker;

$worker = new Sync_Worker(
$redis_queue->queue_manager,
$redis_queue->job_processor
redis_queue_demo()->get_queue_manager(),
redis_queue_demo()->get_job_processor()
);
$results = $worker->process_jobs(['default', 'emails'], 5);
$results = $worker->process_jobs( [ 'default', 'emails' ], 5 );
```

### Custom Job Skeleton
Expand Down
Loading