Skip to content

Commit 2681e0f

Browse files
committed
Plugin Directory: Fix PHP warnings for undefined array keys in upload handler.
Two loops reused a variable name that overwrote the full plugin check result. When the code later tried to read the process output and error details, those keys didn't exist on the individual check record. Also ensures the early return when the process fails to start includes all expected keys, matching the structure returned on the normal path. git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14783 74240141-8908-4e6f-9713-ba540dce6ec7
1 parent e8c0553 commit 2681e0f

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-plugin-updates-pcp.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,16 @@ public static function run_plugin_check( $plugin_slug, $path, $tag = '', $mode =
358358
if ( ! $plugin_check_process ) {
359359
// If we can't run plugin-check, we'll just return a pass.
360360
return [
361-
'verdict' => true,
362-
'results' => [],
363-
'html' => '',
361+
'verdict' => true,
362+
'results' => [],
363+
'results_by_type' => [],
364+
'files' => [],
365+
'totals' => [ 'errors' => 0, 'warnings' => 0 ],
366+
'return_code' => 0,
367+
'output' => [],
368+
'stderr' => '',
369+
'total_time' => 0,
370+
'hash' => '',
364371
];
365372
}
366373

wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -814,14 +814,14 @@ public function check_plugin() {
814814
$maybe_false_positive = __( 'This may be a false-positive, and will be manually checked by a reviewer.', 'wporg-plugins' );
815815
}
816816

817-
foreach ( $result_set as $result ) {
817+
foreach ( $result_set as $check_result ) {
818818
$html .= sprintf(
819819
'<li>%s <a href="%s" title="%s">%s</a>: %s</li>',
820-
esc_html( $result['file'] ),
821-
esc_url( $result['docs'] ?? '' ),
820+
esc_html( $check_result['file'] ),
821+
esc_url( $check_result['docs'] ?? '' ),
822822
esc_attr( $maybe_false_positive ),
823-
esc_html( "{$result_label}: {$result['code']}" ),
824-
$result['message'] // Already escaped.
823+
esc_html( "{$result_label}: {$check_result['code']}" ),
824+
$check_result['message'] // Already escaped.
825825
);
826826
}
827827
}
@@ -851,9 +851,9 @@ public function check_plugin() {
851851

852852
// Include a simplified / merged version of the results for review.
853853
$group_by_code = [ 'ERROR' => [], 'WARNING' => [] ];
854-
foreach ( $results as $result ) {
855-
$group_by_code[ $result['type'] ][ $result['code'] ] ??= [];
856-
$group_by_code[ $result['type'] ][ $result['code'] ][] = $result;
854+
foreach ( $results as $check_result ) {
855+
$group_by_code[ $check_result['type'] ][ $check_result['code'] ] ??= [];
856+
$group_by_code[ $check_result['type'] ][ $check_result['code'] ][] = $check_result;
857857
}
858858
foreach ( $group_by_code as $type => $codes ) {
859859
foreach ( $codes as $code_results ) {

0 commit comments

Comments
 (0)