Skip to content

Commit

Permalink
Launchpad: Add validation for required tasks (#31626)
Browse files Browse the repository at this point in the history
* [not verified] Check that all required tasks are included in the array of task ids

* changelog

* [not verified] Compare the arrays, don't count them

* the condition was wrong

---------

Co-authored-by: Andrés Blanco <[email protected]>
  • Loading branch information
sixhours and Andrés Blanco authored Jul 3, 2023
1 parent 637c4a8 commit d4b9a58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add validation for required tasks.
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ public static function validate_task_list( $task_list ) {
return false;
}

// If we have required tasks, make sure they all exist in the array of `task_ids`.
if ( isset( $task_list['required_task_ids'] ) && array_intersect( $task_list['required_task_ids'], $task_list['task_ids'] ) !== $task_list['required_task_ids'] ) {
_doing_it_wrong( 'validate_task_list', 'The required_task_ids must be a subset of the task_ids', '6.1' );
return false;
}

if ( isset( $task_list['require_last_task_completion'] ) && ! is_bool( $task_list['require_last_task_completion'] ) ) {
_doing_it_wrong( 'validate_task_list', 'The require_last_task_completion attribute must be a boolean', '6.1' );
return false;
Expand Down

0 comments on commit d4b9a58

Please sign in to comment.