@@ -23,10 +23,17 @@ function version_tags(
2323 return array ();
2424 }
2525
26- exec (
27- "grep '@ {$ prefix }-[0-9\.]*' -h -o {$ features_folder }/*.feature | uniq " ,
28- $ existing_tags
29- );
26+ $ existing_tags = array ();
27+ $ feature_files = glob ( $ features_folder . '/*.feature ' );
28+ if ( ! empty ( $ feature_files ) ) {
29+ foreach ( $ feature_files as $ feature_file ) {
30+ $ contents = file_get_contents ( $ feature_file );
31+ if ( preg_match_all ( '/@ ' . $ prefix . '-[0-9\.]+/ ' , $ contents , $ matches ) ) {
32+ $ existing_tags = array_merge ( $ existing_tags , $ matches [0 ] );
33+ }
34+ }
35+ $ existing_tags = array_unique ( $ existing_tags );
36+ }
3037
3138 $ skip_tags = array ();
3239
@@ -41,7 +48,11 @@ function version_tags(
4148}
4249
4350function get_db_version () {
44- $ version_string = exec ( getenv ( 'WP_CLI_TEST_DBTYPE ' ) === 'mariadb ' ? 'mariadb --version ' : 'mysql -V ' );
51+ $ db_type = getenv ( 'WP_CLI_TEST_DBTYPE ' );
52+ if ( 'sqlite ' === $ db_type ) {
53+ return '' ;
54+ }
55+ $ version_string = exec ( 'mariadb ' === $ db_type ? 'mariadb --version ' : 'mysql -V ' );
4556 preg_match ( '@[0-9]+\.[0-9]+\.[0-9]+@ ' , $ version_string , $ version );
4657 return $ version [0 ];
4758}
@@ -116,10 +127,16 @@ function get_db_version() {
116127# Require PHP extension, eg 'imagick'.
117128function extension_tags ( $ features_folder = 'features ' ) {
118129 $ extension_tags = array ();
119- exec (
120- "grep '@require-extension-[A-Za-z_]*' -h -o {$ features_folder }/*.feature | uniq " ,
121- $ extension_tags
122- );
130+ $ feature_files = glob ( $ features_folder . '/*.feature ' );
131+ if ( ! empty ( $ feature_files ) ) {
132+ foreach ( $ feature_files as $ feature_file ) {
133+ $ contents = file_get_contents ( $ feature_file );
134+ if ( preg_match_all ( '/@require-extension-[A-Za-z_]*/ ' , $ contents , $ matches ) ) {
135+ $ extension_tags = array_merge ( $ extension_tags , $ matches [0 ] );
136+ }
137+ }
138+ $ extension_tags = array_unique ( $ extension_tags );
139+ }
123140
124141 $ skip_tags = array ();
125142
0 commit comments