r73976 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73975‎ | r73976 | r73977 >
Date:19:51, 29 September 2010
Author:hashar
Status:reverted (Comments)
Tags:
Comment:
Implements bug 24343 "localurl discards section id".
* parser hook 'linkurl' which use Title::getLinkUrl()
* very basic tests for the Title class
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/TitleTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/TitleTest.php
@@ -1,6 +1,10 @@
22 <?php
33
44 class TitleTest extends PHPUnit_Framework_TestCase {
 5+ function setUp() {
 6+ global $wgContLang;
 7+ $wgContLang = Language::factory( 'en' );
 8+ }
59
610 function testLegalChars() {
711 $titlechars = Title::legalChars();
@@ -14,4 +18,24 @@
1519 }
1620 }
1721 }
 22+
 23+ /**
 24+ * Test originally wrote to investigate bug 24343
 25+ * FIXME : some tests might fail depending on local settings.
 26+ */
 27+ function testGetURLS() {
 28+ global $wgArticlePath, $wgScript;
 29+
 30+ $title = Title::newFromText( 'User:Bob#section' );
 31+
 32+ $this->assertEquals( "$wgScript/User:Bob", $title->getLocalURL(),
 33+ 'Title::getLocalURL() does NOT have fragment' );
 34+ $this->assertEquals( "$wgScript/User:Bob", $title->escapeLocalURL(),
 35+ 'Title::escapeLocalURL() does NOT have fragment' );
 36+ $this->assertEquals( "$wgScript/User:Bob#section", $title->getLinkURL(),
 37+ 'Title::getLinkURL() does have fragment' );
 38+
 39+ #$this->assertEquals( 'toto', $title->getFullURL() );
 40+ #$this->assertEquals( 'toto', $title->escapeFullURL() );
 41+ }
1842 }
Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -31,6 +31,7 @@
3232 $parser->setFunctionHook( 'localurle', array( __CLASS__, 'localurle' ), SFH_NO_HASH );
3333 $parser->setFunctionHook( 'fullurl', array( __CLASS__, 'fullurl' ), SFH_NO_HASH );
3434 $parser->setFunctionHook( 'fullurle', array( __CLASS__, 'fullurle' ), SFH_NO_HASH );
 35+ $parser->setFunctionHook( 'linkurl', array( __CLASS__, 'linkurl' ), SFH_NO_HASH );
3536 $parser->setFunctionHook( 'formatnum', array( __CLASS__, 'formatnum' ), SFH_NO_HASH );
3637 $parser->setFunctionHook( 'grammar', array( __CLASS__, 'grammar' ), SFH_NO_HASH );
3738 $parser->setFunctionHook( 'gender', array( __CLASS__, 'gender' ), SFH_NO_HASH );
@@ -194,6 +195,7 @@
195196 static function localurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeLocalURL', $s, $arg ); }
196197 static function fullurl( $parser, $s = '', $arg = null ) { return self::urlFunction( 'getFullURL', $s, $arg ); }
197198 static function fullurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeFullURL', $s, $arg ); }
 199+ static function linkurl( $parser, $s = '', $arg = null ) { return self::urlFunction( 'getLinkUrl', $s, $arg ); }
198200
199201 static function urlFunction( $func, $s = '', $arg = null ) {
200202 $title = Title::newFromText( $s );
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -295,6 +295,7 @@
296296 'nse' => array( 0, 'NSE:' ),
297297 'localurl' => array( 0, 'LOCALURL:' ),
298298 'localurle' => array( 0, 'LOCALURLE:' ),
 299+ 'linkurl' => array( 0, 'LINKURL:' ),
299300 'articlepath' => array( 0, 'ARTICLEPATH' ),
300301 'server' => array( 0, 'SERVER' ),
301302 'servername' => array( 0, 'SERVERNAME' ),
Index: trunk/phase3/RELEASE-NOTES
@@ -167,6 +167,7 @@
168168 limit for IP addresses: [[MediaWiki:Ratelimit-excluded-ips]]
169169 * Special:Version now displays whether a SQLite database supports full-text
170170 search.
 171+* (bug 24343) New parser hook {{linkurl:}}, same as {{localurl:}} with fragment
171172
172173 === Bug fixes in 1.17 ===
173174 * (bug 17560) Half-broken deletion moved image files to deletion archive

Follow-up revisions

RevisionCommit summaryAuthorDate
r74120Follow up r73976. Made the test do not depend on $wgUsePathInfo being true an...platonides22:59, 1 October 2010
r75250Revert r73976 (Implements bug 24343 "localurl discards section id"). Per BZ f...demon15:32, 23 October 2010

Comments

#Comment by Hashar (talk | contribs)   19:57, 29 September 2010

I have marked bug 24343 as FIXED.

#Comment by MZMcBride (talk | contribs)   19:19, 30 September 2010

I re-opened that bug. I don't understand why a new magic word was added here.

#Comment by Platonides (talk | contribs)   21:38, 29 September 2010

But why would one want to discard the fragment in localurl?

#Comment by Hashar (talk | contribs)   06:28, 5 October 2010

Status & tagging log