var $mTagHooks, $mTransparentTagHooks, $mFunctionHooks, $mFunctionSynonyms, $mVariables,
$mImageParams, $mImageParamsMagicArray, $mStripList, $mMarkerIndex, $mPreprocessor,
$mExtLinkBracketedRegex, $mUrlProtocols, $mDefaultStripList, $mVarCache, $mConf,
- $mFunctionTagHooks, $mDoTitleConvert, $mDoContentConvert;
+ $mFunctionTagHooks;
# Cleared with clearState():
}
$this->mMarkerIndex = 0;
$this->mFirstCall = true;
- $this->mDoTitleConvert = true;
- $this->mDoContentConvert = true;
}
/**
* Set the context title
*/
function setTitle( $t ) {
- // If don't have a Title object, then convert what we have to
- // a string and then to Title. If you pass in an object, make
- // sure it has a __toString() method or you'll get a
- // "Catchable fatal error"
- if ( $t && !($t instanceOf FakeTitle)
- && !($t instanceOf Title) ) {
- $t = Title::newFromText( "$t" );
- }
-
- if ( !($t instanceOf Title) ) {
- $t = Title::newFromText( 'NO TITLE' );
- }
+ if ( !$t || $t instanceof FakeTitle ) {
+ $t = Title::newFromText( 'NO TITLE' );
+ }
if ( strval( $t->getFragment() ) !== '' ) {
# Strip the fragment to avoid various odd effects
* to internalParse() which does all the real work.
*/
- global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang;
+ global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion;
$fname = __METHOD__.'-' . wfGetCaller();
wfProfileIn( __METHOD__ );
wfProfileIn( $fname );
// The position of the convert() call should not be changed. it
// assumes that the links are all replaced and the only thing left
// is the <nowiki> mark.
- if ( $this->mDoContentConvert && !$this->mTitle->isConversionTable()) {
+ if ( !( $wgDisableLangConversion
+ || isset( $this->mDoubleUnderscores['nocontentconvert'] )
+ || $this->mTitle->isTalkPage()
+ || $this->mTitle->isConversionTable() ) ) {
$text = $wgContLang->convert( $text );
}
// rule but content conversion was not done, then the parser
// won't pick it up. This is probably expected behavior.
if ( $wgContLang->getConvRuleTitle() ) {
- $this->setTitle( $wgContLang->getConvRuleTitle() );
- } elseif ( $this->mDoTitleConvert && !$this->mTitle->isConversionTable() ) {
- $this->setTitle( $wgContLang->convert( $title ) );
+ $this->mOutput->setTitleText( $wgContLang->getConvRuleTitle() );
+ } elseif ( !( $wgDisableLangConversion
+ || isset( $this->mDoubleUnderscores['notitleconvert'] ) ) ) {
+ $this->mOutput->setTitleText( $wgContLang->convert( $title ) );
}
$text = $this->mStripState->unstripNoWiki( $text );
$text .= "\n<!-- \n$limitReport-->\n";
}
$this->mOutput->setText( $text );
+
$this->mRevisionId = $oldRevisionId;
$this->mRevisionTimestamp = $oldRevisionTimestamp;
wfProfileOut( $fname );
* Fills $this->mDoubleUnderscores, returns the modified text
*/
function doDoubleUnderscore( $text ) {
- global $wgDisableLangConversion;
wfProfileIn( __METHOD__ );
// The position of __TOC__ needs to be recorded
$this->addTrackingCategory( 'index-category' );
}
- if ( !$wgDisableLangConversion ) {
- if( isset( $this->mDoubleUnderscores['notitleconvert'] ) ){
- $this->mDoTitleConvert = false;
- }
-
- // Don't convert talk pages
- if( isset( $this->mDoubleUnderscores['nocontentconvert'] )
- && !$this->mTitle->isTalkPage() ){
- $this->mDoContentConvert = false;
- }
- }
-
wfProfileOut( __METHOD__ );
return $text;
}
$options = array( 'quick', 'color', 'quiet', 'help', 'show-output', 'record'. 'run-disabled' );
$optionsWithArgs = array( 'regex', 'seed', 'setversion' );
-require_once( dirname(__FILE__) . '/commandLine.inc' );
+if ( !defined( "NO_COMMAND_LINE" ) ) {
+ require_once( dirname(__FILE__) . '/commandLine.inc' );
+}
require_once( "$IP/maintenance/parserTestsParserHook.php" );
require_once( "$IP/maintenance/parserTestsStaticParserHook.php" );
require_once( "$IP/maintenance/parserTestsParserTime.php" );
isset( $options['quiet'] )
&& ( isset( $options['record'] )
|| isset( $options['compare'] ) ) ); // redundant output
-
+
$this->showOutput = isset( $options['show-output'] );
}
if (!isset( $data['config'] ) )
$data['config'] = '';
-
+
if ( (preg_match('/\\bdisabled\\b/i', $data['options'])
|| !preg_match("/{$this->regex}/i", $data['test'])) && !$this->runDisabled ) {
# disabled test
$output = $parser->parse( $input, $title, $options, true, true, 1337 );
$out = $output->getText();
+ if ( isset( $opts['showtitle'] ) ) {
+ $out = $output->getTitleText() . "\n$out";
+ }
if (isset( $opts['ill'] ) ) {
$out = $this->tidy( implode( ' ', $output->getLanguageLinks() ) );
} elseif( isset( $opts['cat'] ) ) {
$result = $this->tidy($result);
}
- if ( isset( $opts['showtitle'] ) ) {
- $out = $parser->mTitle . "\n$out";
- }
$this->teardownGlobals();
return $default;
}
}
-
+
private function parseOptions( $instring ) {
$opts = array();
$lines = explode( "\n", $instring );
}
return $opts;
}
-
+
private function cleanupOption( $opt ) {
if( substr( $opt, 0, 1 ) == '"' ) {
return substr( $opt, 1, -1 );
self::getOptionValue( 'variant', $opts, false );
$maxtoclevel =
self::getOptionValue( 'wgMaxTocLevel', $opts, 999 );
- $linkHolderBatchSize =
+ $linkHolderBatchSize =
self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
$settings = array(
if ($config) {
$configLines = explode( "\n", $config );
-
+
foreach( $configLines as $line ) {
list( $var, $value ) = explode( '=', $line, 2 );
-
+
$settings[$var] = eval("return $value;" );
}
}
-
+
$this->savedGlobals = array();
foreach( $settings as $var => $val ) {
- $this->savedGlobals[$var] = $GLOBALS[$var];
+ if( array_key_exists( $var, $GLOBALS ) ) {
+ $this->savedGlobals[$var] = $GLOBALS[$var];
+ }
$GLOBALS[$var] = $val;
}
$langObj = Language::factory( $lang );
'archive', 'user_groups', 'page_props', 'category'
);
- if ($wgDBtype === 'mysql')
+ if ($wgDBtype === 'mysql')
array_push( $tables, 'searchindex' );
-
+
// Allow extensions to add to the list of tables to duplicate;
// may be necessary if they hook into page save or other code
// which will require them while running tests.
if ($wgDBtype == 'oracle') {
# Insert 0 and 1 user_ids to prevent FK violations
-
+
#Anonymous user
$db->insert( 'user', array(
'user_id' => 0,
$db->query('BEGIN FILL_WIKI_INFO; END;');
*/
}
-
+
/**
* Create a dummy uploads directory which will contain a couple
* of files in order to pass existence tests.
global $wgDBtype, $wgDBprefix;
parent::start();
- if( ! $this->db->tableExists( 'testrun' )
- or ! $this->db->tableExists( 'testitem' ) )
+ if( ! $this->db->tableExists( 'testrun' )
+ or ! $this->db->tableExists( 'testitem' ) )
{
print "WARNING> `testrun` table not found in database.\n";
$this->prevRun = false;
$res = $this->db->select( 'testitem', array( 'ti_name', 'ti_success' ),
array( 'ti_run' => $this->prevRun ), __METHOD__ );
foreach ( $res as $row ) {
- if ( !$this->parent->regex
+ if ( !$this->parent->regex
|| preg_match( "/{$this->parent->regex}/i", $row->ti_name ) )
{
$prevResults[$row->ti_name] = $row->ti_success;
// Otherwise, this test has previous recorded results.
// See when this test last had a different result to what we're seeing now.
- $conds = array(
+ $conds = array(
'ti_name' => $testname,
'ti_success' => ($after == 'f' ? "1" : "0") );
if ( $this->curRun ) {
global $wgDBtype, $wgDBprefix, $options;
$this->db->begin();
- if( ! $this->db->tableExists( 'testrun' )
- or ! $this->db->tableExists( 'testitem' ) )
+ if( ! $this->db->tableExists( 'testrun' )
+ or ! $this->db->tableExists( 'testitem' ) )
{
print "WARNING> `testrun` table not found in database. Trying to create table.\n";
if ($wgDBtype === 'postgres')
$this->db->sourceFile( dirname(__FILE__) . '/testRunner.sql' );
echo "OK, resuming.\n";
}
-
+
parent::start();
$this->db->insert( 'testrun',
$this->results = array();
$this->ping( 'running' );
}
-
+
function record( $test, $result ) {
parent::record( $test, $result );
$this->results[$test] = (bool)$result;
}
-
+
function end() {
$this->ping( 'complete', $this->results );
parent::end();
}
-
+
/**
* Inform a CodeReview instance that we've started or completed a test run...
* @param $remote array: info on remote target
*/
function ping( $status, $results=false ) {
global $wgParserTestRemote, $IP;
-
+
$remote = $wgParserTestRemote;
$revId = SpecialVersion::getSvnRevision( $IP );
$jsonResults = json_encode( $results );
-
+
if( !$remote ) {
print "Can't do remote upload without configuring \$wgParserTestRemote!\n";
exit( 1 );
}
-
+
// Generate a hash MAC to validate our credentials
$message = array(
$remote['repo'],
$message[] = $jsonResults;
}
$hmac = hash_hmac( "sha1", implode( "|", $message ), $remote['secret'] );
-
+
$postData = array(
'action' => 'codetestupload',
'format' => 'json',
$postData['results'] = $jsonResults;
}
$response = $this->post( $remote['api-url'], $postData );
-
+
if( $response === false ) {
print "CodeReview info upload failed to reach server.\n";
exit( 1 );
exit( 1 );
}
}
-
+
function post( $url, $data ) {
// @fixme: for whatever reason, I get a 417 fail when using CURL's multipart form submit.
// If we do form URL encoding ourselves, though, it should work.