r50710 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50709‎ | r50710 | r50711 >
Date:00:33, 18 May 2009
Author:demon
Status:deferred
Tags:
Comment:
* Use wfIniGetBool() and a check for curl.
* Use Http::get() instead of file_get_contents()
* You can't set allow_url_fopen at runtime, it's only configurable in php.ini
Modified paths:
  • /trunk/extensions/AmazonPlus/AmazonPlus.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AmazonPlus/AmazonPlus.php
@@ -24,11 +24,9 @@
2525
2626 # make sure that everything that needs to be set/loaded is that way
2727 $err = '';
28 -if ( !ini_get( 'allow_url_fopen' ) ) {
29 - # we need allow_url_fopen to be on in order for the file_get_contents() call to work on the amazon url
30 - if ( ini_set( 'allow_url_fopen', 1 ) === false ) {
31 - $err .= "\n<li>allow_url_fopen must be enabled in php.ini</li>";
32 - }
 28+if ( !wfIniGetBool( 'allow_url_fopen' ) && !extension_loaded( 'curl' ) ) {
 29+ # we need allow_url_fopen or curl to be on in order for the Http::get() call to work on the amazon url
 30+ $err .= "\n<li>allow_url_fopen or curl must be enabled in php.ini</li>";
3331 }
3432 if ( !extension_loaded( 'simplexml' ) ) {
3533 # we need the simplexml extension loaded to parse the xml string
@@ -201,8 +199,8 @@
202200 $str .= wfUrlencode( $key ) . '=' . wfUrlencode( $value );
203201 }
204202
205 - $this->response = file_get_contents( $str );
206 - if ( $this->response === false ) {
 203+ $this->response = Http::get( $str );
 204+ if ( !$this->response ) {
207205 return 'amazonplus-fgcerr';
208206 }
209207

Status & tagging log