Dbarratt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/384610 )

Change subject: Prevent an empty database record for email-blacklist
......................................................................

Prevent an empty database record for email-blacklist

The email-blacklist needs to be removed from $saveOptions. At the
same time, the default value (an empty array) should always be
returned for the preference.

Bug: T178337
Change-Id: Ie5855d648a99bfc9c083be60a64521e070401e2a
---
M includes/user/User.php
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/10/384610/1

diff --git a/includes/user/User.php b/includes/user/User.php
index 1c894a0..601af0e 100644
--- a/includes/user/User.php
+++ b/includes/user/User.php
@@ -5324,6 +5324,8 @@
                        // to an array of ids.
                        if ( isset( $data['email-blacklist'] ) && 
$data['email-blacklist'] ) {
                                $data['email-blacklist'] = array_map( 'intval', 
explode( "\n", $data['email-blacklist'] ) );
+                       } else {
+                               $data['email-blacklist'] = [];
                        }
 
                        foreach ( $data as $property => $value ) {
@@ -5363,8 +5365,9 @@
                                $this->mOptions['email-blacklist'] = $ids;
                                $saveOptions['email-blacklist'] = implode( 
"\n", $this->mOptions['email-blacklist'] );
                        } else {
-                               // If the blacklist is empty, set it to null 
rather than an empty string.
-                               $this->mOptions['email-blacklist'] = null;
+                               // If the blacklist is empty, Remove it from 
the options.
+                               $this->mOptions['email-blacklist'] = [];
+                               unset( $saveOptions['email-blacklist'] );
                        }
                }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/384610
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5855d648a99bfc9c083be60a64521e070401e2a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Dbarratt <dbarr...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to