Cenarium has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/326156 )
Change subject: Defer changes matching specified thresholds [WIP] ...................................................................... Defer changes matching specified thresholds [WIP] This is a demo of how ORES could defer changes matching thresholds specified by admins. These thresholds have a minimum enforced in the config to protect against mistakes, compomised accounts, etc. Change-Id: I9e1353aa18e06807ee5c26ba587ae902fc04fb49 Depends-On: I6dce48af58bdbe4b684c0bf3a825a428b4a24f43 --- M extension.json M i18n/en.json M i18n/qqq.json M includes/FetchScoreJob.php M includes/Hooks.php 5 files changed, 31 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES refs/changes/56/326156/1 diff --git a/extension.json b/extension.json index d9e7428..5724137 100644 --- a/extension.json +++ b/extension.json @@ -157,6 +157,8 @@ "OresWikiId": null, "OresRevisionsPerBatch": 50, "OresAPIMaxBatchJobs": 100, + "OresPassiveDeferThreshold": 1, + "OresActiveDeferThreshold": 1, "RecentChangesFlags": { "damaging": { "letter": "ores-damaging-letter", diff --git a/i18n/en.json b/i18n/en.json index ade6379..c60464c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -25,5 +25,8 @@ "apihelp-query+recentchanges-paramvalue-prop-oresscores": "Adds ORES scores for the entry.", "apihelp-query+watchlist-paramvalue-prop-oresscores": "Adds ORES scores for the edit.", "apihelp-query+usercontribs-paramvalue-prop-oresscores": "Adds ORES scores for the edit.", - "ores-api-show-note": "When using <kbd>oresreview</kbd> or <kbd>!oresreview</kbd>, revisions without a score (e.g. very old revisions) are considered as not needing review even if they would need review if scored." + "ores-api-show-note": "When using <kbd>oresreview</kbd> or <kbd>!oresreview</kbd>, revisions without a score (e.g. very old revisions) are considered as not needing review even if they would need review if scored.", + "ores-deferredchanges-summary": "[[mw:Extension:ORES|ORES]]: damaging with a probability of $1", + "flaggedrevs-defer-ores": "mw:Extension:ORES", + "notification-link-text-flaggedrevs-deferred-ores": "ORES", } diff --git a/i18n/qqq.json b/i18n/qqq.json index 7ccb230..00554d7 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -28,5 +28,8 @@ "apihelp-query+recentchanges-paramvalue-prop-oresscores": "{{doc-apihelp-paramvalue|query+recentchanges|prop|oresscores}}", "apihelp-query+watchlist-paramvalue-prop-oresscores": "{{doc-apihelp-paramvalue|query+watchlist|prop|oresscores}}", "apihelp-query+usercontribs-paramvalue-prop-oresscores": "{{doc-apihelp-paramvalue|query+usercontribs|prop|oresscores}}", - "ores-api-show-note": "{{doc-apihelp-param|description=additional text for <var>xxshow</var> parameters.|noseealso=1}}" + "ores-api-show-note": "{{doc-apihelp-param|description=additional text for <var>xxshow</var> parameters.|noseealso=1}}", + "ores-deferredchanges-summary": "Log comment for a deferral by ORES", + "flaggedrevs-defer-ores": "Link to page on ORES in defer notification", + "notification-link-text-flaggedrevs-deferred-ores": "Label for link to page on ORES in defer notification", } diff --git a/includes/FetchScoreJob.php b/includes/FetchScoreJob.php index f18b255..f874596 100644 --- a/includes/FetchScoreJob.php +++ b/includes/FetchScoreJob.php @@ -60,6 +60,26 @@ } ); $cache->storeScores( $scores ); if ( $success === true ) { + global $wgOresModels, $wgFlaggedRevsDeferral, $wgOresPassiveDeferThreshold, + $wgOresActiveDeferThreshold; + if ( class_exists( '\FlaggedRevs' ) && $wgOresModels['damaging'] && $wgFlaggedRevsDeferral ) { + $damagingScore = $scores[$this->params['revid']]['damaging']['probability']['true']; + $passiveThreshold = max( + wfMessage( 'deferredchanges-ores-passivethreshold' )->inContentLanguage()->text(), + $wgOresPassiveDeferThreshold + ); + if ( $damagingScore > $passiveThreshold ) { + $article = \FlaggableWikiPage::getTitleInstance( $this->title ); + $activeThreshold = max( + wfMessage( 'deferredchanges-ores-activethreshold' )->inContentLanguage()->text(), + $wgOresActiveDeferThreshold + ); + $override = ( $damagingScore > $activeThreshold ); + $summary = wfMessage( 'ores-deferredchanges-summary' )->inContentLanguage() + ->params( $damagingScore )->text(); + $article->defer( $override, $this->params['user'], null, $summary, 'ores' ); + } + } $logger->debug( 'Stored scores: ' . json_encode( $scores ) ); } return $success; diff --git a/includes/Hooks.php b/includes/Hooks.php index 979ad18..4f0de61 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -71,6 +71,7 @@ ] ); $job = new FetchScoreJob( $rc->getTitle(), [ 'revid' => $revid, + 'user' => $rc->getPerformer(), 'extra_params' => [ 'precache' => 'true' ], ] ); JobQueueGroup::singleton()->push( $job ); -- To view, visit https://gerrit.wikimedia.org/r/326156 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9e1353aa18e06807ee5c26ba587ae902fc04fb49 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ORES Gerrit-Branch: master Gerrit-Owner: Cenarium <cenarium.sy...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits