Skip to content

Commit e273b1c

Browse files
committed
Bump wordpress.org version-check API usage to v1.7
The 1.6 endpoint requires the unsafe `unserialize` method that is flagged by PHPCS. By bumping the version to 1.7, we can replace that with JSON instead.
1 parent c9f4584 commit e273b1c

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/Core_Command.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ public function download( $args, $assoc_args ) {
170170
if ( ! $offer ) {
171171
WP_CLI::error( "The requested locale ({$locale}) was not found." );
172172
}
173-
$version = $offer['current'];
174-
$download_url = $offer['download'];
173+
$version = $offer->current;
174+
$download_url = $offer->download;
175175
if ( ! $skip_content ) {
176176
$download_url = str_replace( '.zip', '.tar.gz', $download_url );
177177
}
@@ -292,12 +292,14 @@ private static function read( $url ) {
292292
}
293293

294294
private function get_download_offer( $locale ) {
295-
$out = self::read( 'https://api.wordpress.org/core/version-check/1.6/?locale=' . $locale );
296-
$out = unserialize( $out );
295+
$out = self::read( 'https://api.wordpress.org/core/version-check/1.7/?locale=' . $locale );
296+
$out = function_exists( 'wp_json_decode' )
297+
? wp_json_decode( $out )
298+
: json_decode( $out );
297299

298-
$offer = $out['offers'][0];
300+
$offer = $out->offers[0];
299301

300-
if ( $offer['locale'] !== $locale ) {
302+
if ( $offer->locale !== $locale ) {
301303
return false;
302304
}
303305

0 commit comments

Comments
 (0)