r108316 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108315‎ | r108316 | r108317 >
Date:12:19, 7 January 2012
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Don't select (even twice for PHPUnit tests) "FOR UPDATE", but use the master database directly instead
* Also pass the line number
* Removed useless usage of $title when throwing the exception about invalid since that variable is always null
* Added $ignoreDuplicate parameter to ParserTest::addArticle()
Modified paths:
  • /trunk/phase3/tests/parser/parserTest.inc (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
@@ -698,7 +698,7 @@
699699 //Various action functions
700700
701701 public function addArticle( $name, $text, $line ) {
702 - self::$articles[$name] = $text;
 702+ self::$articles[$name] = array( $text, $line );
703703 }
704704
705705 public function publishTestArticles() {
@@ -706,12 +706,9 @@
707707 return;
708708 }
709709
710 - foreach ( self::$articles as $name => $text ) {
711 - $title = Title::newFromText( $name );
712 -
713 - if ( $title->getArticleID( Title::GAID_FOR_UPDATE ) == 0 ) {
714 - ParserTest::addArticle( $name, $text );
715 - }
 710+ foreach ( self::$articles as $name => $info ) {
 711+ list( $text, $line ) = $info;
 712+ ParserTest::addArticle( $name, $text, $line, 'ignoreduplicate' );
716713 }
717714 }
718715
Index: trunk/phase3/tests/parser/parserTest.inc
@@ -1162,29 +1162,34 @@
11631163 * @param $name String: the title, including any prefix
11641164 * @param $text String: the article text
11651165 * @param $line Integer: the input line number, for reporting errors
 1166+ * @param $ignoreDuplicate Boolean: whether to silently ignore duplicate pages
11661167 */
1167 - static public function addArticle( $name, $text, $line = 'unknown' ) {
 1168+ static public function addArticle( $name, $text, $line = 'unknown', $ignoreDuplicate = '' ) {
11681169 global $wgCapitalLinks;
11691170
1170 - $text = self::chomp($text);
1171 -
11721171 $oldCapitalLinks = $wgCapitalLinks;
11731172 $wgCapitalLinks = true; // We only need this from SetupGlobals() See r70917#c8637
11741173
 1174+ $text = self::chomp( $text );
11751175 $name = self::chomp( $name );
 1176+
11761177 $title = Title::newFromText( $name );
11771178
11781179 if ( is_null( $title ) ) {
1179 - throw new MWException( "invalid title ('$name' => '$title') at line $line\n" );
 1180+ throw new MWException( "invalid title '$name' at line $line\n" );
11801181 }
11811182
1182 - $aid = $title->getArticleID( Title::GAID_FOR_UPDATE );
 1183+ $page = WikiPage::factory( $title );
 1184+ $page->loadPageData( 'fromdbmaster' );
11831185
1184 - if ( $aid != 0 ) {
1185 - throw new MWException( "duplicate article '$name' at line $line\n" );
 1186+ if ( $page->exists() ) {
 1187+ if ( $ignoreDuplicate == 'ignoreduplicate' ) {
 1188+ return;
 1189+ } else {
 1190+ throw new MWException( "duplicate article '$name' at line $line\n" );
 1191+ }
11861192 }
11871193
1188 - $page = WikiPage::factory( $title );
11891194 $page->doEdit( $text, '', EDIT_NEW );
11901195
11911196 $wgCapitalLinks = $oldCapitalLinks;

Comments

#Comment by 😂 (talk | contribs)   20:22, 7 January 2012

I tried to get rid of parserTest.inc yesterday, but it broke stuff related to addArticle() :(

#Comment by Aaron Schulz (talk | contribs)   20:41, 7 January 2012

Also, apparently parserTest.inc gets run with run-test.bat, so are they both getting run or something?

Status & tagging log