Commit graph

114 commits

Author SHA1 Message Date
Erik Bernhardson
28abb2620a Document namespaces member as nullable
This variable is set to null in the replacePrefixes method, document
it as such to prevent errors in consuming code.

Bug: T98082
Change-Id: I78880ffe590ed7193b8482c0ae41c8c69e495878
2015-05-05 11:11:32 -07:00
Nik Everett
74b1c0d256 Add a sort parameter to SearchEngine
SearchEngine grows a method to list valid sort orders one to set the
sort for the next search, and one to read it.  The default implemenation
only supports 'relevance' and the documenation strongly urges that all
other implemenations leave that as the default.  Other implementations
can support other orders. Cirrus already supports title_asc and title_desc.

Change-Id: Ie946150c6796139201221dfa6f7750c210e97166
2015-01-07 13:41:18 -08:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Brad Jorsch
28e37f55c9 Merge OpenSearchXml extension into core
There's really no reason for the extension to exist separately from
core, and merging it reduces the risks of bitrot in both the extension
(lots of deprecated functions there) and core (missing integration with
PageImages and TextExtracts, for example).

Change-Id: Ie0ab90902ede9499879402290006466efba479e9
2014-11-26 21:07:22 -08:00
umherirrender
c2de24efcd Add missing @param to function docs
Change-Id: Ib7ac94d05a04490f25dfd40b46b27973cbab582c
2014-08-14 19:38:57 +00:00
jenkins-bot
a30854859e Merge "Remove SearchEngineReplacePrefixesComplete hook" 2014-06-24 07:20:18 +00:00
Chad Horohoe
da0070e9d1 Remove SearchEngineReplacePrefixesComplete hook
This hook is poorly thought out. The only extension that uses it
can't possibly think it works how they're expecting.

Change-Id: I853a01afc8e922f22e949321a2f2343d264632a6
2014-06-23 08:48:45 -07:00
Chad Horohoe
cd9dc7ef3f Database search fixes:
- Move filter() function and make it protected, nothing uses it
  outside database-backed searching
- Use per-backend legal search characters rather than assuming the
  static implementation is right

Change-Id: Ic2b830b56137b2dfe68b9b9c3de012151e716952
2014-06-20 13:43:36 -07:00
Chad Horohoe
9643a0a92d Remove SearchResultTooMany
Only worked for Postgres, and only worked halfway at that. Result
sets could be false for many reasons. No results, bad query, database
went to Mars. We shouldn't assume they're always "too many results."

Leave it up to the normal query error logging and move on.

Change-Id: Ieddd163e440ae54b152541d727c1afdbc4ab4fbd
2014-06-20 10:36:47 -07:00
Nemo bis
5dc4dc099d Save advanced search namespace prefs on Special:Search itself
* Checkbox on own row below power search checkboxes per MatmaRex;
  avoiding a mw-search-ns* id leaves it untouched by All/None JS.
* The option searcheverything is removed: a "shortcut" which is no
  longer necessary now that options can be (un)selected at once
  with All/None buttons on search page itself.
* Require a token for saving: no accidental preferences changes.
* Keep the searchoptions/advancedsearchoptions prefs section in case
  something is using it (no known extension does though); options
  are converted to "api" type so it's empty and hidden by default.
* Add minimal documentation for saveSettings() and friends
  (@todo since 155ddf6de, 2009!).

Bug: 52817
Change-Id: I514cee835988600cc013658049e88a10b670e64a
2014-05-30 14:33:47 -07:00
Chad Horohoe
1cb1ac6278 Remove "Help/Project" profile from Special:Search
The vast majority of wikis have an empty help namespace and
searching project pages is mostly an advanced search feature.

Cluttering the UI with an extra tab that's (most likely) rarely
clicked isn't helping anyone.

Change-Id: I0c448bcee877e027ff95c96812aac86d89d4eb32
2014-05-12 11:10:18 -07:00
Siebrand Mazeland
b1aa60af25 Pass phpcs-strict on includes/search/
Change-Id: Ia38af607b1f2a8e49f60f1a659a14b801e7dcda0
2014-05-09 22:32:17 +02:00
umherirrender
dcf6955e5c Fixed some @params documentation (includes/*)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.

Change-Id: Ifbb1da2a6278b0bde2a6f6ce2e7bd383ee3fb28a
2014-04-20 23:33:05 +02:00
umherirrender
edc924869f Changed some comments from /// to /** @var */
Change-Id: I55b30099e4464c272c35bcabbddbb0b1364a5d65
2014-04-07 05:01:19 +00:00
Chad Horohoe
7e8c48ac3d Remove "include redirects" option from search
Always include redirects. Search results are worse without them
and MWSearch has never respected this option anyway.

Change-Id: I0ebe321a3b14e7960aa98e3225dc5a19ba916e7d
2014-03-26 09:28:26 -07:00
Chad Horohoe
7fc1a5b137 Break up SearchEngine.php into a couple of other files
Change-Id: I753eec1d0cf78f2ea08897c7fd3b83f2c88be18d
2014-03-19 20:14:17 +00:00
umherirrender
047c86f26e Fix spacing between two functions
Added and removed some new lines to have one new line between two
functions

Change-Id: I1ccfbd575dd26b160396ef3d3e2e079f5cdbe196
2014-03-15 20:57:23 +00:00
Chad Horohoe
3476fcc5da Remove unused $terms parameter
None of the following extensions use these parameters:
- CirrusSearch
- MWSearch
- SolrSearch
- SphinxSearch

Change-Id: I9686ca0849f35a3a09bd9996e4c6eac4334a342a
2014-03-04 13:26:12 -08:00
Chad Horohoe
653b7d63bc Support interwiki searches in API
Adds new SearchResult methods for getting namespace text

Bug: 60975
Change-Id: I381c8681cabfa9ff7a73cbe0286ed32d267a5990
2014-02-25 13:54:23 -08:00
Nik Everett
4e3e752a9e Don't offer create link for searches with syntax
Rather, create a hook that search implementations can override to specify
that the search contained advanced syntax and core will read it in
Special:Search and only offer the link if it is false.  It'll default
false.

Change-Id: Ic4ce6361d0e602ed9a812dfbbd15ce11a762f5f8
2014-02-04 13:28:19 -05:00
Nik Everett
f8dbaac443 Handle space in namespace prefixed searches
MWSearch handles namespace prefixed searches containing spaces so core
should as well.

Bug: 60489
Change-Id: I7e602d005a8b2786942b76b7185882e5107942c4
2014-02-04 10:57:19 -05:00
Chad Horohoe
ed2f768c62 Remove unused acceptListRedirects()
Change-Id: I411f6f9934917b424591287f5bebbb8183952f32
2014-01-30 11:08:29 -08:00
Chad Horohoe
791a384979 Don't override limits and offsets in SearchEngine::create()
The class default is 10/0, it doesn't make sense to set that
as 0/0 here. Nor does it make sense to really override it
here at all, as class defaults should take precedent unless
explicitly overriden by callers.

Bug: 60475
Change-Id: I4a48fd3c55908b52c8b0ab081d856874d16b876e
2014-01-27 08:55:40 -08:00
jenkins-bot
bb70f87a13 Merge "Begin abstracting more of the database-specific search backend out" 2014-01-23 23:39:34 +00:00
Chad Horohoe
110eb02f3a Begin abstracting more of the database-specific search backend out
There's a lot in the base search implementations that is specific
to the database backed search. This starts moving some of that out
into a shared base class for those.

For starters, let's not grab a connection to the slave DB for
every single search for backends unless they need it.

Change-Id: Ib66696841eea901e04b21dd309784af889a45ab1
2014-01-21 17:53:16 -08:00
Chad Horohoe
05cbfe0ad4 Allow SearchResults to specify that they matched file content
Change-Id: I214406250d10b971dcca025da508272d9805567b
2014-01-17 10:50:08 -05:00
Chad Horohoe
d109ff79e1 Two fixups to SearchResult
- Make variables protected. Only class that uses these is LuceneResult
  and it's fine
- Don't bother constructing a new file object if we've already got
  one in memory (we likely do)

Change-Id: I7973aff1e96297a2fea70392b765c93a8c884d52
2014-01-14 16:21:53 -08:00
Nik Everett
cf14ee4acc Don't suggest if the search term is a known title
Also tell the SearchEngine that we don't *need* the suggestion.  Some will
make it any way and we'll ignore it.  Cirrus will be able to save some time
by not building the suggestion.

Bug: 59666
Change-Id: Ifd5bafe25a715db9d44cf0fee2ba2607f6c270a2
2014-01-06 16:08:34 -05:00
aude
73bc21bb1c Fix SearchEngineTest when $wgSearchType is set to non-default
$wgSearchType needs to be controlled for at time the pages get created.
This patch sets the $wgSearchType global.

Also, the 'singleton' is removed from SearchEngine::getSearchTypes, which
appears to provide little or no benefit while binding all tests to the
global variable.

SearchEngine::getSearchTypes() gets called in SearchUpdate which is
run on page edits. This means the first page edit in the entire
test suite causes the global variable to be set and subsequent tests
cannot override it.

These changes allow SearchEngineTest to pass, even if one has CirrusSearch
or other such extensions enabled.

Change-Id: I39050da8659dc69db31125f469f494a5fb4b8fca
2014-01-03 11:28:41 +01:00
umherirrender
d1d5d6c209 SearchEngine::userHighlightPrefs needs no user
Was removed with r87215 from the function,
but not from the function call

Change-Id: Iacb247d5962fe77db5a29084ece941261bf306ec
2013-09-20 20:54:19 +02:00
Reedy
589b2af808 Improved search backend fallback in Special:Search
Use the srbackend parameter if it's valid.

If it's not, use $wgSearchType if it's not null.

Finally, fall back to the search type of the database.

Bug: 53982
Change-Id: I3605cb4add270543aa20afb037401b2dfbe462f0
2013-09-10 16:49:54 -04:00
Chad Horohoe
2bda9a37fe Allow individual search backends to control whether they SearchUpdate
$wgDisableSearchUpdate is a sledgehammer for disabling all indexing
which is fine for most people, but sometimes you've got multiple
search backends and you want some to update but not others. This
allows each backend to tell core whether they support the feature.

This also removes the SearchUpdate hook which really doesn't make
sense and nobody uses but CirrusSearch and an abandoned extension
from 7 years ago.

Will require parallel change to MWSearch (Ibd002347) and Cirrus (I87a5b8cc)

Change-Id: I2063fe05000044225fa6bec2171ed0071b84a5cf
2013-08-14 17:55:04 +00:00
Chad Horohoe
dd21f34c05 Select search backend by query parameter
This is useful when you're doing testing of multiple search
engines and you want to compare results.

Note that it doesn't do anything for the prefix search which is ok!

Change-Id: I96a08c64ac84e93b0bec2e8b08d8943b775e68d1
2013-08-12 17:09:01 -07:00
Chad Horohoe
74c0e04c1a Allow SearchUpdate hook to abort core update call
Going to use this in CirrusSearch since the default text
handling is insane for Solr.

While we're at it, further move content handling to SearchEngine
so children can override behavior here.

Change-Id: I09d11b81c224d53609c57d75d54021e697b56629
2013-06-21 14:00:45 -04:00
Chad Horohoe
539ec5ffa3 Pass content to SearchUpdate rather than raw text
This is still less than ideal, but at least consolidates the
logic so we can later implement more content-specific handling.

Change-Id: Ic24a7ea2818f6eeb67453877dc5a31f110541ecf
2013-06-19 16:40:46 -04:00
Chad Horohoe
96fb0c4d71 Support updating search index when page is deleted
Right now, if you delete a page then you end up with a stale
entry in the search index, this affects all core SQL-based
searches.

For extensions, this means they no longer have to implement
something like ArticleDelete, they can just add the delete()
method to their SearchEngine subclass.

Change-Id: I9d8a9878aeebc53f453ab1cbacc03fe73fcca949
2013-06-18 17:41:13 -04:00
Reedy
28ec06fa53 Update SearchEngine::searchText() and SearchEngine::searchTitle() return type hints
Matches updates to MWSearch that can now return Status objects

Change-Id: I056fdf9f290d0a17e49948be158dd881185c8345
2013-05-06 15:40:44 +00:00
umherirrender
9f14ecf829 Added space after switch/Removed spaces after unset
While at it, added/removed some other spaces in the same files

Change-Id: I84d8001aa123a008807ad5eb76f396aed7c899a4
2013-04-26 16:42:31 +02:00
umherirrender
6c38a5eb72 Fixed spacing in logging/parser/profiler/rl/revdel/search folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I11bbcfa351e945b7bde10c2105d61a3cf5622205
2013-04-20 17:38:24 +02:00
umherirrender
97234cc884 Added spaces before and removed spaces after 'array'
Fix some other spacing while at it

Change-Id: I13f81533eaf40e06c13cf377c0f08ef5cef01d00
2013-04-14 21:57:46 +02:00
umherirrender
15abcf71ca Added/Removed spaces around string concatenation
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !

Fixed windows newline style

Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
2013-04-13 13:36:24 +02:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
umherirrender
be90ce07b3 fix some spacing
Change-Id: I93f0a87ba7129bc336083e7289247d3150feb606
2013-02-04 19:54:07 +00:00
umherirrender
824fad9956 fix some spacing
Change-Id: I78a97ad87e0bfe724fc851daf6ffeeed81887800
2013-01-26 19:15:35 +01:00
Ori.livneh
023b1dafd3 Merge "Addition of SearchAfterNoDirectMatch hook" 2012-11-28 11:52:07 +00:00
Reedy
904e4bdf7f Addition of SearchAfterNoDirectMatch hook
Needed for mediawiki/extensions/SearchExtraNS

Change-Id: If0a7da5c8691c418bc388e50dd11eea3b57ed45d
2012-11-28 03:47:17 -08:00
Max Semenik
791d96bff3 Fix exception when searching for stuff beginning with "Media:"
Change-Id: I8b5a419fa369ad91034c3769a4b228290b878e1b
2012-11-22 04:29:49 +04:00
daniel
c2172d45e4 Beware that getContent() may return null
Before the introduction of the content handler, missing content was
signified by getText() returning null instead of a string. null will
work much like an empty string in most contexts, so in many places,
it was not checked explcitely whether the conent was null.

Now, when getContent() returns null, this often caused a fatal error,
because the code would access whatever getContent() returned as an object,
without checking whether it was null (because no such check was performed
previously, when the content was represented as a string).

This check introduces explicite checks for getContent() returning null
in the most essential core classes.

Change-Id: I551a90b0b67b8edc7570ca5d252ecc1de903f097
2012-11-09 19:45:12 +01:00
Antoine Musso
9362bb6c56 miscellaneous doxygen warnings
* @licence -> @license
* Protects inline HTML by using double quotes, our inline comments uses
  elements such as <h1> or <firstnameLastname@gmail.com>
* Commands in lowercase (@TODO -> @todo, @NOTE -> @note)
* removes @abstract and @static since doxygen detects them from PHP
  code.
* various undocumented function parameters
* typos in parameters declarations

Change-Id: I62ad6fc124c355bf31acc780b9614a59cf79a421
2012-10-22 14:00:08 +02:00