Anomie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/86707
Change subject: Reset $wgTitle in AbuseFilter::filterAction()
......................................................................
Reset $wgTitle in AbuseFilter::filterAction()
If AbuseFilter::filterAction changed $wgTitle, we need to reset it back
to the old value before returning.
And for good measure, we also need to check the main RequestContext to
make sure it didn't cache the bogus $wgTitle on us.
Bug: 53498
Change-Id: I4d706a1ee07f0b171f98e7d558d7be27e6759614
---
M AbuseFilter.class.php
1 file changed, 42 insertions(+), 29 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter
refs/changes/07/86707/1
diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php
index 8cfed93..f41cbc7 100644
--- a/AbuseFilter.class.php
+++ b/AbuseFilter.class.php
@@ -837,6 +837,10 @@
wfProfileIn( __METHOD__ );
+ $context = RequestContext::getMain();
+ $oldContextTitle = $context->getTitle();
+
+ $oldWgTitle = $wgTitle;
if ( !$wgTitle ) {
$wgTitle = SpecialPage::getTitleFor( 'AbuseFilter' );
}
@@ -854,39 +858,48 @@
$matched_filters = array_keys( array_filter( $filter_matched )
);
- // Short-cut any remaining code if no filters were hit.
if ( count( $matched_filters ) == 0 ) {
- wfProfileOut( __METHOD__ );
- return Status::newGood();
+ $status = Status::newGood();
+ } else {
+ wfProfileIn( __METHOD__ . '-block' );
+
+ $status = self::executeFilterActions(
+ $matched_filters, $title, $vars );
+
+ $actions_taken = $status->value; // getValue() was
introduced only in 1.20
+
+ $action = $vars->getVar( 'ACTION' )->toString();
+
+ // Create a template
+ $log_template = array(
+ 'afl_user' => $wgUser->getId(),
+ 'afl_user_text' => $wgUser->getName(),
+ 'afl_timestamp' => $dbr->timestamp(
wfTimestampNow() ),
+ 'afl_namespace' => $title->getNamespace(),
+ 'afl_title' => $title->getDBkey(),
+ 'afl_ip' => $wgRequest->getIP()
+ );
+
+ // Hack to avoid revealing IPs of people creating
accounts
+ if ( !$wgUser->getId() && ( $action == 'createaccount'
|| $action == 'autocreateaccount' ) ) {
+ $log_template['afl_user_text'] = $vars->getVar(
'accountname' )->toString();
+ }
+
+ self::addLogEntries( $actions_taken, $log_template,
$action, $vars, $group );
+
+ wfProfileOut( __METHOD__ . '-block' );
}
- wfProfileIn( __METHOD__ . '-block' );
-
- $status = self::executeFilterActions(
- $matched_filters, $title, $vars );
-
- $actions_taken = $status->value; // getValue() was introduced
only in 1.20
-
- $action = $vars->getVar( 'ACTION' )->toString();
-
- // Create a template
- $log_template = array(
- 'afl_user' => $wgUser->getId(),
- 'afl_user_text' => $wgUser->getName(),
- 'afl_timestamp' => $dbr->timestamp( wfTimestampNow() ),
- 'afl_namespace' => $title->getNamespace(),
- 'afl_title' => $title->getDBkey(),
- 'afl_ip' => $wgRequest->getIP()
- );
-
- // Hack to avoid revealing IPs of people creating accounts
- if ( !$wgUser->getId() && ( $action == 'createaccount' ||
$action == 'autocreateaccount' ) ) {
- $log_template['afl_user_text'] = $vars->getVar(
'accountname' )->toString();
+ // Bug 53498: If we screwed around with $wgTitle, reset it so
the title
+ // is correctly picked up from the request later. Do the same
for the
+ // main RequestContext, because that might have picked up the
bogus
+ // title from $wgTitle.
+ if ( $wgTitle !== $oldWgTitle ) {
+ $wgTitle = $oldWgTitle;
}
-
- self::addLogEntries( $actions_taken, $log_template, $action,
$vars, $group );
-
- wfProfileOut( __METHOD__ . '-block' );
+ if ( $context->getTitle() !== $oldContextTitle ) {
+ $context->setTitle( $oldContextTitle );
+ }
wfProfileOut( __METHOD__ );
--
To view, visit https://gerrit.wikimedia.org/r/86707
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4d706a1ee07f0b171f98e7d558d7be27e6759614
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits