From 81ab2ff2093f12f96673538fe9a07c301df1edd1 Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Tue, 19 Aug 2025 22:59:18 +0300 Subject: [PATCH 1/7] make sure AS logs table exists before using it --- src/Config.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index ba0b5d6a..18839921 100644 --- a/src/Config.php +++ b/src/Config.php @@ -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 @@ -102,7 +105,18 @@ public static function get_hook_prefix(): string { */ public static function get_logger(): Logger { if ( ! static::$logger ) { - static::$logger = new ActionScheduler_DB_Logger(); + /** + * Filters whether to log anything. + * + * @since TBD + * + * @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; From dd051cf25fbdae73f5bdbaf5612bed01b249ac36 Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Tue, 19 Aug 2025 23:04:36 +0300 Subject: [PATCH 2/7] Update docs --- CHANGELOG.md | 11 +++++++++++ shepherd.php | 2 +- src/Config.php | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a5ba595..88fe9275 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ 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__should_log` to disable logging. + +## [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.3]: https://github.com/stellarwp/shepherd/releases/tag/0.0.3 + ## [0.0.3] 2025-07-31 * Fix - Removed an empty line after the columns and before the primary key of the Table creation SQL. diff --git a/shepherd.php b/shepherd.php index c7446792..eeff43f2 100644 --- a/shepherd.php +++ b/shepherd.php @@ -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 diff --git a/src/Config.php b/src/Config.php index 18839921..76db1ce9 100644 --- a/src/Config.php +++ b/src/Config.php @@ -100,6 +100,7 @@ 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 */ @@ -108,7 +109,7 @@ public static function get_logger(): Logger { /** * Filters whether to log anything. * - * @since TBD + * @since 0.0.5 * * @param bool $should_log Whether to log anything. * From a78f75623cc132b1257460cc3db97aaecb7aef1f Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Tue, 19 Aug 2025 23:05:18 +0300 Subject: [PATCH 3/7] Fix docs --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88fe9275..53cac6ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,14 @@ All notable changes to this project will be documented in this file. This projec * Fix - Ensure the AS logger table exists before using it. Introduce a filter `shepherd__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.3]: https://github.com/stellarwp/shepherd/releases/tag/0.0.3 +[0.0.4]: https://github.com/stellarwp/shepherd/releases/tag/0.0.4 ## [0.0.3] 2025-07-31 From 0c6e792b2a129516efe5d8ea8dab9dffc61e8c3e Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Tue, 19 Aug 2025 23:10:12 +0300 Subject: [PATCH 4/7] Added test coverage --- tests/wpunit/Config_Test.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/wpunit/Config_Test.php b/tests/wpunit/Config_Test.php index c6585372..cd76fec6 100644 --- a/tests/wpunit/Config_Test.php +++ b/tests/wpunit/Config_Test.php @@ -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 */ @@ -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 */ From fdb06c82b5708b18520b867322929cbe63d349e2 Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Tue, 19 Aug 2025 23:14:43 +0300 Subject: [PATCH 5/7] update docs --- .github/pull_request_template.md | 131 +++---------------------------- README.md | 2 +- 2 files changed, 11 insertions(+), 122 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 1e4a4bd4..8c835eaa 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -13,6 +13,14 @@ - [ ] ๐Ÿงช Test improvements - [ ] ๐Ÿ”ง Chore (build process, dependencies, etc.) +## Related Issues + + + + + +Closes # + ## Pre-Submission Checklist @@ -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: `[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 - - - -**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:** - - -**Actual Results:** - - -## 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 - - - -**What breaks:** - - -**Migration path:** - - -**Justification:** - - -## Related Issues - - - -Closes # -Fixes # -Related to # - -## Additional Context - - - -### Performance Impact - - -### Security Considerations - - -### Screenshots - - - -**Before:** - - -**After:** - - ---- - -## 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 - ---- - - +- [ ] **New tests** have been added for new functionality +- [ ] **All existing tests** continue to pass **๐Ÿ“– Read the full contributing guidelines: [CONTRIBUTING.md](/.github/CONTRIBUTING.md)** diff --git a/README.md b/README.md index 7f25c9eb..18404bee 100644 --- a/README.md +++ b/README.md @@ -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. From 36dbe32da39b583d92379b619017052cd5e88578 Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Tue, 19 Aug 2025 23:18:38 +0300 Subject: [PATCH 6/7] Update AS included version to match WC's --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8f5595ca..0bc50b46 100644 --- a/composer.json +++ b/composer.json @@ -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": { From 378f389ee59c922d860f00d3967bb6a55ce7fb88 Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Tue, 19 Aug 2025 23:32:41 +0300 Subject: [PATCH 7/7] Updated release date --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53cac6ec..05c6e254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ 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 +## [0.0.5] 2025-08-19 * Fix - Ensure the AS logger table exists before using it. Introduce a filter `shepherd__should_log` to disable logging.