From bbe130b242fdece03336c08a13452d0a556fd443 Mon Sep 17 00:00:00 2001 From: Reedy Date: Fri, 19 Mar 2021 16:12:50 +0000 Subject: [PATCH] Rename some variables to use more neutral language Bug: T254646 Change-Id: I997625b8201dce2c257d20f96d00089e995c2b0d --- includes/actions/SpecialPageAction.php | 2 +- includes/api/ApiAuthManagerHelper.php | 12 ++++++------ includes/api/ApiRemoveAuthenticationData.php | 6 +++--- includes/block/BlockManager.php | 6 +++--- includes/jobqueue/JobQueueGroup.php | 8 ++++---- includes/pager/TablePager.php | 8 ++++---- .../ResourceLoaderLessVarFileModule.php | 6 +++--- includes/upload/UploadBase.php | 6 +++--- includes/upload/UploadFromUrl.php | 6 +++--- includes/user/UserNameUtils.php | 6 +++--- 10 files changed, 33 insertions(+), 33 deletions(-) diff --git a/includes/actions/SpecialPageAction.php b/includes/actions/SpecialPageAction.php index 56be456cac7..2fa53965632 100644 --- a/includes/actions/SpecialPageAction.php +++ b/includes/actions/SpecialPageAction.php @@ -96,7 +96,7 @@ class SpecialPageAction extends FormlessAction { return null; } - // map actions to (whitelisted) special pages + // map actions to (allowed) special pages return MediaWikiServices::getInstance()->getSpecialPageFactory()-> getPage( self::$actionToSpecialPageMapping[$action] ); } diff --git a/includes/api/ApiAuthManagerHelper.php b/includes/api/ApiAuthManagerHelper.php index 72ce07ed21e..61d298a8d88 100644 --- a/includes/api/ApiAuthManagerHelper.php +++ b/includes/api/ApiAuthManagerHelper.php @@ -123,14 +123,14 @@ class ApiAuthManagerHelper { /** * Filter out authentication requests by class name * @param AuthenticationRequest[] $reqs Requests to filter - * @param string[] $blacklist Class names to remove + * @param string[] $remove Class names to remove * @return AuthenticationRequest[] */ - public static function blacklistAuthenticationRequests( array $reqs, array $blacklist ) { - if ( $blacklist ) { - $blacklist = array_flip( $blacklist ); - $reqs = array_filter( $reqs, static function ( $req ) use ( $blacklist ) { - return !isset( $blacklist[get_class( $req )] ); + public static function blacklistAuthenticationRequests( array $reqs, array $remove ) { + if ( $remove ) { + $remove = array_flip( $remove ); + $reqs = array_filter( $reqs, static function ( $req ) use ( $remove ) { + return !isset( $remove[get_class( $req )] ); } ); } return $reqs; diff --git a/includes/api/ApiRemoveAuthenticationData.php b/includes/api/ApiRemoveAuthenticationData.php index 07144857933..cc1dfae68a3 100644 --- a/includes/api/ApiRemoveAuthenticationData.php +++ b/includes/api/ApiRemoveAuthenticationData.php @@ -59,14 +59,14 @@ class ApiRemoveAuthenticationData extends ApiBase { // Fetch the request. No need to load from the request, so don't use // ApiAuthManagerHelper's method. - $blacklist = $this->authAction === AuthManager::ACTION_REMOVE + $remove = $this->authAction === AuthManager::ACTION_REMOVE ? array_flip( $this->getConfig()->get( 'RemoveCredentialsBlacklist' ) ) : []; $reqs = array_filter( $manager->getAuthenticationRequests( $this->authAction, $this->getUser() ), - static function ( AuthenticationRequest $req ) use ( $params, $blacklist ) { + static function ( AuthenticationRequest $req ) use ( $params, $remove ) { return $req->getUniqueId() === $params['request'] && - !isset( $blacklist[get_class( $req )] ); + !isset( $remove[get_class( $req )] ); } ); if ( count( $reqs ) !== 1 ) { diff --git a/includes/block/BlockManager.php b/includes/block/BlockManager.php index e535e78cb8e..e32d2fcf0ca 100644 --- a/includes/block/BlockManager.php +++ b/includes/block/BlockManager.php @@ -363,12 +363,12 @@ class BlockManager { * Whether the given IP is in a DNS blacklist. * * @param string $ip IP to check - * @param bool $checkWhitelist Whether to check the whitelist first + * @param bool $checkAllowed Whether to check $wgProxyWhitelist first * @return bool True if blacklisted. */ - public function isDnsBlacklisted( $ip, $checkWhitelist = false ) { + public function isDnsBlacklisted( $ip, $checkAllowed = false ) { if ( !$this->options->get( 'EnableDnsBlacklist' ) || - ( $checkWhitelist && in_array( $ip, $this->options->get( 'ProxyWhitelist' ) ) ) + ( $checkAllowed && in_array( $ip, $this->options->get( 'ProxyWhitelist' ) ) ) ) { return false; } diff --git a/includes/jobqueue/JobQueueGroup.php b/includes/jobqueue/JobQueueGroup.php index 34a1c2215ee..cb5bc9e640d 100644 --- a/includes/jobqueue/JobQueueGroup.php +++ b/includes/jobqueue/JobQueueGroup.php @@ -230,10 +230,10 @@ class JobQueueGroup { * * @param int|string $qtype JobQueueGroup::TYPE_* constant or job type string * @param int $flags Bitfield of JobQueueGroup::USE_* constants - * @param array $blacklist List of job types to ignore + * @param array $ignored List of job types to ignore * @return RunnableJob|bool Returns false on failure */ - public function pop( $qtype = self::TYPE_DEFAULT, $flags = 0, array $blacklist = [] ) { + public function pop( $qtype = self::TYPE_DEFAULT, $flags = 0, array $ignored = [] ) { global $wgJobClasses; $job = false; @@ -247,7 +247,7 @@ class JobQueueGroup { } if ( is_string( $qtype ) ) { // specific job type - if ( !in_array( $qtype, $blacklist ) ) { + if ( !in_array( $qtype, $ignored ) ) { $job = $this->get( $qtype )->pop(); } } else { // any job in the "default" jobs types @@ -264,7 +264,7 @@ class JobQueueGroup { $types = array_intersect( $types, $this->getDefaultQueueTypes() ); } - $types = array_diff( $types, $blacklist ); // avoid selected types + $types = array_diff( $types, $ignored ); // avoid selected types shuffle( $types ); // avoid starvation foreach ( $types as $type ) { // for each queue... diff --git a/includes/pager/TablePager.php b/includes/pager/TablePager.php index 4bbea854073..d2e4baec344 100644 --- a/includes/pager/TablePager.php +++ b/includes/pager/TablePager.php @@ -407,13 +407,13 @@ abstract class TablePager extends IndexPager { * Resubmits all defined elements of the query string, except for a * blacklist, passed in the $blacklist parameter. * - * @param array $blacklist Parameters from the request query which should not be resubmitted + * @param array $noResubmit Parameters from the request query which should not be resubmitted * @return string HTML fragment */ - public function getHiddenFields( $blacklist = [] ) { - $blacklist = (array)$blacklist; + public function getHiddenFields( $noResubmit = [] ) { + $noResubmit = (array)$noResubmit; $query = $this->getRequest()->getQueryValues(); - foreach ( $blacklist as $name ) { + foreach ( $noResubmit as $name ) { unset( $query[$name] ); } $s = ''; diff --git a/includes/resourceloader/ResourceLoaderLessVarFileModule.php b/includes/resourceloader/ResourceLoaderLessVarFileModule.php index ecaa5629d6e..e4ef45d9a2d 100644 --- a/includes/resourceloader/ResourceLoaderLessVarFileModule.php +++ b/includes/resourceloader/ResourceLoaderLessVarFileModule.php @@ -57,14 +57,14 @@ class ResourceLoaderLessVarFileModule extends ResourceLoaderFileModule { * Return a subset of messages from a JSON string representation. * * @param string $blob JSON - * @param string[] $whitelist + * @param string[] $allowed * @return array */ - private function pluckFromMessageBlob( $blob, array $whitelist ) : array { + private function pluckFromMessageBlob( $blob, array $allowed ) : array { $data = json_decode( $blob, true ); // Keep only the messages intended for LESS export // (opposite of getMesssages essentially). - return array_intersect_key( $data, array_flip( $whitelist ) ); + return array_intersect_key( $data, array_flip( $allowed ) ); } /** diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 3906c713b17..abb5d90b2d6 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -2161,7 +2161,7 @@ abstract class UploadBase { * @return string[] List of prefixes */ public static function getFilenamePrefixBlacklist() { - $blacklist = []; + $list = []; $message = wfMessage( 'filename-prefix-blacklist' )->inContentLanguage(); if ( !$message->isDisabled() ) { $lines = explode( "\n", $message->plain() ); @@ -2176,11 +2176,11 @@ abstract class UploadBase { if ( $comment > 0 ) { $line = substr( $line, 0, $comment - 1 ); } - $blacklist[] = trim( $line ); + $list[] = trim( $line ); } } - return $blacklist; + return $list; } /** diff --git a/includes/upload/UploadFromUrl.php b/includes/upload/UploadFromUrl.php index f1b8303c8ae..29650735c3b 100644 --- a/includes/upload/UploadFromUrl.php +++ b/includes/upload/UploadFromUrl.php @@ -86,12 +86,12 @@ class UploadFromUrl extends UploadBase { $valid = false; foreach ( $wgCopyUploadsDomains as $domain ) { // See if the domain for the upload matches this whitelisted domain - $whitelistedDomainPieces = explode( '.', $domain ); + $domainPieces = explode( '.', $domain ); $uploadDomainPieces = explode( '.', $parsedUrl['host'] ); - if ( count( $whitelistedDomainPieces ) === count( $uploadDomainPieces ) ) { + if ( count( $domainPieces ) === count( $uploadDomainPieces ) ) { $valid = true; // See if all the pieces match or not (excluding wildcards) - foreach ( $whitelistedDomainPieces as $index => $piece ) { + foreach ( $domainPieces as $index => $piece ) { if ( $piece !== '*' && $piece !== $uploadDomainPieces[$index] ) { $valid = false; } diff --git a/includes/user/UserNameUtils.php b/includes/user/UserNameUtils.php index fb17514fb08..50794d55565 100644 --- a/includes/user/UserNameUtils.php +++ b/includes/user/UserNameUtils.php @@ -150,9 +150,9 @@ class UserNameUtils implements UserRigorOptions { return false; } - // Check an additional blacklist of troublemaker characters. + // Check an additional list of troublemaker characters. // Should these be merged into the title char list? - $unicodeBlacklist = '/[' . + $unicodeList = '/[' . '\x{0080}-\x{009f}' . # iso-8859-1 control chars '\x{00a0}' . # non-breaking space '\x{2000}-\x{200f}' . # various whitespace @@ -160,7 +160,7 @@ class UserNameUtils implements UserRigorOptions { '\x{3000}' . # ideographic space '\x{e000}-\x{f8ff}' . # private use ']/u'; - if ( preg_match( $unicodeBlacklist, $name ) ) { + if ( preg_match( $unicodeList, $name ) ) { return false; }