From 57415d8a318f701fff8bc5b58f8f401d9372f66a Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Sat, 8 Feb 2020 21:07:44 +0100 Subject: [PATCH] Fix PHPNotice caused by missing row fields Follow-up Ie9aae938cca06e38a7a834a3f74f3e8735ab01ee. Some fields are actually necessary when the filter isn't saved. This would cause PHP notices when showing the editor again. Change-Id: I2b9e0f04b3e8ad4eea8e334e16ee422bb40f0eb5 --- includes/Views/AbuseFilterViewEdit.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/Views/AbuseFilterViewEdit.php b/includes/Views/AbuseFilterViewEdit.php index 1ff9afcbe..958f16c26 100644 --- a/includes/Views/AbuseFilterViewEdit.php +++ b/includes/Views/AbuseFilterViewEdit.php @@ -1183,7 +1183,7 @@ class AbuseFilterViewEdit extends AbuseFilterView { // Default values $row = (object)[ 'af_throttled' => $origRow->af_throttled, - 'af_hit_count' => $origRow->af_hit_count + 'af_hit_count' => $origRow->af_hit_count, ]; $row->mOriginalRow = $origRow; $row->mOriginalActions = $origActions; @@ -1217,6 +1217,14 @@ class AbuseFilterViewEdit extends AbuseFilterView { $row->$name = $importRow->$name; } } else { + if ( $filter !== 'new' ) { + // These aren't needed when saving the filter, but they are otherwise (e.g. if + // saving fails and we need to show the edit interface again). + $row->af_user = $origRow->af_user; + $row->af_user_text = $origRow->af_user_text; + $row->af_timestamp = $origRow->af_timestamp; + } + $textLoads = [ 'af_public_comments' => 'wpFilterDescription', 'af_pattern' => 'wpFilterRules',