From: Chad Horohoe Date: Mon, 18 Jul 2011 21:56:10 +0000 (+0000) Subject: (bug 29959) Installer fatal when cURL and allow_url_fopen is disabled and user tries... X-Git-Tag: 1.31.0-rc.0~28762 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=4f21bb309ebfb1b301e452fec868c4fcb3270a37;p=lhc%2Fweb%2Fwiklou.git (bug 29959) Installer fatal when cURL and allow_url_fopen is disabled and user tries to subsribe to mediawiki-announce 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 :) --- diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 57cf5b3ba7..d7df126c4c 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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. diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index bac062fd5c..2e6139ec7d 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -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 diff --git a/includes/installer/Installer.i18n.php b/includes/installer/Installer.i18n.php index ef50a5491e..32966edf58 100644 --- a/includes/installer/Installer.i18n.php +++ b/includes/installer/Installer.i18n.php @@ -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', diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index f9f59cdf73..8cdde632a2 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -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' ); } }