Skip to content

Commit b4b128a

Browse files
authored
Merge branch 'main' into copilot/add-wp-profile-queries
2 parents 91c69cf + 6033ffc commit b4b128a

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed

.github/workflows/copilot-setup-steps.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ jobs:
1717

1818
steps:
1919
- name: Checkout code
20-
uses: actions/checkout@v6
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2121

2222
- name: Check existence of composer.json file
2323
id: check_composer_file
24-
uses: andstor/file-existence-action@v3
24+
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3
2525
with:
2626
files: "composer.json"
2727

2828
- name: Set up PHP environment
2929
if: steps.check_composer_file.outputs.files_exists == 'true'
30-
uses: shivammathur/setup-php@v2
30+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
3131
with:
3232
php-version: 'latest'
3333
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Install Composer dependencies & cache dependencies
4040
if: steps.check_composer_file.outputs.files_exists == 'true'
41-
uses: ramsey/composer-install@v3
41+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3
4242
env:
4343
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
4444
with:

.github/workflows/issue-triage.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ name: Issue and PR Triage
1313
required: false
1414
type: string
1515

16+
permissions:
17+
issues: write
18+
pull-requests: write
19+
actions: write
20+
contents: read
21+
models: read
22+
1623
jobs:
1724
issue-triage:
1825
uses: wp-cli/.github/.github/workflows/reusable-issue-triage.yml@main

.github/workflows/regenerate-readme.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
- "features/**"
1111
- "README.md"
1212

13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
1317
jobs:
1418
regenerate-readme:
1519
uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@main

.github/workflows/welcome-new-contributors.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
- main
88
- master
99

10+
permissions:
11+
pull-requests: write
12+
1013
jobs:
1114
welcome:
1215
uses: wp-cli/.github/.github/workflows/reusable-welcome-new-contributors.yml@main

features/profile-stage.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ Feature: Profile the template render stage
134134
Error: Invalid stage. Must be one of bootstrap, main_query, template, or use --all.
135135
"""
136136

137+
@require-wp-4.0
138+
Scenario: Invalid field name supplied to --fields
139+
Given a WP install
140+
141+
When I try `wp profile stage template --fields=test`
142+
Then STDERR should contain:
143+
"""
144+
Invalid field(s): test
145+
"""
146+
And the return code should be 1
147+
137148
@require-wp-4.0
138149
Scenario: Identify callback_count for each hook
139150
Given a WP install

src/Formatter.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,22 @@ public function __construct( &$assoc_args, $fields = null, $prefix = false ) {
2727
$format_args['fields'] = explode( ',', $format_args['fields'] );
2828
}
2929

30-
if ( 'time' !== $fields[0] ) {
31-
$this->total_cell_index = array_search( $fields[0], $format_args['fields'], true );
30+
$format_args['fields'] = array_filter( array_map( 'trim', $format_args['fields'] ) );
31+
32+
if ( isset( $assoc_args['fields'] ) ) {
33+
if ( empty( $format_args['fields'] ) ) {
34+
$format_args['fields'] = $fields;
35+
}
36+
$invalid_fields = array_diff( $format_args['fields'], $fields );
37+
if ( ! empty( $invalid_fields ) ) {
38+
\WP_CLI::error( 'Invalid field(s): ' . implode( ', ', $invalid_fields ) );
39+
}
3240
}
3341

34-
$format_args['fields'] = array_map( 'trim', $format_args['fields'] );
42+
if ( 'time' !== $fields[0] ) {
43+
$index = array_search( $fields[0], $format_args['fields'], true );
44+
$this->total_cell_index = ( false !== $index ) ? $index : null;
45+
}
3546

3647
$this->args = $format_args;
3748
$this->formatter = new \WP_CLI\Formatter( $assoc_args, $fields, $prefix );

0 commit comments

Comments
 (0)