|
2 | 2 |
|
3 | 3 | namespace WP_CLI; |
4 | 4 |
|
| 5 | +use Composer\Semver\VersionParser; |
5 | 6 | use Composer\Semver\Comparator; |
6 | 7 | use Exception; |
7 | 8 | use WP_CLI; |
@@ -351,7 +352,7 @@ protected function update_many( $args, $assoc_args ) { |
351 | 352 | $type = $minor ? 'minor' : 'patch'; |
352 | 353 | $insecure = (bool) Utils\get_flag_value( $assoc_args, 'insecure', false ); |
353 | 354 |
|
354 | | - $items_to_update = self::get_minor_or_patch_updates( $items_to_update, $type, $insecure ); |
| 355 | + $items_to_update = self::get_minor_or_patch_updates( $items_to_update, $type, $insecure, true ); |
355 | 356 | } |
356 | 357 |
|
357 | 358 | $exclude = Utils\get_flag_value( $assoc_args, 'exclude' ); |
@@ -610,9 +611,10 @@ private function get_color( $status ) { |
610 | 611 | * @param array $items Plugins with updates. |
611 | 612 | * @param string $type Either 'minor' or 'patch'. |
612 | 613 | * @param bool $insecure Whether to retry without certificate validation on TLS handshake failure. |
| 614 | + * @param bool $require_stable Whether to require stable version when comparing versions. |
613 | 615 | * @return array |
614 | 616 | */ |
615 | | - private function get_minor_or_patch_updates( $items, $type, $insecure ) { |
| 617 | + private function get_minor_or_patch_updates( $items, $type, $insecure, $require_stable ) { |
616 | 618 | $wp_org_api = new WpOrgApi( [ 'insecure' => $insecure ] ); |
617 | 619 | foreach ( $items as $i => $item ) { |
618 | 620 | try { |
@@ -642,6 +644,10 @@ private function get_minor_or_patch_updates( $items, $type, $insecure ) { |
642 | 644 | if ( 'minor' === $type && ! in_array( $update_type, array( 'minor', 'patch' ), true ) ) { |
643 | 645 | continue; |
644 | 646 | } |
| 647 | + if ( $require_stable && 'stable' !== VersionParser::parseStability( $version ) ) { |
| 648 | + continue; |
| 649 | + } |
| 650 | + |
645 | 651 | if ( $update_version && ! Comparator::greaterThan( $version, $update_version ) ) { |
646 | 652 | continue; |
647 | 653 | } |
|
0 commit comments