@@ -105,6 +105,11 @@ public function __invoke( $args, $assoc_args ) {
105105 continue ;
106106 }
107107
108+ if ( 'hello ' === $ plugin ->name ) {
109+ $ this ->verify_hello_dolly_from_core ( $ assoc_args );
110+ continue ;
111+ }
112+
108113 if ( false === $ version ) {
109114 WP_CLI ::warning ( "Could not retrieve the version for plugin {$ plugin ->name }, skipping. " );
110115 ++$ skips ;
@@ -143,7 +148,6 @@ public function __invoke( $args, $assoc_args ) {
143148 if ( ! $ strict && $ this ->is_soft_change_file ( $ file ) ) {
144149 continue ;
145150 }
146-
147151 $ result = $ this ->check_file_checksum ( dirname ( $ plugin ->file ) . '/ ' . $ file , $ checksums [ $ file ] );
148152 if ( true !== $ result ) {
149153 $ this ->add_error ( $ plugin ->name , $ file , is_string ( $ result ) ? $ result : 'Checksum does not match ' );
@@ -173,6 +177,29 @@ public function __invoke( $args, $assoc_args ) {
173177 );
174178 }
175179
180+ private function verify_hello_dolly_from_core ( $ assoc_args ) {
181+ $ file = 'hello.php ' ;
182+ $ wp_version = get_bloginfo ( 'version ' , 'display ' );
183+ $ insecure = (bool ) Utils \get_flag_value ( $ assoc_args , 'insecure ' , false );
184+ $ wp_org_api = new WpOrgApi ( [ 'insecure ' => $ insecure ] );
185+ $ locale = '' ;
186+
187+ try {
188+ $ checksums = $ wp_org_api ->get_core_checksums ( $ wp_version , empty ( $ locale ) ? 'en_US ' : $ locale );
189+ } catch ( Exception $ exception ) {
190+ WP_CLI ::error ( $ exception );
191+ }
192+
193+ if ( ! is_array ( $ checksums ) || ! isset ( $ checksums ['wp-content/plugins/hello.php ' ] ) ) {
194+ WP_CLI ::error ( "Couldn't get hello.php checksum from WordPress.org. " );
195+ }
196+
197+ $ md5_file = md5_file ( $ this ->get_absolute_path ( '/ ' ) . $ file );
198+ if ( $ md5_file !== $ checksums ['wp-content/plugins/hello.php ' ] ) {
199+ $ this ->add_error ( 'hello ' , $ file , 'Checksum does not match ' );
200+ }
201+ }
202+
176203 /**
177204 * Adds a new error to the array of detected errors.
178205 *
@@ -255,7 +282,6 @@ private function check_file_checksum( $path, $checksums ) {
255282 && array_key_exists ( 'sha256 ' , $ checksums )
256283 ) {
257284 $ sha256 = $ this ->get_sha256 ( $ this ->get_absolute_path ( $ path ) );
258-
259285 return in_array ( $ sha256 , (array ) $ checksums ['sha256 ' ], true );
260286 }
261287
0 commit comments