Ladsgroup has uploaded a new change for review.
https://gerrit.wikimedia.org/r/263184
Change subject: Add onOldChangesListRecentChangesLine hook
......................................................................
Add onOldChangesListRecentChangesLine hook
It allows us enable ORES for watchlist and old-style RC.
This hook is a mess by design, I think it's the most robust way
to implement it.
Tested and it was okay
Bug: T122535
Bug: T122766
Change-Id: I1921395d622cec0b0ac7ad4b10c74012ae6d4ef5
---
M extension.json
M includes/Hooks.php
2 files changed, 48 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES
refs/changes/84/263184/1
diff --git a/extension.json b/extension.json
index 6b057ab..aee13d5 100644
--- a/extension.json
+++ b/extension.json
@@ -32,6 +32,9 @@
],
"EnhancedChangesListModifyLineData": [
"ORES\\Hooks::onEnhancedChangesListModifyLineData"
+ ],
+ "OldChangesListRecentChangesLine": [
+ "ORES\\Hooks::onOldChangesListRecentChangesLine"
]
},
"ResourceFileModulePaths": {
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 6fe9992..cfa7fe8 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -9,7 +9,7 @@
use Html;
use JobQueueGroup;
use MediaWiki\Logger\LoggerFactory;
-use OldChangesList;
+use ChangesList;
use RCCacheEntry;
use RecentChange;
@@ -17,7 +17,6 @@
* TODO:
* - Fix mw-core EnhancedChangesList::recentChangesBlockGroup to rollup
* extension recentChangesFlags into the top-level grouped line.
- * - Fix mw-core "old" recent changes view to respect recentChangesFlags.
*/
class Hooks {
/**
@@ -41,6 +40,7 @@
'revid' => $rc->getAttribute( 'rc_this_oldid' ),
) );
JobQueueGroup::singleton()->push( $job );
+ $logger->debug( 'Job pushed...' );
}
return true;
@@ -126,14 +126,56 @@
}
/**
+ * Hook for formatting recent changes linkes
+ * @see
https://www.mediawiki.org/wiki/Manual:Hooks/OldChangesListRecentChangesLine
+ *
+ * @since 0.2
+ *
+ * @param ChangesList $changesList
+ * @param string $s
+ * @param RecentChange $rc
+ * @param string[] &$classes
+ *
+ * @return bool
+ */
+ public static function onOldChangesListRecentChangesLine( ChangesList
&$changesList, &$s,
+ $rc, &$classes = array() ) {
+ $damaging = self::getScoreRecentChangesList($rc);
+ if ($damaging) {
+ $seperator = ' <span class="mw-changeslist-separator">.
.</span> ';
+ if ( strpos( $s, $seperator ) === false ) {
+ return false;
+ }
+ $classes[] = 'damaging';
+ $parts = explode($seperator, $s);
+ $parts[1] = $changesList->flag('damaging') . $parts[1];
+ $s = implode($seperator, $parts);
+ }
+
+ return true;
+ }
+
+ /**
* Internal helper to label matching rows
*/
protected static function processRecentChangesList( RCCacheEntry
$rcObj, array &$data ) {
+ $damaging = self::getScoreRecentChangesList($rcObj);
+ if ( $damaging ) {
+ $data['recentChangesFlags']['damaging'] = true;
+ }
+ }
+
+ /**
+ * Another internal helper to label matching rows
+ */
+ protected static function getScoreRecentChangesList( $rcObj) {
global $wgOresDamagingThreshold;
$score = $rcObj->getAttribute( 'ores_probability' );
if ( $score && $score >= $wgOresDamagingThreshold ) {
- $data['recentChangesFlags']['damaging'] = true;
+ return true;
+ } else {
+ return false;
}
}
}
--
To view, visit https://gerrit.wikimedia.org/r/263184
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1921395d622cec0b0ac7ad4b10c74012ae6d4ef5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits