'InstallDocFormatter' => __DIR__ . '/includes/installer/InstallDocFormatter.php',
'Installer' => __DIR__ . '/includes/installer/Installer.php',
'InstallerOverrides' => __DIR__ . '/mw-config/overrides.php',
+ 'InstallerSessionProvider' => __DIR__ . '/includes/installer/InstallerSessionProvider.php',
'Interwiki' => __DIR__ . '/includes/interwiki/Interwiki.php',
'InvalidPassword' => __DIR__ . '/includes/password/InvalidPassword.php',
'IteratorDecorator' => __DIR__ . '/includes/utils/iterators/IteratorDecorator.php',
&$name: Cookie name passed to WebResponse::setcookie()
&$value: Cookie value passed to WebResponse::setcookie()
&$expire: Cookie expiration, as for PHP's setcookie()
-$options: Options passed to WebResponse::setcookie()
+&$options: Options passed to WebResponse::setcookie()
'wfShellWikiCmd': Called when generating a shell-escaped command line string to
run a MediaWiki cli script.
$func = $options['raw'] ? 'setrawcookie' : 'setcookie';
- if ( Hooks::run( 'WebResponseSetCookie', array( &$name, &$value, &$expire, $options ) ) ) {
+ if ( Hooks::run( 'WebResponseSetCookie', array( &$name, &$value, &$expire, &$options ) ) ) {
$cookie = $options['prefix'] . $name;
$data = array(
'name' => (string)$cookie,
return '';
}
$cache = $this->watchMsgCache;
- $that = $this;
return $cache->getWithSetCallback( $count, $cache::TTL_INDEFINITE,
- function () use ( $that, $count ) {
- return $that->msg( 'number_of_watching_users_RCview' )
+ function () use ( $count ) {
+ return $this->msg( 'number_of_watching_users_RCview' )
->numParams( $count )->escaped();
}
);
/**
* Get the name of an index in a given table.
*
- * @protected Don't use outside of DatabaseBase and childs
* @param string $index
* @return string
*/
* @param string $index
* @return string
*/
- function indexName( $index ) {
+ protected function indexName( $index ) {
return $index;
}
*/
protected $trailingContextLines = 0;
+ /** @var string The output buffer; holds the output while it is built. */
+ private $result = '';
+
/**
* Format a diff.
*
}
protected function startDiff() {
- ob_start();
+ $this->result = '';
+ }
+
+ /**
+ * Writes a string to the output buffer.
+ *
+ * @param string $text
+ */
+ protected function writeOutput( $text ) {
+ $this->result .= $text;
}
/**
* @return string
*/
protected function endDiff() {
- $val = ob_get_contents();
- ob_end_clean();
+ $val = $this->result;
+ $this->result = '';
return $val;
}
* @param string $header
*/
protected function startBlock( $header ) {
- echo $header . "\n";
+ $this->writeOutput( $header . "\n" );
}
/**
*/
protected function lines( $lines, $prefix = ' ' ) {
foreach ( $lines as $line ) {
- echo "$prefix $line\n";
+ $this->writeOutput( "$prefix $line\n" );
}
}
*/
protected function changed( $orig, $closing ) {
$this->deleted( $orig );
- echo "---\n";
+ $this->writeOutput( "---\n" );
$this->added( $closing );
}
* @param string $header
*/
protected function startBlock( $header ) {
- echo $header;
+ $this->writeOutput( $header );
}
protected function endBlock() {
*/
protected function added( $lines ) {
foreach ( $lines as $line ) {
- echo '<tr>' . $this->emptyLine() .
+ $this->writeOutput( '<tr>' . $this->emptyLine() .
$this->addedLine( '<ins class="diffchange">' .
- htmlspecialchars( $line ) . '</ins>' ) . "</tr>\n";
+ htmlspecialchars( $line ) . '</ins>' ) . "</tr>\n" );
}
}
*/
protected function deleted( $lines ) {
foreach ( $lines as $line ) {
- echo '<tr>' . $this->deletedLine( '<del class="diffchange">' .
+ $this->writeOutput( '<tr>' . $this->deletedLine( '<del class="diffchange">' .
htmlspecialchars( $line ) . '</del>' ) .
- $this->emptyLine() . "</tr>\n";
+ $this->emptyLine() . "</tr>\n" );
}
}
*/
protected function context( $lines ) {
foreach ( $lines as $line ) {
- echo '<tr>' .
+ $this->writeOutput( '<tr>' .
$this->contextLine( htmlspecialchars( $line ) ) .
- $this->contextLine( htmlspecialchars( $line ) ) . "</tr>\n";
+ $this->contextLine( htmlspecialchars( $line ) ) . "</tr>\n" );
}
}
$line = array_shift( $del );
while ( $line ) {
$aline = array_shift( $add );
- echo '<tr>' . $this->deletedLine( $line ) .
- $this->addedLine( $aline ) . "</tr>\n";
+ $this->writeOutput( '<tr>' . $this->deletedLine( $line ) .
+ $this->addedLine( $aline ) . "</tr>\n" );
$line = array_shift( $del );
}
foreach ( $add as $line ) { # If any leftovers
- echo '<tr>' . $this->emptyLine() .
- $this->addedLine( $line ) . "</tr>\n";
+ $this->writeOutput( '<tr>' . $this->emptyLine() .
+ $this->addedLine( $line ) . "</tr>\n" );
}
}
*/
protected function lines( $lines, $prefix = ' ' ) {
foreach ( $lines as $line ) {
- echo "{$prefix}{$line}\n";
+ $this->writeOutput( "{$prefix}{$line}\n" );
}
}
// Some of the environment checks make shell requests, remove limits
$GLOBALS['wgMaxShellMemory'] = 0;
+
+ $GLOBALS['wgSessionProviders'] = array(
+ array(
+ 'class' => 'InstallerSessionProvider',
+ 'args' => array( array(
+ 'priority' => 1,
+ ) )
+ )
+ );
}
/**
--- /dev/null
+<?php
+/**
+ * Session provider which always provides the same session ID and doesn't
+ * persist the session. For use in the installer when ObjectCache doesn't
+ * work anyway.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Deployment
+ */
+
+use MediaWiki\Session\SessionProvider;
+use MediaWiki\Session\SessionBackend;
+use MediaWiki\Session\SessionInfo;
+
+class InstallerSessionProvider extends SessionProvider {
+ /**
+ * Pretend there is a session, to avoid MWCryptRand overhead
+ */
+ public function provideSessionInfo( WebRequest $request ) {
+ return new SessionInfo( 1, array(
+ 'provider' => $this,
+ 'id' => str_repeat( 'x', 32 ),
+ ) );
+ }
+
+ /**
+ * Yes we will treat your data with great care!
+ */
+ public function persistsSessionId() {
+ return true;
+ }
+
+ /**
+ * Sure, you can be whoever you want, as long as you have ID 0
+ */
+ public function canChangeUser() {
+ return true;
+ }
+
+ public function persistSession( SessionBackend $session, WebRequest $request ) {
+ }
+
+ public function unpersistSession( WebRequest $request ) {
+ }
+}
/**
* Adapter for PHP's session handling
- * @todo Once we drop support for PHP < 5.4, use SessionHandlerInterface
- * (should just be a matter of adding "implements SessionHandlerInterface" and
- * changing the session_set_save_handler() call).
* @ingroup Session
* @since 1.27
*/
-class PHPSessionHandler {
+class PHPSessionHandler implements \SessionHandlerInterface {
/** @var PHPSessionHandler */
protected static $instance = null;
// Also set a sane serialization handler
\Wikimedia\PhpSessionSerializer::setSerializeHandler();
- session_set_save_handler(
- array( self::$instance, 'open' ),
- array( self::$instance, 'close' ),
- array( self::$instance, 'read' ),
- array( self::$instance, 'write' ),
- array( self::$instance, 'destroy' ),
- array( self::$instance, 'gc' )
- );
-
- // It's necessary to register a shutdown function to call session_write_close(),
- // because by the time the request shutdown function for the session module is
- // called, other needed objects may have already been destroyed. Shutdown functions
- // registered this way are called before object destruction.
- register_shutdown_function( array( self::$instance, 'handleShutdown' ) );
+ // Register this as the save handler, and register an appropriate
+ // shutdown function.
+ session_set_save_handler( self::$instance, true );
}
/**
$this->store->deleteObjectsExpiringBefore( $before );
return true;
}
-
- /**
- * Shutdown function.
- *
- * See the comment inside self::install for rationale.
- * @codeCoverageIgnore
- * @private For internal use only
- */
- public function handleShutdown() {
- if ( $this->enable ) {
- session_write_close();
- }
- }
-
}
);
}
- $that = $this;
$dbw->doAtomicSection(
__METHOD__,
- function ( IDatabase $dbw, $fname ) use ( $that, $vals ) {
+ function ( IDatabase $dbw, $fname ) use ( $vals ) {
# Clear out any old cached data
$dbw->delete( 'querycache',
- array( 'qc_type' => $that->getName() ),
+ array( 'qc_type' => $this->getName() ),
$fname
);
# Save results into the querycache table on the master
}
# Update the querycache_info record for the page
$dbw->delete( 'querycache_info',
- array( 'qci_type' => $that->getName() ),
+ array( 'qci_type' => $this->getName() ),
$fname
);
$dbw->insert( 'querycache_info',
- array( 'qci_type' => $that->getName(),
+ array( 'qci_type' => $this->getName(),
'qci_timestamp' => $dbw->timestamp() ),
$fname
);
return;
}
- $that = $this;
// Try to update the DB post-send and only if needed...
- DeferredUpdates::addCallableUpdate( function() use ( $that, $title, $oldid ) {
- if ( !$that->getNewtalk() ) {
+ DeferredUpdates::addCallableUpdate( function() use ( $title, $oldid ) {
+ if ( !$this->getNewtalk() ) {
return; // no notifications to clear
}
// Delete the last notifications (they stack up)
- $that->setNewtalk( false );
+ $this->setNewtalk( false );
// If there is a new, unseen, revision, use its timestamp
$nextid = $oldid
? $title->getNextRevisionID( $oldid, Title::GAID_FOR_UPDATE )
: null;
if ( $nextid ) {
- $that->setNewtalk( true, Revision::newFromId( $nextid ) );
+ $this->setNewtalk( true, Revision::newFromId( $nextid ) );
}
} );
}
* Deferred version of incEditCountImmediate()
*/
public function incEditCount() {
- $that = $this;
- wfGetDB( DB_MASTER )->onTransactionPreCommitOrIdle( function() use ( $that ) {
- $that->incEditCountImmediate();
+ wfGetDB( DB_MASTER )->onTransactionPreCommitOrIdle( function() {
+ $this->incEditCountImmediate();
} );
}
}
if ( strlen( $buffer ) < $bytes ) {
- // If available make use of openssl's random_pseudo_bytes method to
- // attempt to generate randomness. However don't do this on Windows
- // with PHP < 5.3.4 due to a bug:
- // http://stackoverflow.com/questions/1940168/openssl-random-pseudo-bytes-is-slow-php
- // http://git.php.net/?p=php-src.git;a=commitdiff;h=cd62a70863c261b07f6dadedad9464f7e213cad5
- if ( function_exists( 'openssl_random_pseudo_bytes' )
- && ( !wfIsWindows() || version_compare( PHP_VERSION, '5.3.4', '>=' ) )
- ) {
+ if ( function_exists( 'openssl_random_pseudo_bytes' ) ) {
$rem = $bytes - strlen( $buffer );
$openssl_bytes = openssl_random_pseudo_bytes( $rem, $openssl_strong );
if ( $openssl_bytes === false ) {
$maintClass = 'PHPUnitMaintClass';
require RUN_MAINTENANCE_IF_MAIN;
-// Prevent segfault when we have lots of unit tests (bug 62623)
-if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
- register_shutdown_function( function () {
- gc_collect_cycles();
- gc_disable();
- } );
-}
-
$ok = false;
if ( class_exists( 'PHPUnit_TextUI_Command' ) ) {