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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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.3] 2025-07-31

* Fix - Removed an empty line after the columns and before the primary key of the Table creation SQL.

Comment thread
dpanta94 marked this conversation as resolved.
[0.0.3]: https://github.com/stellarwp/shepherd/releases/tag/0.0.3

## [0.0.2] 2025-07-14

* Fix - Fix the path to the Action Scheduler file to take into consideration the different ways Composer can be installed.
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.2
* Version: 0.0.3
* Author: StellarWP
* Author URI: https://stellarwp.com
* License: GPL-2.0-or-later
Expand Down
5 changes: 3 additions & 2 deletions src/Abstracts/Table_Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ protected function check_and_add_index( array $results, string $index_name, stri
* by the `dbDelta` function.
*
* @since 0.0.1
* @since 0.0.3 Updated to remove an empty line after the columns and before the primary key.
*
* @return string The table creation SQL, in the format supported
* by the `dbDelta` function.
Expand Down Expand Up @@ -264,11 +265,11 @@ public function get_definition() {
$columns_definitions[] = $column_sql;
}

$columns_sql = implode( ',' . PHP_EOL, $columns_definitions ) . ',' . PHP_EOL;
$columns_sql = implode( ',' . PHP_EOL, $columns_definitions );

return "
CREATE TABLE `{$table_name}` (
{$columns_sql}
{$columns_sql},
PRIMARY KEY (`{$uid_column}`)
) {$charset_collate};
";
Expand Down
3 changes: 2 additions & 1 deletion src/Tables/Task_Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ class Task_Logs extends Table {
* The schema version.
*
* @since 0.0.1
* @since 0.0.3 Updated to 0.0.3.
*
* @var string
*/
const SCHEMA_VERSION = '0.0.2-dev';
const SCHEMA_VERSION = '0.0.3';

/**
* The base table name, without the table prefix.
Expand Down
3 changes: 2 additions & 1 deletion src/Tables/Tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ class Tasks extends Table {
* The schema version.
*
* @since 0.0.1
* @since 0.0.3 Updated to 0.0.2.
*
* @var string
*/
const SCHEMA_VERSION = '0.0.1-dev';
const SCHEMA_VERSION = '0.0.2s';

/**
* The base table name, without the table prefix.
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/Herding_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ public function it_should_only_clean_orphaned_tasks_not_active_ones(): void {
$shepherd->dispatch( $task1 );
$task_id_1 = $shepherd->get_last_scheduled_task_id();

// Execute first task
$this->assertTaskExecutesWithoutErrors( $task_id_1 );

$task2 = new Do_Action_Task( 'arg2' );
$shepherd->dispatch( $task2 );
$task_id_2 = $shepherd->get_last_scheduled_task_id();

$this->assertNotEquals( $task_id_1, $task_id_2 );

// Execute first task
$this->assertTaskExecutesWithoutErrors( $task_id_1 );

// Manually remove only the first task's action from Action Scheduler
DB::query(
DB::prepare(
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/Provider_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public function it_should_delete_multiple_tasks_for_same_action(): void {
$task_id_2 = $shepherd->get_last_scheduled_task_id();

$this->assertTaskExecutesWithoutErrors( $task_id_1 );
$this->assertTaskExecutesWithoutErrors( $task_id_2 );

// Manually set both tasks to have the same action_id for testing.
$common_action_id = $task1->get_action_id();
Expand All @@ -126,6 +125,7 @@ public function it_should_delete_multiple_tasks_for_same_action(): void {
$task_id_2
)
);

$this->assertEquals( 2, $tasks_count_before );

$this->delete_tasks_action( $task1 );
Expand Down Expand Up @@ -177,11 +177,12 @@ public function it_should_only_delete_tasks_for_specified_action(): void {
$shepherd->dispatch( $task1 );
$task_id_1 = $shepherd->get_last_scheduled_task_id();

$this->assertTaskExecutesWithoutErrors( $task_id_1 );

$task2 = new Do_Action_Task( 'arg2' );
$shepherd->dispatch( $task2 );
$task_id_2 = $shepherd->get_last_scheduled_task_id();

$this->assertTaskExecutesWithoutErrors( $task_id_1 );
$this->assertTaskExecutesWithoutErrors( $task_id_2 );

$this->delete_tasks_action( $task1 );
Expand Down
10 changes: 4 additions & 6 deletions tests/integration/Tasks/Email_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,17 @@ public function it_should_schedule_multiple_tasks_with_different_args(): void {
$task1_id = $shepherd->get_last_scheduled_task_id();
$this->assertIsInt( $task1_id );

$this->assertTaskExecutesWithoutErrors( $task1_id );

$task2 = new Email( 'test2@test.com', 'subject2', 'body2' );
$shepherd->dispatch( $task2 );
$task2_id = $shepherd->get_last_scheduled_task_id();
$this->assertIsInt( $task2_id );

$this->assertNotEquals( $task1_id, $task2_id );

$hook_name = 'shepherd_' . tests_shepherd_get_hook_prefix() . '_task_already_scheduled';
$this->assertSame( 0, did_action( $hook_name ) );

$this->assertTaskExecutesWithoutErrors( $task1_id );
$this->assertTaskExecutesWithoutErrors( $task2_id );

$this->assertNotEquals( $task1_id, $task2_id );

$this->assertCount( 2, $spy );
$this->assertSame( [ 'test1@test.com', 'subject1', 'body1', [], [] ], $spy[0] );
$this->assertSame( [ 'test2@test.com', 'subject2', 'body2', [], [] ], $spy[1] );
Expand Down
10 changes: 4 additions & 6 deletions tests/integration/Tasks/HTTP_Request_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,19 +382,17 @@ public function it_should_schedule_different_requests_separately(): void {
$task1_id = $shepherd->get_last_scheduled_task_id();
$this->assertIsInt( $task1_id );

$this->assertTaskExecutesWithoutErrors( $task1_id );

$task2 = new HTTP_Request( 'https://api2.example.com/endpoint' );
$shepherd->dispatch( $task2 );
$task2_id = $shepherd->get_last_scheduled_task_id();
$this->assertIsInt( $task2_id );

$this->assertNotEquals( $task1_id, $task2_id );

$hook_name = 'shepherd_' . tests_shepherd_get_hook_prefix() . '_task_already_scheduled';
$this->assertSame( 0, did_action( $hook_name ) );

$this->assertTaskExecutesWithoutErrors( $task1_id );
$this->assertTaskExecutesWithoutErrors( $task2_id );

$this->assertNotEquals( $task1_id, $task2_id );

$this->assertCount( 2, $spy );
$this->assertEquals( 'https://api1.example.com/endpoint', $spy[0][0] );
$this->assertEquals( 'https://api2.example.com/endpoint', $spy[1][0] );
Expand Down
Loading