r113157 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113156‎ | r113157 | r113158 >
Date:17:36, 6 March 2012
Author:reedy
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/REL1_19/phase3 (modified) (history)
  • /branches/REL1_19/phase3/includes (modified) (history)
  • /branches/REL1_19/phase3/includes/Block.php (modified) (history)
  • /branches/REL1_19/phase3/includes/DefaultSettings.php (modified) (history)
  • /branches/REL1_19/phase3/includes/cache/MessageCache.php (modified) (history)
  • /branches/REL1_19/phase3/includes/filerepo/backend/FileBackend.php (modified) (history)
  • /branches/REL1_19/phase3/includes/parser/Parser.php (modified) (history)
  • /branches/REL1_19/phase3/includes/specials (modified) (history)
  • /branches/REL1_19/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)
  • /branches/REL1_19/phase3/includes/specials/SpecialUserlogin.php (modified) (history)
  • /branches/REL1_19/phase3/languages (modified) (history)
  • /branches/REL1_19/phase3/languages/messages/MessagesSa.php (modified) (history)
  • /branches/REL1_19/phase3/maintenance/parse.php (modified) (history)
  • /branches/REL1_19/phase3/tests/phpunit/includes/BlockTest.php (modified) (history)
  • /branches/REL1_19/phase3/tests/phpunit/includes/TitlePermissionTest.php (modified) (history)

Diff [purge]

Index: branches/REL1_19/phase3/maintenance/parse.php
@@ -14,8 +14,8 @@
1515 *
1616 * Example2:
1717 * @code
18 - * $ echo "'''bold'''" > /tmp/foo
19 - * $ php parse.php --file /tmp/foo
 18+ * $ echo "'''bold'''" > /tmp/foo.txt
 19+ * $ php parse.php /tmp/foo.txt
2020 * <p><b>bold</b>
2121 * </p>$
2222 * @endcode
@@ -37,10 +37,10 @@
3838 protected $parser;
3939
4040 public function __construct() {
 41+ parent::__construct();
4142 $this->mDescription = "Parse a given wikitext";
4243 $this->addOption( 'title', 'Title name for the given wikitext (Default: \'CLIParser\')', false, true );
43 - $this->addOption( 'file', 'File containing wikitext (Default: stdin)', false, true );
44 - parent::__construct();
 44+ $this->addArg( 'file', 'File containing wikitext (Default: stdin)', false );
4545 }
4646
4747 public function execute() {
@@ -57,13 +57,19 @@
5858 }
5959
6060 /**
61 - * Get wikitext from --file or from STDIN
 61+ * Get wikitext from a the file passed as argument or STDIN
6262 * @return string Wikitext
6363 */
6464 protected function Wikitext() {
65 - return file_get_contents(
66 - $this->getOption( 'file', 'php://stdin' )
67 - );
 65+
 66+ $php_stdin = 'php://stdin';
 67+ $input_file = $this->getArg( 0, $php_stdin );
 68+
 69+ if( $input_file === $php_stdin ) {
 70+ $this->error( basename(__FILE__) .": warning: reading wikitext from STDIN\n" );
 71+ }
 72+
 73+ return file_get_contents( $input_file );
6874 }
6975
7076 protected function initParser() {
Index: branches/REL1_19/phase3/tests/phpunit/includes/BlockTest.php
@@ -35,7 +35,7 @@
3636 $oldBlock->delete();
3737 }
3838
39 - $this->block = new Block( 'UTBlockee', 1, 0,
 39+ $this->block = new Block( 'UTBlockee', $user->getID(), 0,
4040 'Parce que', 0, false, time() + 100500
4141 );
4242 $this->madeAt = wfTimestamp( TS_MW );
Index: branches/REL1_19/phase3/tests/phpunit/includes/TitlePermissionTest.php
@@ -629,7 +629,7 @@
630630 $prev = time();
631631 $now = time() + 120;
632632 $this->user->mBlockedby = $this->user->getId();
633 - $this->user->mBlock = new Block( '127.0.8.1', $this->user->getId(), $this->user->getId(),
 633+ $this->user->mBlock = new Block( '127.0.8.1', 0, $this->user->getId(),
634634 'no reason given', $prev + 3600, 1, 0 );
635635 $this->user->mBlock->mTimestamp = 0;
636636 $this->assertEquals( array( array( 'autoblockedtext',
@@ -646,7 +646,7 @@
647647 global $wgLocalTZoffset;
648648 $wgLocalTZoffset = -60;
649649 $this->user->mBlockedby = $this->user->getName();
650 - $this->user->mBlock = new Block( '127.0.8.1', 2, 1, 'no reason given', $now, 0, 10 );
 650+ $this->user->mBlock = new Block( '127.0.8.1', 0, 1, 'no reason given', $now, 0, 10 );
651651 $this->assertEquals( array( array( 'blockedtext',
652652 '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
653653 'Useruser', null, '23:00, 31 December 1969', '127.0.8.1',
Index: branches/REL1_19/phase3/includes/parser/Parser.php
@@ -370,13 +370,16 @@
371371 */
372372 if ( !( $wgDisableLangConversion
373373 || isset( $this->mDoubleUnderscores['nocontentconvert'] )
374 - || $this->mTitle->isConversionTable()
375 - || $this->mOptions->getInterfaceMessage() ) ) {
376 -
377 - # The position of the convert() call should not be changed. it
378 - # assumes that the links are all replaced and the only thing left
379 - # is the <nowiki> mark.
380 - $text = $this->getFunctionLang()->convert( $text );
 374+ || $this->mTitle->isConversionTable() ) )
 375+ {
 376+ # Run convert unconditionally in 1.18-compatible mode
 377+ global $wgBug34832TransitionalRollback;
 378+ if ( $wgBug34832TransitionalRollback || !$this->mOptions->getInterfaceMessage() ) {
 379+ # The position of the convert() call should not be changed. it
 380+ # assumes that the links are all replaced and the only thing left
 381+ # is the <nowiki> mark.
 382+ $text = $this->getConverterLanguage()->convert( $text );
 383+ }
381384 }
382385
383386 /**
@@ -392,11 +395,11 @@
393396 || isset( $this->mDoubleUnderscores['notitleconvert'] )
394397 || $this->mOutput->getDisplayTitle() !== false ) )
395398 {
396 - $convruletitle = $this->getFunctionLang()->getConvRuleTitle();
 399+ $convruletitle = $this->getConverterLanguage()->getConvRuleTitle();
397400 if ( $convruletitle ) {
398401 $this->mOutput->setTitleText( $convruletitle );
399402 } else {
400 - $titleText = $this->getFunctionLang()->convertTitle( $title );
 403+ $titleText = $this->getConverterLanguage()->convertTitle( $title );
401404 $this->mOutput->setTitleText( $titleText );
402405 }
403406 }
@@ -692,9 +695,18 @@
693696 }
694697
695698 /**
 699+ * Get a language object for use in parser functions such as {{FORMATNUM:}}
696700 * @return Language
697701 */
698702 function getFunctionLang() {
 703+ return $this->getTargetLanguage();
 704+ }
 705+
 706+ /**
 707+ * Get the target language for the content being parsed. This is usually the
 708+ * language that the content is in.
 709+ */
 710+ function getTargetLanguage() {
699711 $target = $this->mOptions->getTargetLanguage();
700712 if ( $target !== null ) {
701713 return $target;
@@ -707,6 +719,18 @@
708720 }
709721
710722 /**
 723+ * Get the language object for language conversion
 724+ */
 725+ function getConverterLanguage() {
 726+ global $wgBug34832TransitionalRollback, $wgContLang;
 727+ if ( $wgBug34832TransitionalRollback ) {
 728+ return $wgContLang;
 729+ } else {
 730+ return $this->getTargetLanguage();
 731+ }
 732+ }
 733+
 734+ /**
711735 * Get a User object either from $this->mUser, if set, or from the
712736 * ParserOptions object otherwise
713737 *
@@ -1225,7 +1249,8 @@
12261250 $text = $this->maybeMakeExternalImage( $url );
12271251 if ( $text === false ) {
12281252 # Not an image, make a link
1229 - $text = Linker::makeExternalLink( $url, $this->getFunctionLang()->markNoConversion($url), true, 'free',
 1253+ $text = Linker::makeExternalLink( $url,
 1254+ $this->getConverterLanguage()->markNoConversion($url), true, 'free',
12301255 $this->getExternalLinkAttribs( $url ) );
12311256 # Register it in the output object...
12321257 # Replace unnecessary URL escape codes with their equivalent characters
@@ -1489,7 +1514,7 @@
14901515 # No link text, e.g. [http://domain.tld/some.link]
14911516 if ( $text == '' ) {
14921517 # Autonumber
1493 - $langObj = $this->getFunctionLang();
 1518+ $langObj = $this->getTargetLanguage();
14941519 $text = '[' . $langObj->formatNum( ++$this->mAutonumber ) . ']';
14951520 $linktype = 'autonumber';
14961521 } else {
@@ -1498,7 +1523,7 @@
14991524 list( $dtrail, $trail ) = Linker::splitTrail( $trail );
15001525 }
15011526
1502 - $text = $this->getFunctionLang()->markNoConversion( $text );
 1527+ $text = $this->getConverterLanguage()->markNoConversion( $text );
15031528
15041529 $url = Sanitizer::cleanUrl( $url );
15051530
@@ -1678,7 +1703,7 @@
16791704 $line = $a->current(); # Workaround for broken ArrayIterator::next() that returns "void"
16801705 $s = substr( $s, 1 );
16811706
1682 - $useLinkPrefixExtension = $this->getFunctionLang()->linkPrefixExtension();
 1707+ $useLinkPrefixExtension = $this->getTargetLanguage()->linkPrefixExtension();
16831708 $e2 = null;
16841709 if ( $useLinkPrefixExtension ) {
16851710 # Match the end of a line for a word that's not followed by whitespace,
@@ -1704,8 +1729,9 @@
17051730 $prefix = '';
17061731 }
17071732
1708 - if ( $this->getFunctionLang()->hasVariants() ) {
1709 - $selflink = $this->getFunctionLang()->autoConvertToAllVariants( $this->mTitle->getPrefixedText() );
 1733+ if ( $this->getConverterLanguage()->hasVariants() ) {
 1734+ $selflink = $this->getConverterLanguage()->autoConvertToAllVariants(
 1735+ $this->mTitle->getPrefixedText() );
17101736 } else {
17111737 $selflink = array( $this->mTitle->getPrefixedText() );
17121738 }
@@ -1923,7 +1949,7 @@
19241950 }
19251951 $sortkey = Sanitizer::decodeCharReferences( $sortkey );
19261952 $sortkey = str_replace( "\n", '', $sortkey );
1927 - $sortkey = $this->getFunctionLang()->convertCategoryKey( $sortkey );
 1953+ $sortkey = $this->getConverterLanguage()->convertCategoryKey( $sortkey );
19281954 $this->mOutput->addCategory( $nt->getDBkey(), $sortkey );
19291955
19301956 /**
@@ -3022,7 +3048,7 @@
30233049 * @private
30243050 */
30253051 function braceSubstitution( $piece, $frame ) {
3026 - global $wgNonincludableNamespaces;
 3052+ global $wgNonincludableNamespaces, $wgContLang;
30273053 wfProfileIn( __METHOD__ );
30283054 wfProfileIn( __METHOD__.'-setup' );
30293055
@@ -3125,7 +3151,7 @@
31263152 $function = $this->mFunctionSynonyms[1][$function];
31273153 } else {
31283154 # Case insensitive functions
3129 - $function = $this->getFunctionLang()->lc( $function );
 3155+ $function = $wgContLang->lc( $function );
31303156 if ( isset( $this->mFunctionSynonyms[0][$function] ) ) {
31313157 $function = $this->mFunctionSynonyms[0][$function];
31323158 } else {
@@ -3201,8 +3227,8 @@
32023228 if ( $title ) {
32033229 $titleText = $title->getPrefixedText();
32043230 # Check for language variants if the template is not found
3205 - if ( $this->getFunctionLang()->hasVariants() && $title->getArticleID() == 0 ) {
3206 - $this->getFunctionLang()->findVariantLink( $part1, $title, true );
 3231+ if ( $this->getConverterLanguage()->hasVariants() && $title->getArticleID() == 0 ) {
 3232+ $this->getConverterLanguage()->findVariantLink( $part1, $title, true );
32073233 }
32083234 # Do recursion depth check
32093235 $limit = $this->mOptions->getMaxTemplateDepth();
@@ -4033,7 +4059,7 @@
40344060 if ( $dot ) {
40354061 $numbering .= '.';
40364062 }
4037 - $numbering .= $this->getFunctionLang()->formatNum( $sublevelCount[$i] );
 4063+ $numbering .= $this->getTargetLanguage()->formatNum( $sublevelCount[$i] );
40384064 $dot = 1;
40394065 }
40404066 }
Index: branches/REL1_19/phase3/includes/filerepo/backend/FileBackend.php
@@ -51,6 +51,7 @@
5252 * $config includes:
5353 * 'name' : The unique name of this backend.
5454 * This should consist of alphanumberic, '-', and '_' characters.
 55+ * This name should not be changed after use.
5556 * 'wikiId' : Prefix to container names that is unique to this wiki.
5657 * This should consist of alphanumberic, '-', and '_' characters.
5758 * 'lockManager' : Registered name of a file lock manager to use.
@@ -61,6 +62,9 @@
6263 */
6364 public function __construct( array $config ) {
6465 $this->name = $config['name'];
 66+ if ( !preg_match( '!^[a-zA-Z0-9-_]{1,255}$!', $this->name ) ) {
 67+ throw new MWException( "Backend name `{$this->name}` is invalid." );
 68+ }
6569 $this->wikiId = isset( $config['wikiId'] )
6670 ? $config['wikiId']
6771 : wfWikiID(); // e.g. "my_wiki-en_"
Index: branches/REL1_19/phase3/includes/cache/MessageCache.php
@@ -833,14 +833,9 @@
834834
835835 $parser = $this->getParser();
836836 $popts = $this->getParserOptions();
 837+ $popts->setInterfaceMessage( $interface );
 838+ $popts->setTargetLanguage( $language );
837839
838 - if ( $interface ) {
839 - $popts->setInterfaceMessage( true );
840 - }
841 - if ( $language !== null ) {
842 - $popts->setTargetLanguage( $language );
843 - }
844 -
845840 wfProfileIn( __METHOD__ );
846841 if ( !$title || !$title instanceof Title ) {
847842 global $wgTitle;
Property changes on: branches/REL1_19/phase3/includes/cache/MessageCache.php
___________________________________________________________________
Modified: svn:mergeinfo
848843 Merged /trunk/phase3/includes/cache/MessageCache.php:r112872-112873,112988,113001,113024,113039,113046,113099
Index: branches/REL1_19/phase3/includes/DefaultSettings.php
@@ -2176,6 +2176,17 @@
21772177 */
21782178 $wgLocalTZoffset = null;
21792179
 2180+/**
 2181+ * If set to true, this will roll back a few bug fixes introduced in 1.19,
 2182+ * emulating the 1.18 behaviour, to avoid introducing bug 34832. In 1.19,
 2183+ * language variant conversion is disabled in interface messages. Setting this
 2184+ * to true re-enables it.
 2185+ *
 2186+ * This variable should be removed (implicitly false) in 1.20 or earlier.
 2187+ */
 2188+$wgBug34832TransitionalRollback = true;
 2189+
 2190+
21802191 /** @} */ # End of language/charset settings
21812192
21822193 /*************************************************************************//**
Index: branches/REL1_19/phase3/includes/specials/SpecialUserlogin.php
@@ -797,7 +797,7 @@
798798 function resetLoginForm( $error ) {
799799 $this->getOutput()->addHTML( Xml::element('p', array( 'class' => 'error' ), $error ) );
800800 $reset = new SpecialChangePassword();
801 - $reset->setContext( $this );
 801+ $reset->setContext( $this->getContext() );
802802 $reset->execute( null );
803803 }
804804
Index: branches/REL1_19/phase3/includes/specials/SpecialRecentchanges.php
@@ -633,10 +633,13 @@
634634 function setTopText( FormOptions $opts ) {
635635 global $wgContLang;
636636 $this->getOutput()->addWikiText(
637 - Html::rawElement( 'p',
638 - array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ),
639 - "\n" . wfMsgForContentNoTrans( 'recentchangestext' ) . "\n"
640 - ), false );
 637+ Html::rawElement( 'p',
 638+ array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ),
 639+ "\n" . wfMsgForContentNoTrans( 'recentchangestext' ) . "\n"
 640+ ),
 641+ /* $lineStart */ false,
 642+ /* $interface */ false
 643+ );
641644 }
642645
643646 /**
Property changes on: branches/REL1_19/phase3/includes/specials
___________________________________________________________________
Modified: svn:mergeinfo
644647 Merged /trunk/phase3/includes/specials:r112872-112873,112988,113001,113024,113039,113046,113099
Index: branches/REL1_19/phase3/includes/Block.php
@@ -71,6 +71,9 @@
7272 }
7373
7474 $this->setTarget( $address );
 75+ if ( $this->target instanceof User && $user ) {
 76+ $this->target->setId( $user ); // needed for foreign users
 77+ }
7578 if ( $by ) { // local user
7679 $this->setBlocker( User::newFromID( $by ) );
7780 } else { // foreign user
Property changes on: branches/REL1_19/phase3/includes
___________________________________________________________________
Modified: svn:mergeinfo
7881 Merged /trunk/phase3/includes:r112563,112566,112838,112872-112873,112988,113001,113024,113039,113046,113099
Index: branches/REL1_19/phase3/languages/messages/MessagesSa.php
@@ -536,7 +536,6 @@
537537 'versionrequiredtext' => 'एतत्पृष्ठं प्रयोक्तुं मीडियाविकि इत्येतस्य $1तमा आवृत्तिः आवश्यकी। पश्यतु [[Special:Version|आवृत्ति-सूचिका]]',
538538
539539 'ok' => 'अस्तु',
540 -'pagetitle' => '',
541540 'retrievedfrom' => '"$1" इत्यस्माद् उद्धृतम्',
542541 'youhavenewmessages' => 'भवदर्थम् $1 सन्ति। ($2).',
543542 'newmessageslink' => 'नूतनाः सन्देशाः',
Property changes on: branches/REL1_19/phase3/languages
___________________________________________________________________
Modified: svn:mergeinfo
544543 Merged /trunk/phase3/languages:r113039,113046,113099
Property changes on: branches/REL1_19/phase3
___________________________________________________________________
Modified: svn:mergeinfo
545544 Merged /trunk/phase3:r112563,112566,112838,112872-112873,112988,113001,113024,113039,113046,113099

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112563Force the target user ID to be the correct foreign ID on the relevant local w...aaron02:04, 28 February 2012
r112566r112563: Removed random bogus user IDs passed into to Block constructor in testsaaron02:32, 28 February 2012
r112838Actually enforce the FileBackend name requirements instead of just having a c...aaron21:55, 1 March 2012
r112872Fix for r86304: if MessageCache::parse() is called twice, once with $interfac...tstarling04:00, 2 March 2012
r112873(bug 34832) Parse recentchangestext with the interface option off, since it c...tstarling04:52, 2 March 2012
r112988make file an argument, --title is script specific...hashar23:05, 4 March 2012
r113001* Fix for r41340, r96405, r97849: introduce a function which gets the current...tstarling05:53, 5 March 2012
r113024Transitional patch for bug 34832: introduce a CI-style option to allow deploy...tstarling12:14, 5 March 2012
r113039Why is tis empty? Bug 34938nikerabbit15:13, 5 March 2012
r113046Fix minor issue from r112988reedy16:38, 5 March 2012
r113099Special pages aren't a contextsource. Ping r100114, pass $this->getContext()reedy22:43, 5 March 2012

Status & tagging log