r44175 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44174‎ | r44175 | r44176 >
Date:15:39, 3 December 2008
Author:demon
Status:ok
Tags:
Comment:
Cleanup. Use wfGetAgent() and Http::userAgent() instead of guessing on our own.
Modified paths:
  • /trunk/extensions/Collection/Collection.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.body.php
@@ -1233,18 +1233,16 @@
12341234
12351235 static function post( $url, $postFields, &$errorMessage, &$headers,
12361236 $timeout=true, $toFile=null ) {
1237 - global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle, $wgRequest;
 1237+ global $wgHTTPTimeout, $wgHTTPProxy, $wgTitle;
12381238 global $wgCollectionMWServeCert;
12391239 global $wgCollectionVersion;
12401240
12411241 $c = curl_init( $url );
12421242 curl_setopt($c, CURLOPT_PROXY, $wgHTTPProxy);
1243 - $userAgent = $wgRequest->getHeader('User-agent');
1244 - if ( $userAgent ) {
1245 - curl_setopt( $c, CURLOPT_USERAGENT, $userAgent . " (via MediaWiki/$wgVersion, Collection/$wgCollectionVersion)" );
1246 - } else {
1247 - curl_setopt( $c, CURLOPT_USERAGENT, "Unknown user agent (via MediaWiki/$wgVersion, Collection/$wgCollectionVersion)" );
1248 - }
 1243+ $userAgent = wfGetAgent();
 1244+ if ( !$userAgent ) $userAgent = "Unknown user agent";
 1245+ curl_setopt( $c, CURLOPT_USERAGENT, $userAgent . " (via " . Http::userAgent() .
 1246+ ", Collection/$wgCollectionVersion)" );
12491247 curl_setopt( $c, CURLOPT_POST, true );
12501248 curl_setopt( $c, CURLOPT_POSTFIELDS, $postFields );
12511249 curl_setopt( $c, CURLOPT_HTTPHEADER, array( 'Expect:' ) );

Status & tagging log