r67663 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67662‎ | r67663 | r67664 >
Date:20:01, 8 June 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Enable http compression.
Skip "CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set" error.
Modified paths:
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HttpFunctions.php
@@ -1,4 +1,4 @@
2 -<?php
 2+ <?php
33 /**
44 * @defgroup HTTP HTTP
55 */
@@ -729,8 +729,8 @@
730730 $this->curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
731731 $this->curlOptions[CURLOPT_WRITEFUNCTION] = $this->callback;
732732 $this->curlOptions[CURLOPT_HEADERFUNCTION] = array($this, "readHeader");
733 - $this->curlOptions[CURLOPT_FOLLOWLOCATION] = $this->followRedirects;
734733 $this->curlOptions[CURLOPT_MAXREDIRS] = $this->maxRedirects;
 734+ $this->curlOptions[CURLOPT_ENCODING] = ""; # Enable compression
735735
736736 /* not sure these two are actually necessary */
737737 if(isset($this->reqHeaders['Referer'])) {
@@ -767,7 +767,13 @@
768768 $this->curlOptions[CURLOPT_HTTPHEADER] = $this->getHeaderList();
769769
770770 $curlHandle = curl_init( $this->url );
771 - curl_setopt_array( $curlHandle, $this->curlOptions );
 771+ if ( !curl_setopt_array( $curlHandle, $this->curlOptions ) ) {
 772+ throw new MWException("Error setting curl options.");
 773+ }
 774+ if ( ! @curl_setopt( $curlHandle, CURLOPT_FOLLOWLOCATION, $this->followRedirects ) ) {
 775+ wfDebug("Couldn't set CURLOPT_FOLLOWLOCATION. Probably safe_mode or open_basedir is set.");
 776+ /* Continue the processing. If it were in curl_setopt_array, processing would have halted on its entry */
 777+ }
772778
773779 if ( false === curl_exec( $curlHandle ) ) {
774780 $code = curl_error( $curlHandle );

Follow-up revisions

RevisionCommit summaryAuthorDate
r67664Follow up r67663. Stay quiet, T_OPEN_TAG!platonides20:06, 8 June 2010
r79181Follow up r67663. Now with 100% less sugar, er.. @s!platonides16:15, 29 December 2010

Comments

#Comment by Nikerabbit (talk | contribs)   20:08, 8 June 2010

This would be nice in 1.16, since it seems to break all requests if the conditions apply.

#Comment by 😂 (talk | contribs)   07:53, 29 December 2010

@ is evil: should probably just check for safe_mode || open_basedir.

#Comment by Platonides (talk | contribs)   16:15, 29 December 2010

Evil removed in r79181.

Status & tagging log