Legoktm has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/372114 )
Change subject: build: Update mediawiki/mediawiki-codesniffer to 0.11.1 ...................................................................... build: Update mediawiki/mediawiki-codesniffer to 0.11.1 Change-Id: I89e6b5f61e0ef048b7bcfba0a88c03c7db352c2c --- M CirrusSearch.php M composer.json M includes/BaseInterwikiResolver.php M includes/BuildDocument/Completion/NaiveSubphrasesSuggestionsBuilder.php M includes/BuildDocument/Completion/SuggestBuilder.php M includes/CirrusSearch.php M includes/CompletionRequestLog.php M includes/CompletionSuggester.php M includes/DataSender.php M includes/Job/Job.php M includes/LanguageDetector/ElasticSearch.php M includes/Maintenance/AnalysisConfigBuilder.php M includes/Maintenance/ConfigUtils.php M includes/Maintenance/Reindexer.php M includes/Maintenance/SuggesterAnalysisConfigBuilder.php M includes/Query/FullTextSimpleMatchQueryBuilder.php M includes/Query/PreferRecentFeature.php M includes/Sanity/Checker.php M includes/Search/CrossProjectBlockScorer.php M includes/Search/RescoreBuilders.php M includes/Search/ResultsType.php M includes/Search/TitleHelper.php M includes/UserTesting.php M maintenance/saneitizeJobs.php M maintenance/updateSuggesterIndex.php M profiles/CrossProjectBlockScorerProfiles.php M profiles/FullTextQueryBuilderProfiles.php M profiles/PhraseSuggesterProfiles.php M profiles/RescoreProfiles.php M profiles/SaneitizeProfiles.php M tests/unit/CompletionSuggesterTest.php M tests/unit/Maintenance/AnalysisConfigBuilderTest.php M tests/unit/RequestLoggerTest.php M tests/unit/SuggestBuilderTest.php M tests/unit/SuggestScoringTest.php M tests/unit/UserTestingTest.php 36 files changed, 73 insertions(+), 73 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/14/372114/1 diff --git a/CirrusSearch.php b/CirrusSearch.php index ccf7d77..4a22384 100644 --- a/CirrusSearch.php +++ b/CirrusSearch.php @@ -1332,8 +1332,8 @@ 'localBasePath' => __DIR__, 'targets' => [ 'desktop', 'mobile' ], ], - "ext.cirrus.explore-similar" => [ - 'scripts' => [ + "ext.cirrus.explore-similar" => [ + 'scripts' => [ 'resources/ext.cirrus.explore-similar.js', ], 'dependencies' => [ diff --git a/composer.json b/composer.json index b6cd741..35e60c5 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "require-dev": { "jakub-onderka/php-parallel-lint": "0.9.2", "jakub-onderka/php-console-highlighter": "0.3.2", - "mediawiki/mediawiki-codesniffer": "0.10.1" + "mediawiki/mediawiki-codesniffer": "0.11.1" }, "scripts": { "fix": "phpcbf", diff --git a/includes/BaseInterwikiResolver.php b/includes/BaseInterwikiResolver.php index 3389281..55402d6 100644 --- a/includes/BaseInterwikiResolver.php +++ b/includes/BaseInterwikiResolver.php @@ -17,7 +17,7 @@ */ public function getSisterProjectPrefixes() { $matrix = $this->getMatrix(); - return isset ( $matrix['sister_projects'] ) ? $matrix['sister_projects'] : []; + return isset( $matrix['sister_projects'] ) ? $matrix['sister_projects'] : []; } /** @@ -26,7 +26,7 @@ */ public function getInterwikiPrefix( $wikiId ) { $matrix = $this->getMatrix(); - return isset ( $matrix['prefixes_by_wiki'][$wikiId] ) ? $matrix['prefixes_by_wiki'][$wikiId] : null; + return isset( $matrix['prefixes_by_wiki'][$wikiId] ) ? $matrix['prefixes_by_wiki'][$wikiId] : null; } /** diff --git a/includes/BuildDocument/Completion/NaiveSubphrasesSuggestionsBuilder.php b/includes/BuildDocument/Completion/NaiveSubphrasesSuggestionsBuilder.php index 94eee82..21c4cb6 100644 --- a/includes/BuildDocument/Completion/NaiveSubphrasesSuggestionsBuilder.php +++ b/includes/BuildDocument/Completion/NaiveSubphrasesSuggestionsBuilder.php @@ -106,7 +106,7 @@ } $language = ""; - if ( isset ( $inputDoc[self::LANG_FIELD] ) ) { + if ( isset( $inputDoc[self::LANG_FIELD] ) ) { $language = $inputDoc[self::LANG_FIELD]; } diff --git a/includes/BuildDocument/Completion/SuggestBuilder.php b/includes/BuildDocument/Completion/SuggestBuilder.php index 3044d4e..e7b93bd 100644 --- a/includes/BuildDocument/Completion/SuggestBuilder.php +++ b/includes/BuildDocument/Completion/SuggestBuilder.php @@ -155,7 +155,7 @@ } // Build cross ns suggestions - if ( !empty ( $crossNsTitles ) ) { + if ( !empty( $crossNsTitles ) ) { $titles = []; foreach ( $crossNsTitles as $data ) { $titles[] = $data['title']; diff --git a/includes/CirrusSearch.php b/includes/CirrusSearch.php index cdfc8d4..bd05469 100644 --- a/includes/CirrusSearch.php +++ b/includes/CirrusSearch.php @@ -725,7 +725,7 @@ // It may require a change in core since ApiBase is // strict and won't allow unknown values to be set // here. - 'desc-message' => isset ( $profile['i18n_msg'] ) ? $profile['i18n_msg'] : null, + 'desc-message' => isset( $profile['i18n_msg'] ) ? $profile['i18n_msg'] : null, 'default' => $default, ]; } diff --git a/includes/CompletionRequestLog.php b/includes/CompletionRequestLog.php index e400b17..0e3ddbc 100644 --- a/includes/CompletionRequestLog.php +++ b/includes/CompletionRequestLog.php @@ -102,7 +102,7 @@ 'queryType' => $this->getQueryType(), 'index' => $this->index, 'elasticTookMs' => $this->getElasticTookMs(), - 'elasticTook2PassMs' => isset( $this->extra['elasticTook2PassMs'] ) ? $this->extra['elasticTook2PassMs'] : -1, + 'elasticTook2PassMs' => isset( $this->extra['elasticTook2PassMs'] ) ? $this->extra['elasticTook2PassMs'] : -1, 'hitsTotal' => $this->getTotalHits(), 'maxScore' => $this->maxScore, 'hitsReturned' => count( $this->hits ), diff --git a/includes/CompletionSuggester.php b/includes/CompletionSuggester.php index f9dbc49..58b9725 100644 --- a/includes/CompletionSuggester.php +++ b/includes/CompletionSuggester.php @@ -328,7 +328,7 @@ $variantIndex++; foreach ( $profiles as $name => $profile ) { $variantProfName = $name . '-variant-' . $variantIndex; - $profile = $this->buildVariantProfile( $profile, self::VARIANT_EXTRA_DISCOUNT/$variantIndex ); + $profile = $this->buildVariantProfile( $profile, self::VARIANT_EXTRA_DISCOUNT / $variantIndex ); $suggest = $this->buildSuggestQuery( $profile, $variant, $queryLen ); @@ -386,7 +386,7 @@ $targetTitle = $suggest['_source']['target_title']['title']; $targetTitleNS = $suggest['_source']['target_title']['namespace']; } - list ( $docId, $type ) = $this->decodeId( $suggest['_id'] ); + list( $docId, $type ) = $this->decodeId( $suggest['_id'] ); $score = $discount * $suggest['_score']; if ( !isset( $suggestionsByDocId[$docId] ) || $score > $suggestionsByDocId[$docId]->getScore() diff --git a/includes/DataSender.php b/includes/DataSender.php index 921fad7..a539d5f 100644 --- a/includes/DataSender.php +++ b/includes/DataSender.php @@ -246,7 +246,7 @@ $opRes = $bulk->getData()['result']; } } - if ( isset ( $updateStats[$opRes] ) ) { + if ( isset( $updateStats[$opRes] ) ) { $updateStats[$opRes]++; } else { $updateStats[$opRes] = 1; diff --git a/includes/Job/Job.php b/includes/Job/Job.php index a71f1a2..2b1fff2 100644 --- a/includes/Job/Job.php +++ b/includes/Job/Job.php @@ -184,7 +184,7 @@ * @return Connection[] indexed by cluster name */ protected function decideClusters() { - $cluster = isset ( $this->params['cluster'] ) ? $this->params['cluster'] : null; + $cluster = isset( $this->params['cluster'] ) ? $this->params['cluster'] : null; if ( $cluster === null ) { $conns = Connection::getWritableClusterConnections( $this->searchConfig ); } else { @@ -195,7 +195,7 @@ "Received {command} job for unwritable cluster {cluster}", [ 'command' => $this->command, - 'cluster' => $cluster + 'cluster' => $cluster ] ); // this job does not allow retries so we just need to throw an exception diff --git a/includes/LanguageDetector/ElasticSearch.php b/includes/LanguageDetector/ElasticSearch.php index 09011b8..50eb696 100644 --- a/includes/LanguageDetector/ElasticSearch.php +++ b/includes/LanguageDetector/ElasticSearch.php @@ -42,7 +42,7 @@ // FIXME: here I'm just winging it, should be something // that makes sense for multiple languages if ( count( $langs ) == 2 ) { - if ( $langs[0]['probability'] > 2*$langs[1]['probability'] ) { + if ( $langs[0]['probability'] > 2 * $langs[1]['probability'] ) { return $langs[0]['language']; } } diff --git a/includes/Maintenance/AnalysisConfigBuilder.php b/includes/Maintenance/AnalysisConfigBuilder.php index cc18b29..36d7ffa 100644 --- a/includes/Maintenance/AnalysisConfigBuilder.php +++ b/includes/Maintenance/AnalysisConfigBuilder.php @@ -186,7 +186,7 @@ * @return array|null the similarity config */ public function buildSimilarityConfig() { - if ( $this->similarity != null && isset ( $this->similarity['similarity'] ) ) { + if ( $this->similarity != null && isset( $this->similarity['similarity'] ) ) { return $this->similarity['similarity']; } return null; diff --git a/includes/Maintenance/ConfigUtils.php b/includes/Maintenance/ConfigUtils.php index d84ad84..13b97f7 100644 --- a/includes/Maintenance/ConfigUtils.php +++ b/includes/Maintenance/ConfigUtils.php @@ -246,7 +246,7 @@ while ( ( $startTime + $timeout ) > time() ) { try { $response = $this->getIndexHealth( $indexName ); - $status = isset ( $response['status'] ) ? $response['status'] : 'unknown'; + $status = isset( $response['status'] ) ? $response['status'] : 'unknown'; if ( $status == 'green' ) { $this->outputIndented( "\tGreen!\n" ); return true; diff --git a/includes/Maintenance/Reindexer.php b/includes/Maintenance/Reindexer.php index 50ba6f5..dccdc38 100644 --- a/includes/Maintenance/Reindexer.php +++ b/includes/Maintenance/Reindexer.php @@ -276,7 +276,7 @@ if ( $upper === 'all' ) { $upper = $nodes - 1; } - $expectedReplicas = min( max( $nodes - 1, $lower ), $upper ); + $expectedReplicas = min( max( $nodes - 1, $lower ), $upper ); $expectedActive = $this->shardCount * ( 1 + $expectedReplicas ); if ( $each === 0 || $active === $expectedActive ) { $this->outputIndented( "\t\tactive:$active/$expectedActive relocating:$relocating" . diff --git a/includes/Maintenance/SuggesterAnalysisConfigBuilder.php b/includes/Maintenance/SuggesterAnalysisConfigBuilder.php index 19ac9f1..6175a9a 100644 --- a/includes/Maintenance/SuggesterAnalysisConfigBuilder.php +++ b/includes/Maintenance/SuggesterAnalysisConfigBuilder.php @@ -282,7 +282,7 @@ /** @var string[] */ private static $stopwords = [ 'ar' => '_arabic_', - 'hy' => '_armenian_', + 'hy' => '_armenian_', 'eu' => '_basque_', 'pt-br' => '_brazilian_', 'bg' => '_bulgarian_', diff --git a/includes/Query/FullTextSimpleMatchQueryBuilder.php b/includes/Query/FullTextSimpleMatchQueryBuilder.php index 84f22f0..2b0f441 100644 --- a/includes/Query/FullTextSimpleMatchQueryBuilder.php +++ b/includes/Query/FullTextSimpleMatchQueryBuilder.php @@ -237,12 +237,12 @@ } foreach ( $dismaxQueries as $name => $queries ) { $dismax = new \Elastica\Query\DisMax(); - if ( isset ( $this->dismaxSettings[$name] ) ) { + if ( isset( $this->dismaxSettings[$name] ) ) { $settings = $this->dismaxSettings[$name]; - if ( isset ( $settings['tie_breaker'] ) ) { + if ( isset( $settings['tie_breaker'] ) ) { $dismax->setTieBreaker( $settings['tie_breaker'] ); } - if ( isset ( $settings['boost'] ) ) { + if ( isset( $settings['boost'] ) ) { $dismax->setBoost( $settings['boost'] ); } } diff --git a/includes/Query/PreferRecentFeature.php b/includes/Query/PreferRecentFeature.php index 8ec73e7..c6b27b2 100644 --- a/includes/Query/PreferRecentFeature.php +++ b/includes/Query/PreferRecentFeature.php @@ -49,7 +49,7 @@ '/prefer-recent:(1|0?(?:\.\d+)?)?(?:,(\d*\.?\d+))? ?/', function ( $matches ) use ( $context ) { $decay = isset( $matches[1] ) && strlen( $matches[1] ) > 0 - ? $decay = floatval( $matches[1] ) + ? $decay = floatval( $matches[1] ) : $decay = $this->unspecifiedDecay; $halfLife = isset( $matches[2] ) diff --git a/includes/Sanity/Checker.php b/includes/Sanity/Checker.php index a2e2097..8f8c364 100644 --- a/includes/Sanity/Checker.php +++ b/includes/Sanity/Checker.php @@ -115,7 +115,7 @@ $fromIndex = $pagesFromIndex[$docId]; } - if ( isset ( $pagesFromDb[$pageId] ) ) { + if ( isset( $pagesFromDb[$pageId] ) ) { $page = $pagesFromDb[$pageId]; $updated = $this->checkExisitingPage( $docId, $pageId, $page, $fromIndex ); } else { diff --git a/includes/Search/CrossProjectBlockScorer.php b/includes/Search/CrossProjectBlockScorer.php index f8ba4b8..657b628 100644 --- a/includes/Search/CrossProjectBlockScorer.php +++ b/includes/Search/CrossProjectBlockScorer.php @@ -53,7 +53,7 @@ if ( !isset( $profile['type'] ) ) { throw new \RuntimeException( "Invalid CrossProjectBlockScorer profile $profileName, 'type' must be set" ); } - return static::loadScorer( $profile['type'], isset ( $profile['settings'] ) ? $profile['settings'] : [] ); + return static::loadScorer( $profile['type'], isset( $profile['settings'] ) ? $profile['settings'] : [] ); } public static function loadScorer( $type, array $config ) { @@ -143,7 +143,7 @@ public function __construct( array $settings ) { parent::__construct( $settings ); foreach ( $settings as $type => $subSettings ) { - $weight = isset ( $subSettings['weight'] ) ? $subSettings['weight'] : 1; + $weight = isset( $subSettings['weight'] ) ? $subSettings['weight'] : 1; $scorerSettings = isset( $subSettings['settings'] ) ? $subSettings['settings'] : []; $scorer = CrossProjectBlockScorerFactory::loadScorer( $type, $scorerSettings ); $this->scorers[] = [ diff --git a/includes/Search/RescoreBuilders.php b/includes/Search/RescoreBuilders.php index 6981a6c..2650c52 100644 --- a/includes/Search/RescoreBuilders.php +++ b/includes/Search/RescoreBuilders.php @@ -362,7 +362,7 @@ * @suppress PhanTypeMismatchReturn phan does not understand hooks and by-ref parameters */ private function getImplementation( $func ) { - $weight = isset ( $func['weight'] ) ? $func['weight'] : 1; + $weight = isset( $func['weight'] ) ? $func['weight'] : 1; switch ( $func['type'] ) { case 'boostlinks': return new IncomingLinksFunctionScoreBuilder( $this->context, $weight ); @@ -716,7 +716,7 @@ */ public function __construct( SearchContext $context, $weight, $profile ) { parent::__construct( $context, $weight ); - if ( isset ( $profile['factor'] ) ) { + if ( isset( $profile['factor'] ) ) { $profile['factor'] = $this->getOverriddenFactor( $profile['factor'] ); } $this->profile = $profile; @@ -771,13 +771,13 @@ throw new InvalidRescoreProfileException( 'midpoint is mandatory' ); } - if ( isset ( $profile['scale'] ) ) { + if ( isset( $profile['scale'] ) ) { $this->scale = $this->getOverriddenFactor( $profile['scale'] ); } else { throw new InvalidRescoreProfileException( 'scale is mandatory' ); } - if ( isset ( $profile['field' ] ) ) { + if ( isset( $profile['field' ] ) ) { $this->field = $profile['field']; } else { throw new InvalidRescoreProfileException( 'field is mandatory' ); @@ -800,10 +800,10 @@ // N²x² + (2N - M)x + 1 = 0 // so we we use the quadratic formula: // (-(2N-M) + sqrt((2N-M)²-4N²)) / 2N² - if ( 4*$N >= $M ) { + if ( 4 * $N >= $M ) { throw new InvalidRescoreProfileException( 'The midpoint point cannot be higher than scale/4' ); } - return ( -( 2*$N - $M ) + sqrt( ( 2 * $N - $M ) * ( 2 * $N - $M ) - 4 * $N * $N ) ) / ( 2 * $N * $N ); + return ( -( 2 * $N - $M ) + sqrt( ( 2 * $N - $M ) * ( 2 * $N - $M ) - 4 * $N * $N ) ) / ( 2 * $N * $N ); } public function append( FunctionScore $functionScore ) { diff --git a/includes/Search/ResultsType.php b/includes/Search/ResultsType.php index 1566f3a..3aca5b5 100644 --- a/includes/Search/ResultsType.php +++ b/includes/Search/ResultsType.php @@ -380,7 +380,7 @@ unset( $text[ 'options' ][ 'skip_if_last_matched' ] ); } - $config = [ + $config = [ 'pre_tags' => [ Searcher::HIGHLIGHT_PRE ], 'post_tags' => [ Searcher::HIGHLIGHT_POST ], 'fields' => [], @@ -468,7 +468,7 @@ */ private function addMatchedFields( $fields ) { foreach ( array_keys( $fields ) as $name ) { - $fields[$name]['matched_fields'] = [ $name, "$name.plain" ]; + $fields[$name]['matched_fields'] = [ $name, "$name.plain" ]; } return $fields; } diff --git a/includes/Search/TitleHelper.php b/includes/Search/TitleHelper.php index 0c52f46..89691b6 100644 --- a/includes/Search/TitleHelper.php +++ b/includes/Search/TitleHelper.php @@ -76,7 +76,7 @@ * @return bool true if this result refers to an external Title */ public static function isExternal( \Elastica\Result $r ) { - if ( isset ( $r->wiki ) && $r->wiki !== wfWikiID() ) { + if ( isset( $r->wiki ) && $r->wiki !== wfWikiID() ) { return true; } // no wiki is suspicious, should we log a warning? @@ -89,7 +89,7 @@ * empty if local. */ public static function identifyInterwikiPrefix( $r ) { - if ( isset ( $r->wiki ) && $r->wiki !== wfWikiID() ) { + if ( isset( $r->wiki ) && $r->wiki !== wfWikiID() ) { return MediaWikiServices::getInstance() ->getService( InterwikiResolver::SERVICE ) ->getInterwikiPrefix( $r->wiki ); diff --git a/includes/UserTesting.php b/includes/UserTesting.php index 968d6ec..60ae1ce 100644 --- a/includes/UserTesting.php +++ b/includes/UserTesting.php @@ -228,7 +228,7 @@ // xor will retain the uniform distribution $sum = $sum ^ $dec; } - return $sum / ( ( 1<<16 )-1 ); + return $sum / ( ( 1 << 16 ) - 1 ); } /** diff --git a/maintenance/saneitizeJobs.php b/maintenance/saneitizeJobs.php index 5f3b982..4459f00 100644 --- a/maintenance/saneitizeJobs.php +++ b/maintenance/saneitizeJobs.php @@ -224,7 +224,7 @@ } private function pushJobs() { - $pushJobFreq = $this->getOption( 'refresh-freq', 2*3600 ); + $pushJobFreq = $this->getOption( 'refresh-freq', 2 * 3600 ); if ( !$this->getSearchConfig()->get( 'CirrusSearchSanityCheck' ) ) { $this->error( "Sanity check disabled, abandonning...\n", 1 ); } diff --git a/maintenance/updateSuggesterIndex.php b/maintenance/updateSuggesterIndex.php index 7df908a..dee3c86 100644 --- a/maintenance/updateSuggesterIndex.php +++ b/maintenance/updateSuggesterIndex.php @@ -232,7 +232,7 @@ if ( $this->getSearchConfig()->get( 'CirrusSearchCompletionSuggesterUseDefaultSort' ) ) { $extraBuilders[] = new DefaultSortSuggestionsBuilder(); } - $subPhrasesConfig = $this->getSearchConfig() + $subPhrasesConfig = $this->getSearchConfig() ->get( 'CirrusSearchCompletionSuggesterSubphrases' ); if ( $subPhrasesConfig['build'] ) { $extraBuilders[] = NaiveSubphrasesSuggestionsBuilder::create( $subPhrasesConfig ); diff --git a/profiles/CrossProjectBlockScorerProfiles.php b/profiles/CrossProjectBlockScorerProfiles.php index d433d1a..f9d1403 100644 --- a/profiles/CrossProjectBlockScorerProfiles.php +++ b/profiles/CrossProjectBlockScorerProfiles.php @@ -26,7 +26,7 @@ global $wgCirrusSearchCrossProjectBlockScoreProfiles, $wgCirrusSearchCrossProjectOrder; $profile = $request->getVal( 'cirrusCrossProjectOrderProfile' ); - if ( $profile != null && isset ( $wgCirrusSearchCrossProjectBlockScoreProfiles[$profile] ) ) { + if ( $profile != null && isset( $wgCirrusSearchCrossProjectBlockScoreProfiles[$profile] ) ) { $wgCirrusSearchCrossProjectOrder = $profile; } } diff --git a/profiles/FullTextQueryBuilderProfiles.php b/profiles/FullTextQueryBuilderProfiles.php index a89c161..5b234d4 100644 --- a/profiles/FullTextQueryBuilderProfiles.php +++ b/profiles/FullTextQueryBuilderProfiles.php @@ -26,7 +26,7 @@ global $wgCirrusSearchFullTextQueryBuilderProfiles, $wgCirrusSearchFullTextQueryBuilderProfile; $profile = $request->getVal( 'cirrusFTQBProfile' ); - if ( $profile != null && isset ( $wgCirrusSearchFullTextQueryBuilderProfiles[$profile] ) ) { + if ( $profile != null && isset( $wgCirrusSearchFullTextQueryBuilderProfiles[$profile] ) ) { $wgCirrusSearchFullTextQueryBuilderProfile = $profile; } } diff --git a/profiles/PhraseSuggesterProfiles.php b/profiles/PhraseSuggesterProfiles.php index 87a9f0f..09ee5ff 100644 --- a/profiles/PhraseSuggesterProfiles.php +++ b/profiles/PhraseSuggesterProfiles.php @@ -59,7 +59,7 @@ Util::overrideYesNo( $wgCirrusSearchPhraseSuggestSettings['collate'], $request, 'cirrusSuggCollate' ); $smoothing = $request->getVal( 'cirrusSuggSmoothing' ); - if ( isset ( $smoothing ) && in_array( $smoothing, $wgCirrusSearchPhraseSuggestAllowedSmoothingModel ) ) { + if ( isset( $smoothing ) && in_array( $smoothing, $wgCirrusSearchPhraseSuggestAllowedSmoothingModel ) ) { // We do not support linear_interpolation customization yet, should be added // later if proven useful. switch ( $smoothing ) { @@ -81,7 +81,7 @@ } // Custom discount for stupid_backoff smoothing model - if ( isset ( $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['stupid_backoff'] ) ) { + if ( isset( $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['stupid_backoff'] ) ) { $discount = $request->getVal( 'cirrusSuggDiscount' ); if ( is_numeric( $discount ) && $discount <= 1 && $discount >= 0 ) { $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['stupid_backoff']['discount'] = floatval( $discount ); @@ -89,7 +89,7 @@ } // Custom alpha for laplace smoothing model - if ( isset ( $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['laplace'] ) ) { + if ( isset( $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['laplace'] ) ) { $alpha = $request->getVal( 'cirrusSuggAlpha' ); if ( is_numeric( $alpha ) && $alpha <= 1 && $alpha >= 0 ) { $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['laplace']['alpha'] = floatval( $alpha ); @@ -97,10 +97,10 @@ } // Support deprecated settings - if ( isset ( $wgCirrusSearchPhraseSuggestConfidence ) ) { + if ( isset( $wgCirrusSearchPhraseSuggestConfidence ) ) { Util::overrideNumeric( $wgCirrusSearchPhraseSuggestConfidence, $request, 'cirrusSuggConfidence' ); } - if ( isset ( $wgCirrusSearchPhraseSuggestMaxErrors ) ) { + if ( isset( $wgCirrusSearchPhraseSuggestMaxErrors ) ) { Util::overrideNumeric( $wgCirrusSearchPhraseSuggestMaxErrors, $request, 'cirrusSuggMaxErrors', $wgCirrusSearchPhraseSuggestMaxErrorsHardLimit ); } @@ -147,7 +147,7 @@ if ( is_numeric( $v ) && $v >= 1 && $v <= $wgCirrusSearchPhraseSuggestMaxErrorsHardLimit ) { $wgCirrusSearchPhraseSuggestSettings['max_errors'] = floatval( $v ); // Support deprecated settings - if ( isset ( $wgCirrusSearchPhraseSuggestMaxErrors ) ) { + if ( isset( $wgCirrusSearchPhraseSuggestMaxErrors ) ) { $wgCirrusSearchPhraseSuggestMaxErrors = floatval( $v ); } } @@ -155,7 +155,7 @@ case 'confidence' : if ( is_numeric( $v ) && $v >= 0 ) { $wgCirrusSearchPhraseSuggestSettings['confidence'] = floatval( $v ); - if ( isset ( $wgCirrusSearchPhraseSuggestConfidence ) ) { + if ( isset( $wgCirrusSearchPhraseSuggestConfidence ) ) { $wgCirrusSearchPhraseSuggestConfidence = floatval( $v ); } } @@ -216,14 +216,14 @@ } // Apply smoothing model options, if none provided we'll use elasticsearch defaults - if ( isset ( $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['laplace'] ) && - isset ( $laplaceAlpha ) ) { + if ( isset( $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['laplace'] ) && + isset( $laplaceAlpha ) ) { $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['laplace'] = [ 'alpha' => $laplaceAlpha ]; } - if ( isset ( $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['stupid_backoff'] ) && - isset ( $stupidBackoffDiscount ) ) { + if ( isset( $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['stupid_backoff'] ) && + isset( $stupidBackoffDiscount ) ) { $wgCirrusSearchPhraseSuggestSettings['smoothing_model']['stupid_backoff'] = [ 'discount' => $stupidBackoffDiscount ]; diff --git a/profiles/RescoreProfiles.php b/profiles/RescoreProfiles.php index a713c61..3ff5bfa 100644 --- a/profiles/RescoreProfiles.php +++ b/profiles/RescoreProfiles.php @@ -43,7 +43,7 @@ $wgCirrusSearchRescoreProfiles; $profile = $request->getVal( 'cirrusRescoreProfile' ); - if ( $profile !== null && isset ( $wgCirrusSearchRescoreProfiles[$profile] ) ) { + if ( $profile !== null && isset( $wgCirrusSearchRescoreProfiles[$profile] ) ) { $wgCirrusSearchRescoreProfile = $profile; } } diff --git a/profiles/SaneitizeProfiles.php b/profiles/SaneitizeProfiles.php index c5a37b6..54e5003 100644 --- a/profiles/SaneitizeProfiles.php +++ b/profiles/SaneitizeProfiles.php @@ -55,7 +55,7 @@ // Minimum time to wait between loops in seconds // Default: 2 weeks // Usefull to not restart a loop too frequently on small wikis - 'min_loop_duration' => 2*7*24*3600, + 'min_loop_duration' => 2 * 7 * 24 * 3600, ], // Loop in 16 days for 99k ids, 0.006 jobs/sec, with 18% ids wrong // it's 0.0125 updates/sec per cluster @@ -66,7 +66,7 @@ 'max_checker_jobs' => 50, 'update_jobs_max_pressure' => 100, 'checker_job_max_time' => 60, - 'min_loop_duration' => 2*7*24*3600, + 'min_loop_duration' => 2 * 7 * 24 * 3600, ], // Loop in 15 days for 920k ids, 0.06 jobs/sec, with 18% ids wrong // it's 0.125 updates/sec per cluster @@ -77,7 +77,7 @@ 'max_checker_jobs' => 500, 'update_jobs_max_pressure' => 250, 'checker_job_max_time' => 60, - 'min_loop_duration' => 2*7*24*3600, + 'min_loop_duration' => 2 * 7 * 24 * 3600, ], // Loop in 17 days for 10m ids, 0.13 jobs/sec, with 18% ids wrong // it's 1.25 updates/sec per cluster @@ -88,7 +88,7 @@ 'max_checker_jobs' => 1000, 'update_jobs_max_pressure' => 500, 'checker_job_max_time' => 60, - 'min_loop_duration' => 2*7*24*3600, + 'min_loop_duration' => 2 * 7 * 24 * 3600, ], // Loop in 15 days for 27m ids, 0.20 jobs/sec, with 18% ids wrong // it's 3.75 updates/sec per cluster @@ -99,7 +99,7 @@ 'max_checker_jobs' => 1500, 'update_jobs_max_pressure' => 750, 'checker_job_max_time' => 60, - 'min_loop_duration' => 2*7*24*3600, + 'min_loop_duration' => 2 * 7 * 24 * 3600, ], // Loop in 16 days for 50m ids, 0.34 jobs/sec, with 18% ids wrong // it's 6 updates/sec per cluster @@ -110,6 +110,6 @@ 'max_checker_jobs' => 2500, 'update_jobs_max_pressure' => 1000, 'checker_job_max_time' => 60, - 'min_loop_duration' => 2*7*24*3600, + 'min_loop_duration' => 2 * 7 * 24 * 3600, ], ]; diff --git a/tests/unit/CompletionSuggesterTest.php b/tests/unit/CompletionSuggesterTest.php index e741755..3047b43 100644 --- a/tests/unit/CompletionSuggesterTest.php +++ b/tests/unit/CompletionSuggesterTest.php @@ -140,7 +140,7 @@ 'plain-variant-2' => [ 'field' => 'suggest', 'min_query_len' => 0, - 'discount' => 1.0 * ( CompletionSuggester::VARIANT_EXTRA_DISCOUNT/2 ), + 'discount' => 1.0 * ( CompletionSuggester::VARIANT_EXTRA_DISCOUNT / 2 ), 'fetch_limit_factor' => 2, 'fallback' => true, // extra key added, not used for now ] @@ -256,7 +256,7 @@ $score = $max - $i; $suggestions[] = [ '_id' => $i.'t', - 'text'=> "Title$i", + 'text' => "Title$i", '_score' => $score, ]; } @@ -286,7 +286,7 @@ ], 'Reach ES limit' => [ $resp, - 5, $max-3, 'Title198', 'Title200', 3, 300 + 5, $max - 3, 'Title198', 'Title200', 3, 300 ], 'Reach Cirrus limit' => [ $resp, diff --git a/tests/unit/Maintenance/AnalysisConfigBuilderTest.php b/tests/unit/Maintenance/AnalysisConfigBuilderTest.php index c3abbe5..01845e1 100644 --- a/tests/unit/Maintenance/AnalysisConfigBuilderTest.php +++ b/tests/unit/Maintenance/AnalysisConfigBuilderTest.php @@ -22,7 +22,7 @@ if ( isset( $expected['filter'] ) ) { $this->assertEquals( $expected['filter'], $result['filter'] ); } else { - $this->assertFalse( isset ( $result['filter'] ) ); + $this->assertFalse( isset( $result['filter'] ) ); } } diff --git a/tests/unit/RequestLoggerTest.php b/tests/unit/RequestLoggerTest.php index dcf3659..f1079f4 100644 --- a/tests/unit/RequestLoggerTest.php +++ b/tests/unit/RequestLoggerTest.php @@ -60,9 +60,9 @@ private function runFixture( array $query, $responses, $expectedLogs, \Closure $test ) { if ( is_string( $responses ) ) { - list ( $loggers, $config, $connection, $transport ) = $this->buildDependencies( null ); + list( $loggers, $config, $connection, $transport ) = $this->buildDependencies( null ); } else { - list ( $loggers, $config, $connection, $transport ) = $this->buildDependencies( $responses ); + list( $loggers, $config, $connection, $transport ) = $this->buildDependencies( $responses ); } // Disable opportunistic execution of deferred updates @@ -108,7 +108,7 @@ public function testRequestLogging( array $query, $responses = null, $expectedLogs ) { switch ( $query['type'] ) { case 'fulltext': - $work = function ( $config, $connection ) use ( $query ) { + $work = function ( $config, $connection ) use ( $query ) { $offset = isset( $query['offset'] ) ? $query['offset'] : 0; $limit = isset( $query['limit'] ) ? $query['limit'] : 20; $namespaces = isset( $query['namespaces'] ) ? $query['namespaces'] : null; diff --git a/tests/unit/SuggestBuilderTest.php b/tests/unit/SuggestBuilderTest.php index 562b70b..d142dbd 100644 --- a/tests/unit/SuggestBuilderTest.php +++ b/tests/unit/SuggestBuilderTest.php @@ -301,7 +301,7 @@ 'namespace' => 0, 'redirect' => [ [ 'title' => 'UN/LOCODE:DEULM', 'namespace' => 0 ], - [ 'title'=> 'Ulm, Germany', 'namespace' => 0 ], + [ 'title' => 'Ulm, Germany', 'namespace' => 0 ], [ 'title' => "Ulm displaced persons camp", 'namespace' => 0 ], [ 'title' => "Söflingen", 'namespace' => 0 ], [ 'title' => "Should be ignored", 'namespace' => 1 ], diff --git a/tests/unit/SuggestScoringTest.php b/tests/unit/SuggestScoringTest.php index 6b7c6ec..22ade31 100644 --- a/tests/unit/SuggestScoringTest.php +++ b/tests/unit/SuggestScoringTest.php @@ -103,8 +103,8 @@ $res2 = $qs->boost( $score2, $boost ); $this->assertGreaterThan( $res1, $res2, "A boost cannot 'overboost' a score" ); - $res1 = $qs->boost( $score1, (float)1/(float)$boost ); - $res2 = $qs->boost( $score2, (float)1/(float)$boost ); + $res1 = $qs->boost( $score1, (float)1 / (float)$boost ); + $res2 = $qs->boost( $score2, (float)1 / (float)$boost ); $this->assertGreaterThan( $res1, $res2, "A boost cannot 'overboost' a score" ); } @@ -113,7 +113,7 @@ $this->assertEquals( $res, 1, "When boost is 1 the score remains unchanged." ); $res = $qs->boost( 1, 0 ); $this->assertEquals( $res, 0.5, "When boost is 0 the score is divided by 2." ); - $res = $qs->boost( 1, 2^31-1 ); + $res = $qs->boost( 1, 2 ^ 31 - 1 ); $this->assertEquals( $res, 1, "When score is 1 and boost is very high the score is still 1." ); $res = $qs->boost( 0, 0 ); @@ -238,7 +238,7 @@ for ( $i = 0; $i < 1000; $i++ ) { $page = [ - 'incoming_links' => mt_rand( 0, 2^31-1 ), + 'incoming_links' => mt_rand( 0, 2 ^ 31 - 1 ), 'external_link' => array_fill( 0, mt_rand( 1, 2000 ), null ), 'text_bytes' => mt_rand( 1, 400000 ), 'heading' => array_fill( 0, mt_rand( 1, 1000 ), null ), @@ -304,7 +304,7 @@ } public function testRobustness() { - $templates = [ 'Good' => 2, 'Bad' => 0.5 ]; + $templates = [ 'Good' => 2, 'Bad' => 0.5 ]; $all_templates = array_keys( $templates ); $all_templates += [ 'Foo', 'Bar' ]; for ( $i = 0; $i < 5000; $i++ ) { diff --git a/tests/unit/UserTestingTest.php b/tests/unit/UserTestingTest.php index 956676b..6909afb 100644 --- a/tests/unit/UserTestingTest.php +++ b/tests/unit/UserTestingTest.php @@ -169,7 +169,7 @@ 'trigger' => 'hi there', ], 'b' => [ - 'trigger' => 'or this one', + 'trigger' => 'or this one', ], ], ], -- To view, visit https://gerrit.wikimedia.org/r/372114 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I89e6b5f61e0ef048b7bcfba0a88c03c7db352c2c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: Legoktm <lego...@member.fsf.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits