r92481 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92480‎ | r92481 | r92482 >
Date:21:56, 18 July 2011
Author:demon
Status:ok (Comments)
Tags:
Comment:
(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 :)
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -171,6 +171,8 @@
172172 * Removed AjaxFunctions.php. The last remaining function js_unescape() was moved
173173 to the FCKEditor extension.
174174 * (bug 28762) Resizing to specified height broken for very thin images
 175+* (bug 29959) Installer fatal when cURL and allow_url_fopen is disabled and user
 176+ tries to subsribe to mediawiki-announce
175177
176178 === API changes in 1.19 ===
177179 * BREAKING CHANGE: action=watch now requires POST and token.
Index: trunk/phase3/includes/installer/Installer.php
@@ -1466,10 +1466,14 @@
14671467 $params['language'] = $myLang;
14681468 }
14691469
1470 - $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
1471 - array( 'method' => 'POST', 'postData' => $params ) )->execute();
1472 - if( !$res->isOK() ) {
1473 - $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
 1470+ if( MWHttpRequest::canMakeRequests() ) {
 1471+ $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
 1472+ array( 'method' => 'POST', 'postData' => $params ) )->execute();
 1473+ if( !$res->isOK() ) {
 1474+ $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
 1475+ }
 1476+ } else {
 1477+ $s->warning( 'config-install-subscribe-notpossible' );
14741478 }
14751479 }
14761480
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -520,6 +520,7 @@
521521 '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.",
522522 'config-install-sysop' => 'Creating administrator user account',
523523 'config-install-subscribe-fail' => 'Unable to subscribe to mediawiki-announce: $1',
 524+ 'config-install-subscribe-notpossible' => 'cURL is not installed and allow_url_fopen is not available.',
524525 'config-install-mainpage' => 'Creating main page with default content',
525526 'config-install-extension-tables' => 'Creating tables for enabled extensions',
526527 'config-install-mainpage-failed' => 'Could not insert main page: $1',
Index: trunk/phase3/includes/HttpFunctions.php
@@ -210,6 +210,15 @@
211211 }
212212
213213 /**
 214+ * Simple function to test if we can make any sort of requests at all, using
 215+ * cURL or fopen()
 216+ * @return bool
 217+ */
 218+ public static function canMakeRequests() {
 219+ return function_exists( 'curl_init' ) || wfIniGetBool( 'allow_url_fopen' );
 220+ }
 221+
 222+ /**
214223 * Generate a new request object
215224 * @param $url String: url to use
216225 * @param $options Array: (optional) extra params to pass (see Http::request())

Follow-up revisions

RevisionCommit summaryAuthorDate
r92505MFT r92477, r92480, r92481, r92482, r92484, r9485, r92486...reedy23:14, 18 July 2011
r94040MFT r92481 to 1.17: (bug 29959) Installer fatal when cURL and allow_url_fopen...maxsem08:23, 7 August 2011

Comments

#Comment by Nikerabbit (talk | contribs)   06:26, 19 July 2011

The message says that both are not available, but what if only the other one is missing?

#Comment by 😂 (talk | contribs)   06:38, 19 July 2011

Well if only one or the other is missing, then canMakeRequests() will return true and we'll be able to make the request. We don't care about the situation in which one (or both) is available, we only are trying to catch when neither are there (and factory() explodes)

Status & tagging log