Skip to content

Commit 3788b95

Browse files
swissspidyCopilot
andauthored
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 40062cd commit 3788b95

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/WP_CLI/ExpandsIdRanges.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ protected static function expand_id_ranges( array $args, callable $get_ids_in_ra
3131
foreach ( $args as $arg ) {
3232
if ( preg_match( '/^(\d+)-(\d+)$/', $arg, $matches ) ) {
3333
// Full range: "15-35"
34-
$ids = array_merge( $ids, $get_ids_in_range( (int) $matches[1], (int) $matches[2] ) );
34+
$start = (int) $matches[1];
35+
$end = (int) $matches[2];
36+
if ( $start > $end ) {
37+
// Normalize reversed ranges like "35-15" to "15-35".
38+
$temp = $start;
39+
$start = $end;
40+
$end = $temp;
41+
}
42+
$ids = array_merge( $ids, $get_ids_in_range( $start, $end ) );
3543
} elseif ( preg_match( '/^(\d+)-$/', $arg, $matches ) ) {
3644
// Open-ended range: "34-"
3745
$ids = array_merge( $ids, $get_ids_in_range( (int) $matches[1], null ) );

0 commit comments

Comments
 (0)