/**
* 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" );
}
}
);
}
- $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
);
$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' ) ) {