jenkins-bot has submitted this change and it was merged.
Change subject: Enable filtering by action on Special:Log
......................................................................
Enable filtering by action on Special:Log
This allows logs to be filtered by log actions, provided
the log type has been set as such in config.
There is an index for log actions so the queries should
be performant enough (already used by API).
Extensions can use $wgActionFilteredLogs to filter their
own logs in the same way.
Bug: T20954
Change-Id: I6a61175f9a111c03d15b4d41751c818e3a411ff6
---
M includes/DefaultSettings.php
M includes/logging/LogEventsList.php
M includes/specials/SpecialLog.php
M languages/i18n/en.json
M languages/i18n/qqq.json
5 files changed, 137 insertions(+), 4 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index c04602c..3b2c697 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -7236,6 +7236,37 @@
];
/**
+ * List of log types that can be filtered by action types
+ *
+ * To each action is associated the list of log_action
+ * subtypes to search for, usually one, but not necessarily so
+ * Extensions may append to this array
+ * @since 1.27
+ */
+$wgActionFilteredLogs = [
+ 'block' => [
+ 'block' => [ 'block' ],
+ 'reblock' => [ 'reblock' ],
+ 'unblock' => [ 'unblock' ],
+ ],
+ 'delete' => [
+ 'delete' => [ 'delete' ],
+ 'restore' => [ 'restore' ],
+ 'event' => [ 'event' ],
+ 'revision' => [ 'revision' ],
+ ],
+ 'protect' => [
+ 'protect' => [ 'protect' ],
+ 'modify' => [ 'modify' ],
+ 'unprotect' => [ 'unprotect' ],
+ ],
+ 'upload' => [
+ 'upload' => [ 'upload' ],
+ 'overwrite' => [ 'overwrite' ],
+ ],
+];
+
+/**
* Maintain a log of newusers at Log/newusers?
*/
$wgNewUserLog = true;
diff --git a/includes/logging/LogEventsList.php
b/includes/logging/LogEventsList.php
index c96c0db..9d39d54 100644
--- a/includes/logging/LogEventsList.php
+++ b/includes/logging/LogEventsList.php
@@ -41,6 +41,11 @@
protected $showTagEditUI;
/**
+ * @var array
+ */
+ protected $allowedActions = null;
+
+ /**
* Constructor.
* The first two parameters used to be $skin and $out, but now only a
context
* is needed, that's why there's a second unused parameter.
@@ -74,9 +79,10 @@
* @param int $month Month
* @param array $filter
* @param string $tagFilter Tag to select by default
+ * @param string $action
*/
public function showOptions( $types = [], $user = '', $page = '',
$pattern = '', $year = 0,
- $month = 0, $filter = null, $tagFilter = ''
+ $month = 0, $filter = null, $tagFilter = '', $action = null
) {
global $wgScript, $wgMiserMode;
@@ -111,6 +117,11 @@
// Filter links
if ( $filter ) {
$html .= Xml::tags( 'p', null, $this->getFilterLinks(
$filter ) );
+ }
+
+ // Action filter
+ if ( $action !== null ) {
+ $html .= Xml::tags( 'p', null,
$this->getActionSelector( $types, $action ) );
}
// Submit button
@@ -288,6 +299,41 @@
}
/**
+ * Drop down menu for selection of actions that can be used to filter
the log
+ * @param array $types
+ * @param string $action
+ * @return string
+ * @since 1.27
+ */
+ private function getActionSelector( $types, $action ) {
+ if ( $this->allowedActions === null || !count(
$this->allowedActions ) ) {
+ return '';
+ }
+ $html = '';
+ $html .= xml::label( wfMessage( 'log-action-filter-' .
$types[0] )->text(),
+ 'action-filter-' .$types[0] ) . "\n";
+ $select = new XmlSelect( 'subtype' );
+ $select->addOption( wfMessage( 'log-action-filter-all'
)->text(), '' );
+ foreach ( $this->allowedActions as $value ) {
+ $msgKey = 'log-action-filter-' . $types[0] . '-' .
$value;
+ $select->addOption( wfMessage( $msgKey )->text(),
$value );
+ }
+ $select->setDefault( $action );
+ $html .= $select->getHtml();
+ return $html;
+ }
+
+ /**
+ * Sets the action types allowed for log filtering
+ * To one action type may correspond several log_actions
+ * @param array $actions
+ * @since 1.27
+ */
+ public function setAllowedActions( $actions ) {
+ $this->allowedActions = $actions;
+ }
+
+ /**
* @return string
*/
public function beginLogEventsList() {
diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php
index d4c7c6a..7132207 100644
--- a/includes/specials/SpecialLog.php
+++ b/includes/specials/SpecialLog.php
@@ -49,6 +49,7 @@
$opts->add( 'offset', '' );
$opts->add( 'dir', '' );
$opts->add( 'offender', '' );
+ $opts->add( 'subtype', '' );
// Set values
$opts->fetchValuesFromRequest( $this->getRequest() );
@@ -167,6 +168,26 @@
null,
LogEventsList::USE_CHECKBOXES
);
+
+ $action = '';
+ // Allow to filter the log by actions
+ $type = $opts->getValue( 'type' );
+ if ( $type !== '' ) {
+ $actions = $this->getConfig()->get(
'ActionFilteredLogs' );
+ if ( isset( $actions[$type] ) ) {
+ // log type can be filtered by actions
+ $loglist->setAllowedActions( array_keys(
$actions[$type] ) );
+ $action = $opts->getValue( 'subtype' );
+ if ( $action !== '' && isset(
$actions[$type][$action] ) ) {
+ // add condition to query
+ $extraConds['log_action'] =
$actions[$type][$action];
+ } else {
+ // no action or invalid action
+ $action = '';
+ }
+ }
+ }
+
$pager = new LogPager(
$loglist,
$opts->getValue( 'type' ),
@@ -195,7 +216,8 @@
$pager->getYear(),
$pager->getMonth(),
$pager->getFilterParams(),
- $opts->getValue( 'tagfilter' )
+ $opts->getValue( 'tagfilter' ),
+ $action
);
# Insert list
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 5b32b97..5ae694e 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -4029,5 +4029,22 @@
"sessionprovider-generic": "$1 sessions",
"sessionprovider-mediawiki-session-cookiesessionprovider":
"cookie-based sessions",
"sessionprovider-nocookies": "Cookies may be disabled. Ensure you have
cookies enabled and start again.",
- "randomrootpage": "Random root page"
+ "randomrootpage": "Random root page",
+ "log-action-filter-block": "Type of block:",
+ "log-action-filter-delete": "Type of deletion:",
+ "log-action-filter-protect": "Type of protection:",
+ "log-action-filter-upload": "Type of upload:",
+ "log-action-filter-all": "All",
+ "log-action-filter-block-block": "Block",
+ "log-action-filter-block-reblock": "Block modification",
+ "log-action-filter-block-unblock": "Unblock",
+ "log-action-filter-delete-delete": "Page deletion",
+ "log-action-filter-delete-restore": "Page undeletion",
+ "log-action-filter-delete-event": "Log deletion",
+ "log-action-filter-delete-revision": "Revision deletion",
+ "log-action-filter-protect-protect": "Protection",
+ "log-action-filter-protect-modify": "Protection modification",
+ "log-action-filter-protect-unprotect": "Unprotection",
+ "log-action-filter-upload-upload": "New upload",
+ "log-action-filter-upload-overwrite": "Reupload"
}
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index ae2eca4..1c144dd 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -4205,5 +4205,22 @@
"sessionprovider-generic": "Used to create a generic session type
description when one isn't provided via the proper message. Should be phrased
to make sense when added to a message such as
{{msg-mw|cannotloginnow-text}}.\n\nParameters:\n* $1 - PHP classname.",
"sessionprovider-mediawiki-session-cookiesessionprovider": "Description
of the sessions provided by the CookieSessionProvider class, which use HTTP
cookies. Should be phrased to make sense when added to a message such as
{{msg-mw|cannotloginnow-text}}.",
"sessionprovider-nocookies": "Used to inform the user that sessions may
be missing due to lack of cookies.",
- "randomrootpage": "{{doc-special|RandomRootPage}}"
+ "randomrootpage": "{{doc-special|RandomRootPage}}",
+ "log-action-filter-block": "Which type of action to filter for in this
log",
+ "log-action-filter-delete": "Which type of action to filter for in this
log",
+ "log-action-filter-protect": "Which type of action to filter for in
this log",
+ "log-action-filter-upload": "Which type of action to filter for in this
log",
+ "log-action-filter-all": "All types of action are allowed",
+ "log-action-filter-block-block": "Action to filter for in this log",
+ "log-action-filter-block-reblock": "Action to filter for in this log",
+ "log-action-filter-block-unblock": "Action to filter for in this log",
+ "log-action-filter-delete-delete": "Action to filter for in this log",
+ "log-action-filter-delete-restore": "Action to filter for in this log",
+ "log-action-filter-delete-event": "Action to filter for in this log",
+ "log-action-filter-delete-revision": "Action to filter for in this log",
+ "log-action-filter-protect-protect": "Action to filter for in this log",
+ "log-action-filter-protect-modify": "Action to filter for in this log",
+ "log-action-filter-protect-unprotect": "Action to filter for in this
log",
+ "log-action-filter-upload-upload": "Action to filter for in this log",
+ "log-action-filter-upload-overwrite": "Action to filter for in this log"
}
--
To view, visit https://gerrit.wikimedia.org/r/253072
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6a61175f9a111c03d15b4d41751c818e3a411ff6
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Cenarium <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Cenarium <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Luke081515 <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits