Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
131 changes: 10 additions & 121 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
- [ ] 🧪 Test improvements
- [ ] 🔧 Chore (build process, dependencies, etc.)

## Related Issues

<!-- Link to related issues using GitHub keywords -->

<!-- Ignore if not applicable -->

Closes #<!-- issue number -->

## Pre-Submission Checklist

<!-- Verify all items before submitting this PR -->
Expand All @@ -25,127 +33,8 @@
- [ ] **All tests pass**: `slic run wpunit && slic run integration`
- [ ] **No debug code** (var_dump, error_log, etc.) left in production code
- [ ] **No commented-out code** unless specifically needed for reference

### Documentation & Communication

- [ ] **Documentation updated** for any new features or changed behavior
- [ ] **CLAUDE.md updated** if changes affect AI assistance context
- [ ] **Commit messages** follow [conventional commits format](/.github/CONTRIBUTING.md#commit-message-format)
- [ ] **PR title** follows conventional format: `<type>[scope]: description`

### Branch & Conflicts

- [ ] **Branch is up to date** with target branch (usually `main`)
- [ ] **No merge conflicts** exist
- [ ] **CHANGELOG.md updated** (if applicable)

## Testing

### Automated Testing

- [ ] New tests have been added for new functionality
- [ ] All existing tests continue to pass
- [ ] Test coverage is maintained or improved

### Manual Testing

<!-- Describe how you tested this change manually -->

**Test Environment:**

- WordPress version:
- PHP version:

**Test Steps:**

1. **Setup**: What initial setup is required? (e.g., `composer install`, activate plugins)
2. **Steps to Reproduce**:
- Go to '...'
- Click on '....'
- Execute '....'
- Verify '....'
3. **Verification**: What is the expected outcome?

**Expected Results:**
<!-- What should happen -->

**Actual Results:**
<!-- What actually happened -->

## Documentation Updates

- [ ] Code comments added/updated for complex logic
- [ ] PHPDoc blocks added/updated for public methods
- [ ] API documentation updated (`docs/api-reference.md`)
- [ ] User documentation updated (if applicable)
- [ ] Examples provided for new features

## Breaking Changes

<!-- If this is a breaking change, describe the impact -->

**What breaks:**
<!-- Describe what existing functionality will no longer work -->

**Migration path:**
<!-- Provide clear instructions for updating existing code -->

**Justification:**
<!-- Explain why this breaking change is necessary -->

## Related Issues

<!-- Link to related issues using GitHub keywords -->

Closes #<!-- issue number -->
Fixes #<!-- issue number -->
Related to #<!-- issue number -->

## Additional Context

<!-- Add any other context, screenshots, or information about the PR here -->

### Performance Impact
<!-- If applicable, describe any performance implications -->

### Security Considerations
<!-- If applicable, describe any security implications -->

### Screenshots

<!-- If your changes include UI components, provide before/after screenshots -->

**Before:**
<!-- Add screenshot here -->

**After:**
<!-- Add screenshot here -->

---

## For Reviewers

### Review Checklist

- [ ] Code follows WordPress coding standards
- [ ] Proper error handling is implemented
- [ ] Security best practices are followed
- [ ] Performance implications are acceptable
- [ ] Documentation is complete and accurate
- [ ] Tests provide adequate coverage
- [ ] Breaking changes are properly documented

---

<!--
By submitting this PR, I confirm that:
- I have read and followed the contributing guidelines
- My code follows the project's coding standards
- I have performed a self-review of my own code
- I have made corresponding changes to the documentation
- My changes generate no new warnings or errors
- I have added tests that prove my fix is effective or that my feature works
- New and existing unit tests pass locally with my changes
-->
- [ ] **New tests** have been added for new functionality
- [ ] **All existing tests** continue to pass

**📖 Read the full contributing guidelines: [CONTRIBUTING.md](/.github/CONTRIBUTING.md)**
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to this project will be documented in this file. This project adhere to the [Semantic Versioning](http://semver.org/) standard.

## [0.0.5] 2025-08-20

* Fix - Ensure the AS logger table exists before using it. Introduce a filter `shepherd_<hook_prefix>_should_log` to disable logging.

[0.0.5]: https://github.com/stellarwp/shepherd/releases/tag/0.0.5

## [0.0.4] 2025-08-04

* Fix - Deal with issues of auto-loading the functions.php file while using Strauss.
* Fix - Issue with php 7.4.

[0.0.4]: https://github.com/stellarwp/shepherd/releases/tag/0.0.4

## [0.0.3] 2025-07-31

* Fix - Removed an empty line after the columns and before the primary key of the Table creation SQL.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ Shepherd comes with a set of pre-packaged tasks to handle common background oper

## Contributing

We welcome contributions! Please see our contributing guidelines for more information. (TODO: Add a CONTRIBUTING.md file)
We welcome contributions! Please see our contributing guidelines for more information.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"php": ">=7.4",
"stellarwp/db": "^1.1",
"stellarwp/schema": "^2.0",
"woocommerce/action-scheduler": "3.9.2",
"woocommerce/action-scheduler": "3.9.3",
"psr/log": "^1.1"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion shepherd.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @wordpress-plugin
* Plugin Name: Shepherd
* Description: A library for offloading tasks to background processes.
* Version: 0.0.3
* Version: 0.0.5
* Author: StellarWP
* Author URI: https://stellarwp.com
* License: GPL-2.0-or-later
Expand Down
17 changes: 16 additions & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
use StellarWP\ContainerContract\ContainerInterface;
use StellarWP\Shepherd\Contracts\Logger;
use StellarWP\Shepherd\Loggers\ActionScheduler_DB_Logger;
use StellarWP\Shepherd\Loggers\Null_Logger;
use StellarWP\Shepherd\Loggers\DB_Logger;
use StellarWP\Shepherd\Tables\AS_Logs;

/**
* Shepherd Config
Expand Down Expand Up @@ -97,12 +100,24 @@ public static function get_hook_prefix(): string {
* Gets the logger.
*
* @since 0.0.1
* @since 0.0.5 Introduce a filter to disable logging. Ensures the AS logger table exists before using it.
*
* @return Logger
*/
public static function get_logger(): Logger {
if ( ! static::$logger ) {
static::$logger = new ActionScheduler_DB_Logger();
/**
* Filters whether to log anything.
*
* @since 0.0.5
*
* @param bool $should_log Whether to log anything.
*
* @return bool Whether to log anything.
*/
$should_log = (bool) apply_filters( 'shepherd_' . static::get_hook_prefix() . '_should_log', true );

static::$logger = ! $should_log ? new Null_Logger() : ( self::get_container()->get( AS_Logs::class )->exists() ? new ActionScheduler_DB_Logger() : new DB_Logger() );
}

return static::$logger;
Expand Down
24 changes: 24 additions & 0 deletions tests/wpunit/Config_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
use RuntimeException;
use StellarWP\ContainerContract\ContainerInterface;
use StellarWP\Shepherd\Loggers\ActionScheduler_DB_Logger;
use StellarWP\Shepherd\Loggers\DB_Logger;
use StellarWP\Shepherd\Loggers\Null_Logger;
use StellarWP\Schema\Tables\Contracts\Table;
use StellarWP\Shepherd\Tests\Traits\With_Uopz;

class Config_Test extends WPTestCase {
use With_Uopz;

/**
* @test
*/
Expand Down Expand Up @@ -50,9 +55,28 @@ public function it_should_throw_exception_if_setting_empty_hook_prefix(): void {
* @test
*/
public function it_should_get_default_db_logger_if_none_is_set(): void {
Config::set_hook_prefix( 'my_prefix' );
$this->assertInstanceOf( ActionScheduler_DB_Logger::class, Config::get_logger() );
}

/**
* @test
*/
public function it_should_get_db_logger_if_as_table_doesnt_exist(): void {
Config::set_hook_prefix( 'my_prefix' );
$this->set_class_fn_return( Table::class, 'exists', false );
$this->assertInstanceOf( DB_Logger::class, Config::get_logger() );
}

/**
* @test
*/
public function it_should_get_null_logger_if_should_log_is_false(): void {
Config::set_hook_prefix( 'my_prefix' );
add_filter( 'shepherd_my_prefix_should_log', '__return_false' );
$this->assertInstanceOf( Null_Logger::class, Config::get_logger() );
}

/**
* @test
*/
Expand Down
Loading