(bug 29959) Installer fatal when cURL and allow_url_fopen is disabled and user tries...
authorChad Horohoe <demon@users.mediawiki.org>
Mon, 18 Jul 2011 21:56:10 +0000 (21:56 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Mon, 18 Jul 2011 21:56:10 +0000 (21:56 +0000)
Really, I'm not sure about the usefulness of exploding with a MWException anytime we can't do an external request, but at least we can stop the installer from exploding :)

RELEASE-NOTES-1.19
includes/HttpFunctions.php
includes/installer/Installer.i18n.php
includes/installer/Installer.php

index 57cf5b3..d7df126 100644 (file)
@@ -171,6 +171,8 @@ production.
 * Removed AjaxFunctions.php. The last remaining function js_unescape() was moved
   to the FCKEditor extension.
 * (bug 28762) Resizing to specified height broken for very thin images
+* (bug 29959) Installer fatal when cURL and allow_url_fopen is disabled and user
+  tries to subsribe to mediawiki-announce
 
 === API changes in 1.19 ===
 * BREAKING CHANGE: action=watch now requires POST and token.
index bac062f..2e6139e 100644 (file)
@@ -209,6 +209,15 @@ class MWHttpRequest {
                }
        }
 
+       /**
+        * Simple function to test if we can make any sort of requests at all, using
+        * cURL or fopen()
+        * @return bool
+        */
+       public static function canMakeRequests() {
+               return function_exists( 'curl_init' ) || wfIniGetBool( 'allow_url_fopen' );
+       }
+
        /**
         * Generate a new request object
         * @param $url String: url to use
index ef50a54..32966ed 100644 (file)
@@ -520,6 +520,7 @@ Skipping default list.",
        'config-insecure-keys'            => "'''Warning:''' {{PLURAL:$2|A secure key|Secure keys}} ($1) generated during installation {{PLURAL:$2|is|are}} not completely safe. Consider changing {{PLURAL:$2|it|them}} manually.",
        'config-install-sysop'            => 'Creating administrator user account',
        'config-install-subscribe-fail'   => 'Unable to subscribe to mediawiki-announce: $1',
+       'config-install-subscribe-notpossible' => 'cURL is not installed and allow_url_fopen is not available.',
        'config-install-mainpage'         => 'Creating main page with default content',
        'config-install-extension-tables' => 'Creating tables for enabled extensions',
        'config-install-mainpage-failed'  => 'Could not insert main page: $1',
index f9f59cd..8cdde63 100644 (file)
@@ -1466,10 +1466,14 @@ abstract class Installer {
                        $params['language'] = $myLang;
                }
 
-               $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
-                       array( 'method' => 'POST', 'postData' => $params ) )->execute();
-               if( !$res->isOK() ) {
-                       $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
+               if( MWHttpRequest::canMakeRequests() ) {
+                       $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
+                               array( 'method' => 'POST', 'postData' => $params ) )->execute();
+                       if( !$res->isOK() ) {
+                               $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
+                       }
+               } else {
+                       $s->warning( 'config-install-subscribe-notpossible' );
                }
        }