|
2 | 2 |
|
3 | 3 | namespace WP_CLI; |
4 | 4 |
|
| 5 | +use WP_CLI; |
| 6 | + |
5 | 7 | /** |
6 | 8 | * Trait that provides ID range expansion for WP-CLI commands. |
7 | 9 | * |
@@ -39,13 +41,19 @@ protected static function expand_id_ranges( array $args, callable $get_ids_in_ra |
39 | 41 | $start = $end; |
40 | 42 | $end = $temp; |
41 | 43 | } |
42 | | - $ids = array_merge( $ids, $get_ids_in_range( $start, $end ) ); |
| 44 | + $range_ids = $get_ids_in_range( $start, $end ); |
| 45 | + WP_CLI::debug( sprintf( "Expanded range '%s' to %d IDs.", $arg, count( $range_ids ) ), 'range-expansion' ); |
| 46 | + $ids = array_merge( $ids, $range_ids ); |
43 | 47 | } elseif ( preg_match( '/^(\d+)-$/', $arg, $matches ) ) { |
44 | 48 | // Open-ended range: "34-" |
45 | | - $ids = array_merge( $ids, $get_ids_in_range( (int) $matches[1], null ) ); |
| 49 | + $range_ids = $get_ids_in_range( (int) $matches[1], null ); |
| 50 | + WP_CLI::debug( sprintf( "Expanded range '%s' to %d IDs.", $arg, count( $range_ids ) ), 'range-expansion' ); |
| 51 | + $ids = array_merge( $ids, $range_ids ); |
46 | 52 | } elseif ( preg_match( '/^-(\d+)$/', $arg, $matches ) ) { |
47 | 53 | // Lower-bounded range: "-35" |
48 | | - $ids = array_merge( $ids, $get_ids_in_range( 1, (int) $matches[1] ) ); |
| 54 | + $range_ids = $get_ids_in_range( 1, (int) $matches[1] ); |
| 55 | + WP_CLI::debug( sprintf( "Expanded range '%s' to %d IDs.", $arg, count( $range_ids ) ), 'range-expansion' ); |
| 56 | + $ids = array_merge( $ids, $range_ids ); |
49 | 57 | } else { |
50 | 58 | $ids[] = $arg; |
51 | 59 | } |
|
0 commit comments