Yurik has uploaded a new change for review.
https://gerrit.wikimedia.org/r/149296
Change subject: Logging opera-detection cleanup
......................................................................
Logging opera-detection cleanup
Change-Id: Id056974a0157720035511e6874bb1918fc264cca
---
M includes/PageRendering.php
1 file changed, 26 insertions(+), 26 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroBanner
refs/changes/96/149296/1
diff --git a/includes/PageRendering.php b/includes/PageRendering.php
index a1ce08d..86848e1 100644
--- a/includes/PageRendering.php
+++ b/includes/PageRendering.php
@@ -596,7 +596,7 @@
list( $lang, $subdomain, $project ) =
$this->getWikiInfo();
$this->config->setContext(
$ipset,
- $this->getRequest()->getHeader(
'X-Forwarded-By' ),
+ $this->getRequest()->getHeader(
'X-FORWARDED-BY' ),
$this->getRequest()->getProtocol() ===
'https',
$subdomain . '.' . $project, $lang,
$this->getRequest()->getCheck( 'X-CS' ) );
}
@@ -897,7 +897,7 @@
$dbg[] = $request->getIP();
}
$host = implode( '.', $this->getWikiInfo() );
- $dbg[] = ( $request->getHeader( 'X-Forwarded-Proto' ) ?: 'http'
) . '://' . $host;
+ $dbg[] = ( $request->getHeader( 'X-FORWARDED-PROTO' ) ?: 'http'
) . '://' . $host;
$dbg[] = $request->getRawQueryString();
$dbg = implode( "\t", $dbg );
@@ -988,7 +988,7 @@
*/
private function logWarnings( $isZeroTraffic ) {
$req = $this->getRequest();
- $configId2 = $req->getHeader( 'X-CS2' );
+ $xcs = $req->getHeader( 'X-CS2' ) ?: $req->getHeader( 'X-CS' );
$ua = $req->getHeader( 'USER-AGENT' );
$isBot =
$req->getHeader( 'FROM' ) ===
'googlebot(at)googlebot.com' ||
@@ -1018,33 +1018,33 @@
// }
// For Zero traffic, either it should come from Opera
AND have slot, or should be neither.
- // For non-Zero traffic, it should not have opera route
- $forwardedByOpera = $req->getHeader( 'X-Forwarded-By' )
=== 'Opera';
+ // For non-Zero traffic, it should not have opera slot
+ $forwardedBy = $req->getHeader( 'X-FORWARDED-BY' ) ?:
$req->getHeader( 'X-FORWARDED-BY2' );
+ // route could be 0, which is the same as not having it.
$slot = $req->getHeader( 'X-OPERAMINI-ROUTE' );
- if ( !$forwardedByOpera && $slot ) {
- if ( $req->getHeader( 'X-Forwarded-By2' ) ===
'Opera' ) {
- if ( $configId2 ) {
- // Opera traffic, and opera has
marked it with a slot, but we are not marking as zero
- $warn['opera-slot-not-zero'] =
$configId2;
- } else {
- // Opera traffic, and opera has
marked it with a slot, but we don't know who this is
- $warn['opera-slot-unknown'] =
$req->getHeader( 'X-Forwarded-For' );
+ if ( $forwardedBy === 'Opera' ) {
+ if ( $slot ) {
+ if ( !$xcs ) {
+ // Opera has a slot for it, but
we don't know who this is
+ $warn['opera'] =
'slot-no-partner';
+ $warn['slot'] = $slot;
+ $warn['xff'] = $req->getHeader(
'X-FORWARDED-FOR' );
+ } elseif ( !$isZeroTraffic ) {
+ // Opera has a slot for it, and
the partner is known, but we didn't zero-rate this request
+ $warn['opera'] =
'slot-incomplete';
+ $warn['slot'] = $slot;
+ $warn['xcs'] = $xcs;
}
- } else {
- // Opera has marked it with a slot, but
we didn't recognize it as opera traffic
- $warn['not-opera-slot2'] =
$req->getHeader( 'X-Forwarded-For' );
- }
- } elseif ( $forwardedByOpera ) {
- if ( !$slot && $isZeroTraffic ) {
+ } elseif ( $isZeroTraffic ) {
// We think it has been zero-rated, but
opera has not marked it with a slot
- $warn['opera-no-slot'] = $configId2;
- } elseif ( $slot && !$configId2 ) {
- // Opera has a slot for it, but we
don't know who this is
- $warn['opera-slot-no-partner'] =
$req->getHeader( 'X-Forwarded-For' );
- } elseif ( $slot && !$isZeroTraffic ) {
- // Opera has a slot for it, and the
partner is known, but we didn't zero-rate this request
- $warn['opera-slot-incomplete'] =
$configId2;
+ $warn['opera'] = 'no-slot';
+ $warn['xcs'] = $xcs;
}
+ } elseif ( $slot ) {
+ // Opera has marked it with a slot, but we
didn't recognize it as opera traffic
+ $warn['opera'] = 'slot-no-opera';
+ $warn['slot'] = $slot;
+ $warn['xff'] = $req->getHeader(
'X-FORWARDED-FOR' );
}
if ( $warn ) {
--
To view, visit https://gerrit.wikimedia.org/r/149296
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id056974a0157720035511e6874bb1918fc264cca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ZeroBanner
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits