r38330 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38329‎ | r38330 | r38331 >
Date:01:47, 1 August 2008
Author:simetrical
Status:old
Tags:
Comment:
(bug 14995 again) Fix behavior of link() when it's provided with Titles that have no text, only a fragment. getLocalURL() doesn't work here either. Can we have a function that actually means "generate a link to whatever this Title points at"?

Also remove, as Tim so eloquently terms it, "that crap in the release notes", which I also think is unnecessary and crufty.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -221,11 +221,19 @@
222222 $query['action'] = 'edit';
223223 $query['redlink'] = '1';
224224 }
225 - $ret = $target->getLocalURL( $query );
226 - if( $target->getFragment() !== '' ) {
227 - $ret .= '#'.$target->getFragment();
 225+ # A couple of things to be concerned about here. First of all,
 226+ # getLocalURL() ignores fragments. Second of all, if the Title is
 227+ # *only* a fragment, it returns something like "/".
 228+ if( $target->getFragment() === '' and $target->getPrefixedText() !== '' ) {
 229+ return $target->getLocalURL( $query );
228230 }
229 - return $ret;
 231+ if( $target->getPrefixedText() === '' ) {
 232+ # Just a fragment. There had better be one, anyway, or this is a
 233+ # pretty silly Title.
 234+ return '#'.$target->getFragment();
 235+ }
 236+ # Then we must have a fragment *and* some Title text.
 237+ return $target->getLocalURL( $query ).'#'.$target->getFragment();
230238 }
231239
232240 private function linkAttribs( $target, $attribs, $options ) {
@@ -1203,7 +1211,7 @@
12041212 *
12051213 * @todo Document the $local parameter.
12061214 */
1207 - private function formatAutocomments( $comment, $title = NULL, $local = false ) {
 1215+ private function formatAutocomments( $comment, $title = null, $local = false ) {
12081216 $match = array();
12091217 while (preg_match('!(.*)/\*\s*(.*?)\s*\*/(.*)!', $comment,$match)) {
12101218 $pre=$match[1];
@@ -1222,7 +1230,7 @@
12231231 $section = str_replace( '[[', '', $section );
12241232 $section = str_replace( ']]', '', $section );
12251233 if ( $local ) {
1226 - $sectionTitle = Title::newFromText( '#' . $section);
 1234+ $sectionTitle = Title::newFromText( '#' . $section );
12271235 } else {
12281236 $sectionTitle = wfClone( $title );
12291237 $sectionTitle->setFragment( $section );
Index: trunk/phase3/RELEASE-NOTES
@@ -48,8 +48,6 @@
4949 * Recursion loop check added to Categoryfinder class
5050 * Fixed few performance troubles of large job queue processing
5151 * Not setting various parameters in Foreign Repos now fails more gracefully
52 -* (bug 14995) Some link fragments in the interface stopped appearing
53 -* (bug 14997) Rollback links now work again
5452
5553 === API changes in 1.14 ===
5654

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r38325(bug 14995) Some link fragments in the interface stopped appearing, because T...simetrical00:47, 1 August 2008

Status & tagging log