From 0086965fd08f7f18abd4770eedf1c76c5c99ce6f Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 7 Aug 2015 16:07:37 -0700 Subject: [PATCH] Removed ScopedPHPTimeout; unused Change-Id: Ic3a3500ddd410c68a30d3f3d1947f632e1aff5fd --- RELEASE-NOTES-1.26 | 1 + autoload.php | 1 - includes/libs/ScopedPHPTimeout.php | 84 ------------------------------ 3 files changed, 1 insertion(+), 85 deletions(-) delete mode 100644 includes/libs/ScopedPHPTimeout.php diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26 index b4702728fb..7770e74136 100644 --- a/RELEASE-NOTES-1.26 +++ b/RELEASE-NOTES-1.26 @@ -143,6 +143,7 @@ changes to languages because of Phabricator reports. * DatabaseBase::ignoreErrors() is now protected. * BREAKING CHANGE: mediawiki.legacy.ajax has been removed, following a lengthy deprecation period. +* The ScopedPHPTimeout class was removed. == Compatibility == diff --git a/autoload.php b/autoload.php index a6c7488100..e001805522 100644 --- a/autoload.php +++ b/autoload.php @@ -1064,7 +1064,6 @@ $wgAutoloadLocalClasses = array( 'SavepointPostgres' => __DIR__ . '/includes/db/DatabasePostgres.php', 'ScopedCallback' => __DIR__ . '/includes/libs/ScopedCallback.php', 'ScopedLock' => __DIR__ . '/includes/filebackend/lockmanager/ScopedLock.php', - 'ScopedPHPTimeout' => __DIR__ . '/includes/libs/ScopedPHPTimeout.php', 'SearchDatabase' => __DIR__ . '/includes/search/SearchDatabase.php', 'SearchDump' => __DIR__ . '/maintenance/dumpIterator.php', 'SearchEngine' => __DIR__ . '/includes/search/SearchEngine.php', diff --git a/includes/libs/ScopedPHPTimeout.php b/includes/libs/ScopedPHPTimeout.php deleted file mode 100644 index d1493c30b7..0000000000 --- a/includes/libs/ScopedPHPTimeout.php +++ /dev/null @@ -1,84 +0,0 @@ - 0 ) { // CLI uses 0 - if ( self::$totalCalls >= self::MAX_TOTAL_CALLS ) { - trigger_error( "Maximum invocations of " . __CLASS__ . " exceeded." ); - } elseif ( self::$totalElapsed >= self::MAX_TOTAL_TIME ) { - trigger_error( "Time limit within invocations of " . __CLASS__ . " exceeded." ); - } elseif ( self::$stackDepth > 0 ) { // recursion guard - trigger_error( "Resursive invocation of " . __CLASS__ . " attempted." ); - } else { - $this->oldIgnoreAbort = ignore_user_abort( true ); - $this->oldTimeout = ini_set( 'max_execution_time', $seconds ); - $this->startTime = microtime( true ); - ++self::$stackDepth; - ++self::$totalCalls; // proof against < 1us scopes - } - } - } - - /** - * Restore the original timeout. - * This does not account for the timer value on __construct(). - */ - public function __destruct() { - if ( $this->oldTimeout ) { - $elapsed = microtime( true ) - $this->startTime; - // Note: a limit of 0 is treated as "forever" - set_time_limit( max( 1, $this->oldTimeout - (int)$elapsed ) ); - // If each scoped timeout is for less than one second, we end up - // restoring the original timeout without any decrease in value. - // Thus web scripts in an infinite loop can run forever unless we - // take some measures to prevent this. Track total time and calls. - self::$totalElapsed += $elapsed; - --self::$stackDepth; - ignore_user_abort( $this->oldIgnoreAbort ); - } - } -} -- 2.20.1