r61465 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61464‎ | r61465 | r61466 >
Date:15:44, 24 January 2010
Author:maxsem
Status:resolved (Comments)
Tags:
Comment:
Parser tests:
* Now defining a message in MediaWiki: namespace with !! article works
* Started covering image blacklisting with tests, only one basic test so far.
Modified paths:
  • /trunk/phase3/maintenance/parserTests.inc (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.inc
@@ -825,8 +825,25 @@
826826 'img_metadata' => serialize( array() ),
827827 ) );
828828
 829+ # This image will be blacklisted in [[MediaWiki:Bad image list]]
 830+ $db->insert( 'image', array(
 831+ 'img_name' => 'Bad.jpg',
 832+ 'img_size' => 12345,
 833+ 'img_description' => 'zomgnotcensored',
 834+ 'img_user' => 1,
 835+ 'img_user_text' => 'WikiSysop',
 836+ 'img_timestamp' => $db->timestamp( '20010115123500' ),
 837+ 'img_width' => 320,
 838+ 'img_height' => 240,
 839+ 'img_bits' => 24,
 840+ 'img_media_type' => MEDIATYPE_BITMAP,
 841+ 'img_major_mime' => "image",
 842+ 'img_minor_mime' => "jpeg",
 843+ 'img_metadata' => serialize( array() ),
 844+ ) );
 845+
829846 # Update certain things in site_stats
830 - $db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 1, 'ss_good_articles' => 1 ) );
 847+ $db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ) );
831848
832849 # Reinitialise the LocalisationCache to match the database state
833850 Language::getLocalisationCache()->unloadAll();
@@ -896,6 +913,9 @@
897914 }
898915 wfMkdirParents( $dir . '/3/3a' );
899916 copy( "$IP/skins/monobook/headbg.jpg", "$dir/3/3a/Foobar.jpg" );
 917+
 918+ wfMkdirParents( $dir . '/0/09' );
 919+ copy( "$IP/skins/monobook/headbg.jpg", "$dir/0/09/Bad.jpg" );
900920 return $dir;
901921 }
902922
@@ -931,6 +951,8 @@
932952 "$dir/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg",
933953 "$dir/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg",
934954 "$dir/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg",
 955+
 956+ "$dir/0/09/Bad.jpg",
935957 )
936958 );
937959
@@ -943,6 +965,10 @@
944966 "$dir/thumb/3/3a/Foobar.jpg",
945967 "$dir/thumb/3/3a",
946968 "$dir/thumb/3",
 969+
 970+ "$dir/0/09/",
 971+ "$dir/0/",
 972+
947973 "$dir/thumb",
948974 "$dir",
949975 )
@@ -1095,6 +1121,7 @@
10961122 * @param int $line the input line number, for reporting errors
10971123 */
10981124 private function addArticle($name, $text, $line) {
 1125+ global $wgMessageCache;
10991126 $this->setupGlobals();
11001127 $title = Title::newFromText( $name );
11011128 if ( is_null($title) ) {
@@ -1108,6 +1135,10 @@
11091136
11101137 $art = new Article($title);
11111138 $art->insertNewArticle($text, '', false, false );
 1139+ if( $title->getNamespace() == NS_MEDIAWIKI ) {
 1140+ $wgMessageCache->replace( $title->getDBkey(), $text );
 1141+ }
 1142+
11121143 $this->teardownGlobals();
11131144 }
11141145
Index: trunk/phase3/maintenance/parserTests.txt
@@ -7812,7 +7812,18 @@
78137813
78147814 !! end
78157815
 7816+!!article
 7817+MediaWiki:bad image list
 7818+!!text
 7819+* [[File:Bad.jpg]] except [[Nasty page]]
 7820+!!endarticle
78167821
 7822+!! test
 7823+Bad images - basic functionality
 7824+!! input
 7825+[[File:Bad.jpg]]
 7826+!! result
 7827+!! end
78177828
78187829
78197830 TODO:

Follow-up revisions

RevisionCommit summaryAuthorDate
r61500Fix parser test broken by r61465overlordq20:39, 25 January 2010
r61748Rv extra precautions from r61465. I think I was confused by bug 16039 into ad...maxsem18:16, 31 January 2010

Comments

#Comment by OverlordQ (talk | contribs)   20:36, 25 January 2010
Running test Magic Word: {{NUMBEROFFILES}}... FAILED!
--- /tmp/mwParser-182526930-expected    2010-01-25 14:32:26.000000000 -0600
+++ /tmp/mwParser-182526930-actual      2010-01-25 14:32:26.000000000 -0600
@@ -1,2 +1,2 @@
-<p>1
+<p>2
 </p>

1 previously passing test(s) now FAILING! :(

* Magic Word: {{NUMBEROFFILES}}  [Introduced between 25-Jan-2010 14:30:59, 1.16alpha (r61464) and 25-Jan-2010 14:32:17, 1.16alpha (r61465)]
#Comment by MaxSem (talk | contribs)   03:41, 26 January 2010

Strange, did this test not run for me? Anyway, I'm currently away from my development PC, and will be back in a few days, so this could be reverted if it causes problems.

#Comment by Tim Starling (talk | contribs)   01:16, 29 January 2010

The $wgMessageCache->replace() call is unnecessary, it's already called by Article::insertNewArticle:

Backtrace:
#0 .../includes/Article.php(3347): MessageCache->replace('Fake', '==header==')
#1 .../includes/Article.php(2057): Article->editUpdates('==header==', 'Created page wi...', false, '20100129011413', 41, true)
#2 .../includes/Article.php(1740): Article->doEdit('==header==', '', 97)
#3 .../maintenance/parserTests.inc(1137): Article->insertNewArticle('==header==', '', false, false)
#4 .../maintenance/parserTests.inc(313): ParserTest->addArticle('MediaWiki:Fake', '==header==', 6603)
#5 .../maintenance/parserTests.inc(279): ParserTest->runFile('/home/tstarling...')
#6 .../maintenance/parserTests.php(86): ParserTest->runTestsFromFiles(Array)
#7 {main}

Status & tagging log