Index: trunk/phase3/maintenance/parserTests.inc |
— | — | @@ -28,7 +28,9 @@ |
29 | 29 | $options = array( 'quick', 'color', 'quiet', 'help', 'show-output', 'record'. 'run-disabled' ); |
30 | 30 | $optionsWithArgs = array( 'regex', 'seed', 'setversion' ); |
31 | 31 | |
32 | | -require_once( dirname(__FILE__) . '/commandLine.inc' ); |
| 32 | +if ( !defined( "NO_COMMAND_LINE" ) ) { |
| 33 | + require_once( dirname(__FILE__) . '/commandLine.inc' ); |
| 34 | +} |
33 | 35 | require_once( "$IP/maintenance/parserTestsParserHook.php" ); |
34 | 36 | require_once( "$IP/maintenance/parserTestsStaticParserHook.php" ); |
35 | 37 | require_once( "$IP/maintenance/parserTestsParserTime.php" ); |
— | — | @@ -97,7 +99,7 @@ |
98 | 100 | isset( $options['quiet'] ) |
99 | 101 | && ( isset( $options['record'] ) |
100 | 102 | || isset( $options['compare'] ) ) ); // redundant output |
101 | | - |
| 103 | + |
102 | 104 | $this->showOutput = isset( $options['show-output'] ); |
103 | 105 | |
104 | 106 | |
— | — | @@ -359,7 +361,7 @@ |
360 | 362 | } |
361 | 363 | if (!isset( $data['config'] ) ) |
362 | 364 | $data['config'] = ''; |
363 | | - |
| 365 | + |
364 | 366 | if ( (preg_match('/\\bdisabled\\b/i', $data['options']) |
365 | 367 | || !preg_match("/{$this->regex}/i", $data['test'])) && !$this->runDisabled ) { |
366 | 368 | # disabled test |
— | — | @@ -477,6 +479,9 @@ |
478 | 480 | $output = $parser->parse( $input, $title, $options, true, true, 1337 ); |
479 | 481 | $out = $output->getText(); |
480 | 482 | |
| 483 | + if ( isset( $opts['showtitle'] ) ) { |
| 484 | + $out = $output->getTitleText() . "\n$out"; |
| 485 | + } |
481 | 486 | if (isset( $opts['ill'] ) ) { |
482 | 487 | $out = $this->tidy( implode( ' ', $output->getLanguageLinks() ) ); |
483 | 488 | } elseif( isset( $opts['cat'] ) ) { |
— | — | @@ -493,9 +498,6 @@ |
494 | 499 | $result = $this->tidy($result); |
495 | 500 | } |
496 | 501 | |
497 | | - if ( isset( $opts['showtitle'] ) ) { |
498 | | - $out = $parser->mTitle . "\n$out"; |
499 | | - } |
500 | 502 | |
501 | 503 | $this->teardownGlobals(); |
502 | 504 | |
— | — | @@ -521,7 +523,7 @@ |
522 | 524 | return $default; |
523 | 525 | } |
524 | 526 | } |
525 | | - |
| 527 | + |
526 | 528 | private function parseOptions( $instring ) { |
527 | 529 | $opts = array(); |
528 | 530 | $lines = explode( "\n", $instring ); |
— | — | @@ -577,7 +579,7 @@ |
578 | 580 | } |
579 | 581 | return $opts; |
580 | 582 | } |
581 | | - |
| 583 | + |
582 | 584 | private function cleanupOption( $opt ) { |
583 | 585 | if( substr( $opt, 0, 1 ) == '"' ) { |
584 | 586 | return substr( $opt, 1, -1 ); |
— | — | @@ -605,7 +607,7 @@ |
606 | 608 | self::getOptionValue( 'variant', $opts, false ); |
607 | 609 | $maxtoclevel = |
608 | 610 | self::getOptionValue( 'wgMaxTocLevel', $opts, 999 ); |
609 | | - $linkHolderBatchSize = |
| 611 | + $linkHolderBatchSize = |
610 | 612 | self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 ); |
611 | 613 | |
612 | 614 | $settings = array( |
— | — | @@ -664,17 +666,19 @@ |
665 | 667 | |
666 | 668 | if ($config) { |
667 | 669 | $configLines = explode( "\n", $config ); |
668 | | - |
| 670 | + |
669 | 671 | foreach( $configLines as $line ) { |
670 | 672 | list( $var, $value ) = explode( '=', $line, 2 ); |
671 | | - |
| 673 | + |
672 | 674 | $settings[$var] = eval("return $value;" ); |
673 | 675 | } |
674 | 676 | } |
675 | | - |
| 677 | + |
676 | 678 | $this->savedGlobals = array(); |
677 | 679 | foreach( $settings as $var => $val ) { |
678 | | - $this->savedGlobals[$var] = $GLOBALS[$var]; |
| 680 | + if( array_key_exists( $var, $GLOBALS ) ) { |
| 681 | + $this->savedGlobals[$var] = $GLOBALS[$var]; |
| 682 | + } |
679 | 683 | $GLOBALS[$var] = $val; |
680 | 684 | } |
681 | 685 | $langObj = Language::factory( $lang ); |
— | — | @@ -706,9 +710,9 @@ |
707 | 711 | 'archive', 'user_groups', 'page_props', 'category' |
708 | 712 | ); |
709 | 713 | |
710 | | - if ($wgDBtype === 'mysql') |
| 714 | + if ($wgDBtype === 'mysql') |
711 | 715 | array_push( $tables, 'searchindex' ); |
712 | | - |
| 716 | + |
713 | 717 | // Allow extensions to add to the list of tables to duplicate; |
714 | 718 | // may be necessary if they hook into page save or other code |
715 | 719 | // which will require them while running tests. |
— | — | @@ -791,7 +795,7 @@ |
792 | 796 | |
793 | 797 | if ($wgDBtype == 'oracle') { |
794 | 798 | # Insert 0 and 1 user_ids to prevent FK violations |
795 | | - |
| 799 | + |
796 | 800 | #Anonymous user |
797 | 801 | $db->insert( 'user', array( |
798 | 802 | 'user_id' => 0, |
— | — | @@ -867,7 +871,7 @@ |
868 | 872 | $db->query('BEGIN FILL_WIKI_INFO; END;'); |
869 | 873 | */ |
870 | 874 | } |
871 | | - |
| 875 | + |
872 | 876 | /** |
873 | 877 | * Create a dummy uploads directory which will contain a couple |
874 | 878 | * of files in order to pass existence tests. |
— | — | @@ -1310,8 +1314,8 @@ |
1311 | 1315 | global $wgDBtype, $wgDBprefix; |
1312 | 1316 | parent::start(); |
1313 | 1317 | |
1314 | | - if( ! $this->db->tableExists( 'testrun' ) |
1315 | | - or ! $this->db->tableExists( 'testitem' ) ) |
| 1318 | + if( ! $this->db->tableExists( 'testrun' ) |
| 1319 | + or ! $this->db->tableExists( 'testitem' ) ) |
1316 | 1320 | { |
1317 | 1321 | print "WARNING> `testrun` table not found in database.\n"; |
1318 | 1322 | $this->prevRun = false; |
— | — | @@ -1347,7 +1351,7 @@ |
1348 | 1352 | $res = $this->db->select( 'testitem', array( 'ti_name', 'ti_success' ), |
1349 | 1353 | array( 'ti_run' => $this->prevRun ), __METHOD__ ); |
1350 | 1354 | foreach ( $res as $row ) { |
1351 | | - if ( !$this->parent->regex |
| 1355 | + if ( !$this->parent->regex |
1352 | 1356 | || preg_match( "/{$this->parent->regex}/i", $row->ti_name ) ) |
1353 | 1357 | { |
1354 | 1358 | $prevResults[$row->ti_name] = $row->ti_success; |
— | — | @@ -1420,7 +1424,7 @@ |
1421 | 1425 | |
1422 | 1426 | // Otherwise, this test has previous recorded results. |
1423 | 1427 | // See when this test last had a different result to what we're seeing now. |
1424 | | - $conds = array( |
| 1428 | + $conds = array( |
1425 | 1429 | 'ti_name' => $testname, |
1426 | 1430 | 'ti_success' => ($after == 'f' ? "1" : "0") ); |
1427 | 1431 | if ( $this->curRun ) { |
— | — | @@ -1483,8 +1487,8 @@ |
1484 | 1488 | global $wgDBtype, $wgDBprefix, $options; |
1485 | 1489 | $this->db->begin(); |
1486 | 1490 | |
1487 | | - if( ! $this->db->tableExists( 'testrun' ) |
1488 | | - or ! $this->db->tableExists( 'testitem' ) ) |
| 1491 | + if( ! $this->db->tableExists( 'testrun' ) |
| 1492 | + or ! $this->db->tableExists( 'testitem' ) ) |
1489 | 1493 | { |
1490 | 1494 | print "WARNING> `testrun` table not found in database. Trying to create table.\n"; |
1491 | 1495 | if ($wgDBtype === 'postgres') |
— | — | @@ -1495,7 +1499,7 @@ |
1496 | 1500 | $this->db->sourceFile( dirname(__FILE__) . '/testRunner.sql' ); |
1497 | 1501 | echo "OK, resuming.\n"; |
1498 | 1502 | } |
1499 | | - |
| 1503 | + |
1500 | 1504 | parent::start(); |
1501 | 1505 | |
1502 | 1506 | $this->db->insert( 'testrun', |
— | — | @@ -1537,17 +1541,17 @@ |
1538 | 1542 | $this->results = array(); |
1539 | 1543 | $this->ping( 'running' ); |
1540 | 1544 | } |
1541 | | - |
| 1545 | + |
1542 | 1546 | function record( $test, $result ) { |
1543 | 1547 | parent::record( $test, $result ); |
1544 | 1548 | $this->results[$test] = (bool)$result; |
1545 | 1549 | } |
1546 | | - |
| 1550 | + |
1547 | 1551 | function end() { |
1548 | 1552 | $this->ping( 'complete', $this->results ); |
1549 | 1553 | parent::end(); |
1550 | 1554 | } |
1551 | | - |
| 1555 | + |
1552 | 1556 | /** |
1553 | 1557 | * Inform a CodeReview instance that we've started or completed a test run... |
1554 | 1558 | * @param $remote array: info on remote target |
— | — | @@ -1558,16 +1562,16 @@ |
1559 | 1563 | */ |
1560 | 1564 | function ping( $status, $results=false ) { |
1561 | 1565 | global $wgParserTestRemote, $IP; |
1562 | | - |
| 1566 | + |
1563 | 1567 | $remote = $wgParserTestRemote; |
1564 | 1568 | $revId = SpecialVersion::getSvnRevision( $IP ); |
1565 | 1569 | $jsonResults = json_encode( $results ); |
1566 | | - |
| 1570 | + |
1567 | 1571 | if( !$remote ) { |
1568 | 1572 | print "Can't do remote upload without configuring \$wgParserTestRemote!\n"; |
1569 | 1573 | exit( 1 ); |
1570 | 1574 | } |
1571 | | - |
| 1575 | + |
1572 | 1576 | // Generate a hash MAC to validate our credentials |
1573 | 1577 | $message = array( |
1574 | 1578 | $remote['repo'], |
— | — | @@ -1579,7 +1583,7 @@ |
1580 | 1584 | $message[] = $jsonResults; |
1581 | 1585 | } |
1582 | 1586 | $hmac = hash_hmac( "sha1", implode( "|", $message ), $remote['secret'] ); |
1583 | | - |
| 1587 | + |
1584 | 1588 | $postData = array( |
1585 | 1589 | 'action' => 'codetestupload', |
1586 | 1590 | 'format' => 'json', |
— | — | @@ -1593,7 +1597,7 @@ |
1594 | 1598 | $postData['results'] = $jsonResults; |
1595 | 1599 | } |
1596 | 1600 | $response = $this->post( $remote['api-url'], $postData ); |
1597 | | - |
| 1601 | + |
1598 | 1602 | if( $response === false ) { |
1599 | 1603 | print "CodeReview info upload failed to reach server.\n"; |
1600 | 1604 | exit( 1 ); |
— | — | @@ -1611,7 +1615,7 @@ |
1612 | 1616 | exit( 1 ); |
1613 | 1617 | } |
1614 | 1618 | } |
1615 | | - |
| 1619 | + |
1616 | 1620 | function post( $url, $data ) { |
1617 | 1621 | // @fixme: for whatever reason, I get a 417 fail when using CURL's multipart form submit. |
1618 | 1622 | // If we do form URL encoding ourselves, though, it should work. |
Index: trunk/phase3/maintenance/parserTests.txt |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | # language=XXX set content language to XXX for this test |
23 | 23 | # variant=XXX set the variant of language for this test (eg zh-tw) |
24 | 24 | # disabled do not run test |
| 25 | +# showtitle make the first line the title |
25 | 26 | # comment run through Linker::formatComment() instead of main parser |
26 | 27 | # local format section links in edit comment text as local links |
27 | 28 | # |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | var $mTagHooks, $mTransparentTagHooks, $mFunctionHooks, $mFunctionSynonyms, $mVariables, |
95 | 95 | $mImageParams, $mImageParamsMagicArray, $mStripList, $mMarkerIndex, $mPreprocessor, |
96 | 96 | $mExtLinkBracketedRegex, $mUrlProtocols, $mDefaultStripList, $mVarCache, $mConf, |
97 | | - $mFunctionTagHooks, $mDoTitleConvert, $mDoContentConvert; |
| 97 | + $mFunctionTagHooks; |
98 | 98 | |
99 | 99 | |
100 | 100 | # Cleared with clearState(): |
— | — | @@ -147,8 +147,6 @@ |
148 | 148 | } |
149 | 149 | $this->mMarkerIndex = 0; |
150 | 150 | $this->mFirstCall = true; |
151 | | - $this->mDoTitleConvert = true; |
152 | | - $this->mDoContentConvert = true; |
153 | 151 | } |
154 | 152 | |
155 | 153 | /** |
— | — | @@ -258,19 +256,10 @@ |
259 | 257 | * Set the context title |
260 | 258 | */ |
261 | 259 | function setTitle( $t ) { |
262 | | - // If don't have a Title object, then convert what we have to |
263 | | - // a string and then to Title. If you pass in an object, make |
264 | | - // sure it has a __toString() method or you'll get a |
265 | | - // "Catchable fatal error" |
266 | | - if ( $t && !($t instanceOf FakeTitle) |
267 | | - && !($t instanceOf Title) ) { |
268 | | - $t = Title::newFromText( "$t" ); |
269 | | - } |
| 260 | + if ( !$t || $t instanceof FakeTitle ) { |
| 261 | + $t = Title::newFromText( 'NO TITLE' ); |
| 262 | + } |
270 | 263 | |
271 | | - if ( !($t instanceOf Title) ) { |
272 | | - $t = Title::newFromText( 'NO TITLE' ); |
273 | | - } |
274 | | - |
275 | 264 | if ( strval( $t->getFragment() ) !== '' ) { |
276 | 265 | # Strip the fragment to avoid various odd effects |
277 | 266 | $this->mTitle = clone $t; |
— | — | @@ -316,7 +305,7 @@ |
317 | 306 | * to internalParse() which does all the real work. |
318 | 307 | */ |
319 | 308 | |
320 | | - global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang; |
| 309 | + global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion; |
321 | 310 | $fname = __METHOD__.'-' . wfGetCaller(); |
322 | 311 | wfProfileIn( __METHOD__ ); |
323 | 312 | wfProfileIn( $fname ); |
— | — | @@ -360,7 +349,10 @@ |
361 | 350 | // The position of the convert() call should not be changed. it |
362 | 351 | // assumes that the links are all replaced and the only thing left |
363 | 352 | // is the <nowiki> mark. |
364 | | - if ( $this->mDoContentConvert && !$this->mTitle->isConversionTable()) { |
| 353 | + if ( !( $wgDisableLangConversion |
| 354 | + || isset( $this->mDoubleUnderscores['nocontentconvert'] ) |
| 355 | + || $this->mTitle->isTalkPage() |
| 356 | + || $this->mTitle->isConversionTable() ) ) { |
365 | 357 | $text = $wgContLang->convert( $text ); |
366 | 358 | } |
367 | 359 | |
— | — | @@ -369,9 +361,10 @@ |
370 | 362 | // rule but content conversion was not done, then the parser |
371 | 363 | // won't pick it up. This is probably expected behavior. |
372 | 364 | if ( $wgContLang->getConvRuleTitle() ) { |
373 | | - $this->setTitle( $wgContLang->getConvRuleTitle() ); |
374 | | - } elseif ( $this->mDoTitleConvert && !$this->mTitle->isConversionTable() ) { |
375 | | - $this->setTitle( $wgContLang->convert( $title ) ); |
| 365 | + $this->mOutput->setTitleText( $wgContLang->getConvRuleTitle() ); |
| 366 | + } elseif ( !( $wgDisableLangConversion |
| 367 | + || isset( $this->mDoubleUnderscores['notitleconvert'] ) ) ) { |
| 368 | + $this->mOutput->setTitleText( $wgContLang->convert( $title ) ); |
376 | 369 | } |
377 | 370 | |
378 | 371 | $text = $this->mStripState->unstripNoWiki( $text ); |
— | — | @@ -451,6 +444,7 @@ |
452 | 445 | $text .= "\n<!-- \n$limitReport-->\n"; |
453 | 446 | } |
454 | 447 | $this->mOutput->setText( $text ); |
| 448 | + |
455 | 449 | $this->mRevisionId = $oldRevisionId; |
456 | 450 | $this->mRevisionTimestamp = $oldRevisionTimestamp; |
457 | 451 | wfProfileOut( $fname ); |
— | — | @@ -3423,7 +3417,6 @@ |
3424 | 3418 | * Fills $this->mDoubleUnderscores, returns the modified text |
3425 | 3419 | */ |
3426 | 3420 | function doDoubleUnderscore( $text ) { |
3427 | | - global $wgDisableLangConversion; |
3428 | 3421 | wfProfileIn( __METHOD__ ); |
3429 | 3422 | |
3430 | 3423 | // The position of __TOC__ needs to be recorded |
— | — | @@ -3466,18 +3459,6 @@ |
3467 | 3460 | $this->addTrackingCategory( 'index-category' ); |
3468 | 3461 | } |
3469 | 3462 | |
3470 | | - if ( !$wgDisableLangConversion ) { |
3471 | | - if( isset( $this->mDoubleUnderscores['notitleconvert'] ) ){ |
3472 | | - $this->mDoTitleConvert = false; |
3473 | | - } |
3474 | | - |
3475 | | - // Don't convert talk pages |
3476 | | - if( isset( $this->mDoubleUnderscores['nocontentconvert'] ) |
3477 | | - && !$this->mTitle->isTalkPage() ){ |
3478 | | - $this->mDoContentConvert = false; |
3479 | | - } |
3480 | | - } |
3481 | | - |
3482 | 3463 | wfProfileOut( __METHOD__ ); |
3483 | 3464 | return $text; |
3484 | 3465 | } |
Index: trunk/phase3/includes/parser/ParserOutput.php |
— | — | @@ -28,11 +28,6 @@ |
29 | 29 | $mTOCHTML = ''; # HTML of the TOC |
30 | 30 | private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change. |
31 | 31 | |
32 | | - /** |
33 | | - * Overridden title for display |
34 | | - */ |
35 | | - private $displayTitle = false; |
36 | | - |
37 | 32 | function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(), |
38 | 33 | $containsOldMagic = false, $titletext = '' ) |
39 | 34 | { |
— | — | @@ -183,7 +178,7 @@ |
184 | 179 | * @param string $text Desired title text |
185 | 180 | */ |
186 | 181 | public function setDisplayTitle( $text ) { |
187 | | - $this->displayTitle = $text; |
| 182 | + $this->setTitleText( $text ); |
188 | 183 | } |
189 | 184 | |
190 | 185 | /** |
— | — | @@ -192,7 +187,10 @@ |
193 | 188 | * @return string |
194 | 189 | */ |
195 | 190 | public function getDisplayTitle() { |
196 | | - return $this->displayTitle; |
| 191 | + $t = $this->getTitleText( $text ); |
| 192 | + if( $t === '' ) { |
| 193 | + return false; |
| 194 | + } |
197 | 195 | } |
198 | 196 | |
199 | 197 | /** |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -347,8 +347,6 @@ |
348 | 348 | * Bad tags that were escaped in <h1> will still be escaped in <title>, and good tags like <i> will be dropped entirely. |
349 | 349 | */ |
350 | 350 | public function setPageTitle( $name ) { |
351 | | - global $wgContLang; |
352 | | - |
353 | 351 | # change "<script>foo&bar</script>" to "<script>foo&bar</script>" |
354 | 352 | # but leave "<i>foobar</i>" alone |
355 | 353 | $nameWithTags = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $name ) ); |
— | — | @@ -617,12 +615,8 @@ |
618 | 616 | } |
619 | 617 | } |
620 | 618 | // Page title |
621 | | - $dt = $parserOutput->getDisplayTitle(); |
622 | 619 | $title = $parserOutput->getTitleText(); |
623 | | - if ( $dt !== false ) { |
624 | | - $this->setPageTitle( $dt ); |
625 | | - } |
626 | | - else if ( $title != '' ) { |
| 620 | + if ( $title != '' ) { |
627 | 621 | $this->setPageTitle( $title ); |
628 | 622 | } |
629 | 623 | |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -131,6 +131,14 @@ |
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
| 135 | + * Get the title produced by the conversion rule. |
| 136 | + * @returns string |
| 137 | + */ |
| 138 | + function getConvRuleTitle() { |
| 139 | + return $this->mConvRuleTitle; |
| 140 | + } |
| 141 | + |
| 142 | + /** |
135 | 143 | * Get preferred language variants. |
136 | 144 | * @param boolean $fromUser Get it from $wgUser's preferences |
137 | 145 | * @param boolean $fromHeader Get it from Accept-Language |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -34,12 +34,12 @@ |
35 | 35 | */ |
36 | 36 | class FakeConverter { |
37 | 37 | var $mLang; |
38 | | - var $mConvRuleTitle; |
39 | 38 | function FakeConverter($langobj) {$this->mLang = $langobj;} |
40 | 39 | function autoConvertToAllVariants($text) {return $text;} |
41 | 40 | function convert($t, $i) {return $t;} |
42 | 41 | function getVariants() { return array( $this->mLang->getCode() ); } |
43 | 42 | function getPreferredVariant() { return $this->mLang->getCode(); } |
| 43 | + function getConvRuleTitle() { return false; } |
44 | 44 | function findVariantLink(&$l, &$n, $ignoreOtherCond = false) {} |
45 | 45 | function getExtraHashOptions() {return '';} |
46 | 46 | function getParsedTitle() {return '';} |
— | — | @@ -2670,6 +2670,6 @@ |
2671 | 2671 | * Get the conversion rule title, if any. |
2672 | 2672 | */ |
2673 | 2673 | function getConvRuleTitle() { |
2674 | | - return $this->mConverter->mConvRuleTitle; |
| 2674 | + return $this->mConverter->getConvRuleTitle(); |
2675 | 2675 | } |
2676 | 2676 | } |