aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiQueryWatchlist.php
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2021-06-11 12:52:06 +1000
committerTim Starling <tstarling@wikimedia.org>2021-06-15 00:11:10 +0000
commit9c3c0b704b695af6e332f6d1bd8b13fad8fd5a66 (patch)
tree3eed7254368c5578f321201c6d7678451be3522a /includes/api/ApiQueryWatchlist.php
parent1129e717746e440efa7e5b190a2bbc8cc29f429b (diff)
downloadmediawikicore-9c3c0b704b695af6e332f6d1bd8b13fad8fd5a66.tar.gz
mediawikicore-9c3c0b704b695af6e332f6d1bd8b13fad8fd5a66.zip
Use array_fill_keys() instead of array_flip() if that reflects the developer's intention
array_fill_keys() was introduced in PHP 5.2.0 and works like array_flip() except that it does only one thing (copying keys) instead of two things (copying keys and values). That makes it faster and more obvious. When array_flip() calls were paired, I left them as is, because that pattern is too cute. I couldn't kill something so cute. Sometimes it was hard to figure out whether the values in array_flip() result were used. That's the point of this change. If you use array_fill_keys(), the intention is obvious. Change-Id: If8d340a8bc816a15afec37e64f00106ae45e10ed
Diffstat (limited to 'includes/api/ApiQueryWatchlist.php')
-rw-r--r--includes/api/ApiQueryWatchlist.php4
1 files changed, 2 insertions, 2 deletions
diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php
index 9d62380b7b79..968b5a0e1441 100644
--- a/includes/api/ApiQueryWatchlist.php
+++ b/includes/api/ApiQueryWatchlist.php
@@ -80,7 +80,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
$wlowner = $this->getWatchlistUser( $params );
if ( $params['prop'] !== null && $resultPageSet === null ) {
- $prop = array_flip( $params['prop'] );
+ $prop = array_fill_keys( $params['prop'], true );
$this->fld_ids = isset( $prop['ids'] );
$this->fld_title = isset( $prop['title'] );
@@ -145,7 +145,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
}
if ( $params['show'] !== null ) {
- $show = array_flip( $params['show'] );
+ $show = array_fill_keys( $params['show'], true );
/* Check for conflicting parameters. */
if ( $this->showParamsConflicting( $show ) ) {