From 852334b7366ebfff658731abeb7cae70e70878c5 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 21 Jun 2011 01:13:45 +0000 Subject: [PATCH] (bug 29492) Long-running steps in the installer (such as Upgrade and Install) can sometimes timeout --- RELEASE-NOTES-1.19 | 2 ++ includes/installer/Installer.php | 10 ++++++++++ includes/installer/WebInstaller.php | 4 ++++ includes/installer/WebInstallerPage.php | 15 +++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index fb2f0d2395..180817be7c 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -108,6 +108,8 @@ production. * (bug 29342) Patrol preferences shouldn't be visible to users who don't have patrol permissions * (bug 29471) Exception thrown for files with invalid date in metadata +* (bug 29492) Long-running steps in the installer (such as Upgrade and Install) + can sometimes timeout === API changes in 1.19 === * BREAKING CHANGE: action=watch now requires POST and token. diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index c496ecc5e9..f9f59cdf73 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -1533,4 +1533,14 @@ abstract class Installer { public function addInstallStep( $callback, $findStep = 'BEGINNING' ) { $this->extraInstallSteps[$findStep][] = $callback; } + + /** + * Disable the time limit for execution. + * Some long-running pages (Install, Upgrade) will want to do this + */ + protected function disableTimeLimit() { + wfSuppressWarnings(); + set_time_limit( 0 ); + wfRestoreWarnings(); + } } diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index 4ea0cd4071..4189ece062 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -247,6 +247,10 @@ class WebInstaller extends Installer { $this->currentPageName = $page->getName(); $this->startPageWrapper( $pageName ); + if( $page->isSlow() ) { + $this->disableTimeLimit(); + } + $result = $page->execute(); $this->endPageWrapper(); diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php index f0ae6ba66e..a06dc20145 100644 --- a/includes/installer/WebInstallerPage.php +++ b/includes/installer/WebInstallerPage.php @@ -32,6 +32,15 @@ abstract class WebInstallerPage { $this->parent = $parent; } + /** + * Is this a slow-running page in the installer? If so, WebInstaller will + * set_time_limit(0) before calling execute(). Right now this only applies + * to Install and Upgrade pages + */ + public function isSlow() { + return false; + } + public function addHTML( $html ) { $this->parent->output->addHTML( $html ); } @@ -467,6 +476,9 @@ class WebInstaller_DBConnect extends WebInstallerPage { } class WebInstaller_Upgrade extends WebInstallerPage { + public function isSlow() { + return true; + } public function execute() { if ( $this->getVar( '_UpgradeDone' ) ) { @@ -1086,6 +1098,9 @@ class WebInstaller_Options extends WebInstallerPage { } class WebInstaller_Install extends WebInstallerPage { + public function isSlow() { + return true; + } public function execute() { if( $this->getVar( '_UpgradeDone' ) ) { -- 2.20.1