r14823 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14822‎ | r14823 | r14824 >
Date:00:02, 20 June 2006
Author:brion
Status:old
Tags:
Comment:
Bug fixes after initial testing:
* Show error instead of every URL on invalid query
* Work right with non-latin 'Special' namespace
Modified paths:
  • /trunk/extensions/LinkSearch/LinkSearch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LinkSearch/LinkSearch.php
@@ -14,6 +14,7 @@
1515 'linksearch' => 'Search web links',
1616 'linksearch-text' => 'Wildcards such as "*.wikipedia.org" may be used.',
1717 'linksearch-line' => '$1 linked from $2',
 18+ 'linksearch-error' => 'Wildcards may appear only at the start of the hostname.'
1819 )
1920 );
2021
@@ -50,8 +51,7 @@
5152 $page = $dbr->tableName( 'page' );
5253 $externallinks = $dbr->tableName( 'externallinks' );
5354
54 - $search = self::mungeQuery( $this->mQuery );
55 - $encSearch = $dbr->addQuotes( $search );
 55+ $encSearch = $dbr->addQuotes( $this->mQuery );
5656
5757 return
5858 "SELECT
@@ -90,7 +90,7 @@
9191 $wgOut->addHtml(
9292 wfOpenElement( 'form',
9393 array( 'method' => 'get', 'action' => $GLOBALS['wgScript'] ) ) .
94 - wfHidden( 'title', $self->getPrefixedUrl() ) .
 94+ wfHidden( 'title', $self->getPrefixedDbKey() ) .
9595 wfInput( 'target', 50, $target ) .
9696 wfSubmitButton( wfMsg( 'search' ) ) .
9797 wfCloseElement( 'form' ) );
@@ -98,10 +98,14 @@
9999 if( $target != '' ) {
100100 // For debugging
101101 $search = LinkSearchPage::mungeQuery( $target );
102 - $wgOut->addHtml( "\n<!-- " . htmlspecialchars( $search ) . " -->\n" );
103 -
104 - $searcher = new LinkSearchPage( $target );
105 - $searcher->doQuery( $offset, $limit );
 102+ if( $search === false ) {
 103+ $wgOut->addWikiText( wfMsg( 'linksearch-error' ) );
 104+ } else {
 105+ $wgOut->addHtml( "\n<!-- " . htmlspecialchars( $search ) . " -->\n" );
 106+
 107+ $searcher = new LinkSearchPage( $search );
 108+ $searcher->doQuery( $offset, $limit );
 109+ }
106110 }
107111 }
108112 }

Status & tagging log