* defaults if not given. The limit must be positive and is capped at 5000.
* Offset must be positive but is not capped.
*
- * @param int $deflimit limit to use if no input and the user hasn't set the option.
+ * @param $deflimit Integer: limit to use if no input and the user hasn't set the option.
* @param string $optionname to specify an option other than rclimit to pull from.
- * @param int $hardlimit the maximum upper limit to allow, usually 5000
* @return array first element is limit, second is offset
*/
- public function getLimitOffset( $deflimit = 50, $optionname = 'rclimit', $hardlimit = 5000 ) {
+ public function getLimitOffset( $deflimit = 50, $optionname = 'rclimit' ) {
global $wgUser;
$limit = $this->getInt( 'limit', 0 );
if ( $limit <= 0 ) {
$limit = $deflimit;
}
- if ( $limit > $hardlimit ) {
- $limit = $hardlimit; # We have *some* limits...
+ if ( $limit > 5000 ) {
+ $limit = 5000; # We have *some* limits...
}
$offset = $this->getInt( 'offset', 0 );
return $file->getTempName();
}
- /**
- * Return the size of the upload, or 0.
- *
- * @deprecated since 1.17
- * @param $key String:
- * @return integer
- */
- public function getFileSize( $key ) {
- wfDeprecated( __METHOD__, '1.17' );
- $file = new WebRequestUpload( $this, $key );
- return $file->getSize();
- }
-
/**
* Return the upload error or 0
*
return true;
}
- /**
- * Returns true if the PATH_INFO ends with an extension other than a script
- * extension. This could confuse IE for scripts that send arbitrary data which
- * is not HTML but may be detected as such.
- *
- * Various past attempts to use the URL to make this check have generally
- * run up against the fact that CGI does not provide a standard method to
- * determine the URL. PATH_INFO may be mangled (e.g. if cgi.fix_pathinfo=0),
- * but only by prefixing it with the script name and maybe some other stuff,
- * the extension is not mangled. So this should be a reasonably portable
- * way to perform this security check.
- *
- * Also checks for anything that looks like a file extension at the end of
- * QUERY_STRING, since IE 6 and earlier will use this to get the file type
- * if there was no dot before the question mark (bug 28235).
- *
- * @deprecated Use checkUrlExtension().
- *
- * @param $extWhitelist array
- *
- * @return bool
- */
- public function isPathInfoBad( $extWhitelist = array() ) {
- wfDeprecated( __METHOD__, '1.17' );
- global $wgScriptExtension;
- $extWhitelist[] = ltrim( $wgScriptExtension, '.' );
- return IEUrlExtension::areServerVarsBad( $_SERVER, $extWhitelist );
- }
-
/**
* Parse the Accept-Language header sent by the client into an array
* @return array array( languageCode => q-value ) sorted by q-value in descending order then
# unless the address is not sensible (e.g. private). However, prefer private
# IP addresses over proxy servers controlled by this site (more sensible).
foreach ( $ipchain as $i => $curIP ) {
+ // ignore 'unknown' value from Squid when 'forwarded_for off' and try next
+ if ( $curIP === 'unknown' ) {
+ continue;
+ }
$curIP = IP::sanitizeIP( IP::canonicalize( $curIP ) );
if ( wfIsTrustedProxy( $curIP ) && isset( $ipchain[$i + 1] ) ) {
if ( wfIsConfiguredProxy( $curIP ) || // bug 48919; treat IP as sane
return $this->session;
}
- /**
- * @param array $extWhitelist
- * @return bool
- */
- public function isPathInfoBad( $extWhitelist = array() ) {
- return false;
- }
-
/**
* FauxRequests shouldn't depend on raw request data (but that could be implemented here)
* @return String
*/
public function load() {
$request = $this->getRequest();
- list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, '', 500 );
+ list( $this->limit, $this->offset ) = $request->getLimitOffset( 20 );
$this->mPrefix = $request->getVal( 'prefix', '' );
$user = $this->getUser();
if ( !is_null( $t ) ) {
global $wgGoToEdit;
wfRunHooks( 'SpecialSearchNogomatch', array( &$t ) );
- wfDebugLog( 'nogomatch', $t->getText(), false );
+ wfDebugLog( 'nogomatch', $t->getText(), 'private' );
# If the feature is enabled, go straight to the edit page
if ( $wgGoToEdit ) {
// prev/next links
if ( $num || $this->offset ) {
// Show the create link ahead
- $this->showCreateLink( $t, $num );
+ $this->showCreateLink( $t, $num, $titleMatches, $textMatches );
$prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit,
$this->powerSearchOptions() + array( 'search' => $term ),
max( $titleMatchesNum, $textMatchesNum ) < $this->limit
} else {
$out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>",
array( 'search-nonefound', wfEscapeWikiText( $term ) ) );
- $this->showCreateLink( $t, $num );
+ $this->showCreateLink( $t, $num, $titleMatches, $textMatches );
}
}
$out->addHtml( "</div>" );
/**
* @param $t Title
* @param int $num The number of search results found
+ * @param $titleMatches null|SearchResultSet results from title search
+ * @param $textMatches null|SearchResultSet results from text search
*/
- protected function showCreateLink( $t, $num ) {
+ protected function showCreateLink( $t, $num, $titleMatches, $textMatches ) {
// show direct page/create link if applicable
// Check DBkey !== '' in case of fragment link only.
- if ( is_null( $t ) || $t->getDBkey() === '' ) {
+ if ( is_null( $t ) || $t->getDBkey() === '' ||
+ ( $titleMatches !== null && $titleMatches->searchContainedSyntax() ) ||
+ ( $textMatches !== null && $textMatches->searchContainedSyntax() ) ) {
// invalid title
// preserve the paragraph for margins etc...
$this->getOutput()->addHtml( '<p></p>' );
);
}
+ $fileMatch = '';
// Include a thumbnail for media files...
if ( $t->getNamespace() == NS_FILE ) {
- $img = wfFindFile( $t );
+ $img = $result->getFile();
+ $img = $img ?: wfFindFile( $t );
+ if ( $result->isFileMatch() ) {
+ $fileMatch = "<span class='searchalttitle'>" .
+ $this->msg( 'search-file-match' )->escaped() . "</span>";
+ }
if ( $img ) {
$thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) );
if ( $thumb ) {
$thumb->toHtml( array( 'desc-link' => true ) ) .
'</td>' .
'<td style="vertical-align: top;">' .
- $link .
+ "{$link} {$fileMatch}" .
$extract .
"<div class='mw-search-result-data'>{$score}{$desc} - {$date}{$related}</div>" .
'</td>' .
&$score, &$size, &$date, &$related,
&$html
) ) ) {
- $html = "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section}</div> {$extract}\n" .
+ $html = "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section} {$fileMatch}</div> {$extract}\n" .
"<div class='mw-search-result-data'>{$score}{$size} - {$date}{$related}</div>" .
"</li>\n";
}
$out .= Html::hidden( 'fulltext', 'Search' ) . "\n";
$out .= Xml::submitButton(
$this->msg( 'searchbutton' )->text(),
- array( 'class' => array( 'mw-ui-button', 'mw-ui-primary' ) )
+ array( 'class' => array( 'mw-ui-button', 'mw-ui-progressive' ) )
) . "\n";
return $out . $this->didYouMeanHtml;
}