r84032 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84031‎ | r84032 | r84033 >
Date:16:47, 15 March 2011
Author:ialex
Status:ok
Tags:
Comment:
Changed LinkHolderArray::makeHolder() to use Linker::link() instead of Linker::makeBrokenLinkObj() and Linker::makeColouredLinkObj()
Modified paths:
  • /trunk/phase3/includes/parser/CoreLinkFunctions.php (modified) (history)
  • /trunk/phase3/includes/parser/LinkHolderArray.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/LinkHolderArray.php
@@ -191,7 +191,7 @@
192192 *
193193 * @param $nt Title
194194 */
195 - function makeHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
 195+ function makeHolder( $nt, $text = '', $query = array(), $trail = '', $prefix = '' ) {
196196 wfProfileIn( __METHOD__ );
197197 if ( ! is_object($nt) ) {
198198 # Fail gracefully
@@ -205,7 +205,7 @@
206206 'text' => $prefix.$text.$inside,
207207 'pdbk' => $nt->getPrefixedDBkey(),
208208 );
209 - if ( $query !== '' ) {
 209+ if ( $query !== array() ) {
210210 $entry['query'] = $query;
211211 }
212212
@@ -349,23 +349,29 @@
350350 foreach ( $entries as $index => $entry ) {
351351 $pdbk = $entry['pdbk'];
352352 $title = $entry['title'];
353 - $query = isset( $entry['query'] ) ? $entry['query'] : '';
 353+ $query = isset( $entry['query'] ) ? $entry['query'] : array();
354354 $key = "$ns:$index";
355355 $searchkey = "<!--LINK $key-->";
356 - if ( !isset( $colours[$pdbk] ) || $colours[$pdbk] == 'new' ) {
 356+ $displayText = $entry['text'];
 357+ if ( $displayText === '' ) {
 358+ $displayText = null;
 359+ }
 360+ if ( !isset( $colours[$pdbk] ) ) {
 361+ $colours[$pdbk] = 'new';
 362+ }
 363+ $attribs = array();
 364+ if ( $colours[$pdbk] == 'new' ) {
357365 $linkCache->addBadLinkObj( $title );
358 - $colours[$pdbk] = 'new';
359366 $output->addLink( $title, 0 );
360 - // FIXME: replace deprecated makeBrokenLinkObj() by link()
361 - $replacePairs[$searchkey] = $sk->makeBrokenLinkObj( $title,
362 - $entry['text'],
363 - $query );
 367+ $type = array( 'broken' );
364368 } else {
365 - // FIXME: replace deprecated makeColouredLinkObj() by link()
366 - $replacePairs[$searchkey] = $sk->makeColouredLinkObj( $title, $colours[$pdbk],
367 - $entry['text'],
368 - $query );
 369+ if ( $colours[$pdbk] != '' ) {
 370+ $attribs['class'] = $colours[$pdbk];
 371+ }
 372+ $type = array( 'known', 'noclasses' );
369373 }
 374+ $replacePairs[$searchkey] = $sk->link( $title, $displayText,
 375+ $attribs, $query, $type );
370376 }
371377 }
372378 $replacer = new HashtableReplacer( $replacePairs, 1 );
Index: trunk/phase3/includes/parser/Parser.php
@@ -1935,7 +1935,7 @@
19361936 $s .= $this->makeKnownLinkHolder( $nt, $text, array(), $trail, $prefix );
19371937 } else {
19381938 # Links will be added to the output link list after checking
1939 - $s .= $holders->makeHolder( $nt, $text, '', $trail, $prefix );
 1939+ $s .= $holders->makeHolder( $nt, $text, array(), $trail, $prefix );
19401940 }
19411941 wfProfileOut( __METHOD__."-always_known" );
19421942 }
@@ -1951,7 +1951,7 @@
19521952 *
19531953 * @deprecated
19541954 */
1955 - function makeLinkHolder( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
 1955+ function makeLinkHolder( &$nt, $text = '', $query = array(), $trail = '', $prefix = '' ) {
19561956 return $this->mLinkHolders->makeHolder( $nt, $text, $query, $trail, $prefix );
19571957 }
19581958
Index: trunk/phase3/includes/parser/CoreLinkFunctions.php
@@ -41,7 +41,7 @@
4242 # Return false so that this link is reverted back to WikiText
4343 return false;
4444 }
45 - return $holders->makeHolder( $title, isset($displayText) ? $displayText : $titleText, '', '', '' );
 45+ return $holders->makeHolder( $title, isset($displayText) ? $displayText : $titleText, array(), '', '' );
4646 }
4747
4848 /**

Status & tagging log