woocommerce/woocommerce

Fieldset verification is incorrect if the value does not exist in the field array.

クローズ

#30,897 opened on 2021/10/07

 (2 件のコメント) (0 件のリアクション) (0 人の担当者)PHP (10,695 件のフォーク)batch import
CheckoutEnhancementGood First IssueRubikplugin: woocommerce

Repository metrics

Stars
 (10,294 個のスター)
PR merge metrics
 (平均マージ 9d 12h) (30d で 423 merged PRs)

説明

If you request a non-existent field with the function, it throws an "Undefined index" notice. Since $this->fields is not null, but the $fieldset parameter is not an empty string, e.g. 'foo', then the first condition would return $this->fields['foo'], but it may not exist.

Suggestion for improvement.

return array_key_exists($fieldset, $this->fieldset) ? $this->fields[ $fieldset ] : $this->fields;

or

return isset($this->fieldset[$fieldset]) ? $this->fields[ $fieldset ] : $this->fields;

https://github.com/woocommerce/woocommerce/blob/4e929d78757a5e7fc9e70d2477070139d17135e1/includes/class-wc-checkout.php#L205

コントリビューターガイド