Commit graph

50 commits

Author SHA1 Message Date
Amir E. Aharoni
1e5e969625 Shorten long lines in PrefixSearch.php to make phpcs pass
Change-Id: Ibf18835ff614e53887912b8e997a3230ed29dd68
2015-03-04 09:13:53 +02:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -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
umherirrender
489d793882 Fixed spacing
- Added/removed spaces around parenthesis
- Added newline in empty blocks
- Added space after switch/foreach/function
- Use tabs at begin of line
- Add newline at end of file

Change-Id: I244cdb2c333489e1020931bf4ac5266a87439f0d
2014-12-05 22:28:07 +01:00
Chad Horohoe
b702cb3b24 Support offsets in prefix searching
Fixes T75522
Change-Id: I7a27a64e295a1efcb1d9728d95cf254bb8bfbe92
2014-12-02 11:59:26 -08:00
Nik Everett
2ec9915816 Handle redirects during prefix search exact match
Prefix search attempts to find exact matches to the user's query that aren't
returned by plugins.  In some cases, like when the exact match is a redirect
and the target of the redirect is also in the search results, it would result
in multiple results in prefix search going the same place.  This looks really
silly when the top hit is "Barack obama" (a redirect) and the next one is
"Barack Obama" (the target of the redirect).

This handles a bunch of cases to do with redirects in the matches and when
the exact match is a redirect.

Bug: 736731
Change-Id: I49fe1ccec84bd5d1f44c6b91b260abf50f2cc3a1
2014-11-21 14:47:32 -05:00
Nik Everett
eb68807367 Add hook to extract namespace in prefix search
This will allow extensions (namely CirrusSearch) to match namespaces using
their own rules if core can't find the namespace on its own.

Bug: 62322
Change-Id: I17337cd8ce90190bd335c9159e9d3bbb39ba89cd
2014-10-22 16:05:19 -04:00
Nik Everett
2c121e0f67 Fix exception while bubbling titles
In prefix search if the search text is actually a title we make sure it is at
the top of the results.  But if it isn't a valid title we shouldn't blow up
because blowing up is bad.

Bug: 72260
Change-Id: I5bd795df447a33bb003a38ec2068dc184379a813
2014-10-20 12:32:36 -04:00
jenkins-bot
79ea0edce2 Merge "PrefixSearch: Enforce including the exact match as first result" 2014-10-10 21:34:23 +00:00
Timo Tijhof
8dd95a13e3 PrefixSearch: Enforce including the exact match as first result
The default search backend implements proper prefix search and
does this naturally. But extensions providing search backends
like Lucene and CirrusSearch actually fail to implement proper
prefix searching and instead use their search engine ranking for
prefix search as well. Thus often the exact match is not on top
or is not even in the first 10 results at all.

On en.wikipedia.org:

> Example
1. "Example (musician)"
2. "Example"
3. "Example.com"

> John ive
1. "John Ives"
2. "John Ivey"
3. "John Ive"

> Foo
1. "Football (soccer)"
2. "Football League Cup"
3. "Foot (length)"

"Foo" exists but is NOT among the returned results.

Bug: 70958
Change-Id: I78d419424baf43d38beeb6dabfc347f430fa45f6
2014-10-10 19:32:09 +00:00
jenkins-bot
4ffe4ca50b Merge "PrefixSearch: Add unit tests for StringPrefixSearch" 2014-10-07 12:41:08 +00:00
umherirrender
df24b7209d Fixed spacing
- Added newline at end of file
- Removed double spaces/newlines
- Added space after if/function and parentheses/brackets
- Removed space before comma/cast
- Fixed indent of some lines

Change-Id: I29867ffdffdfb7d2b56997e9393497c7dc12f7d3
2014-09-29 20:46:19 +02:00
Timo Tijhof
9e3e9e28d4 PrefixSearch: Add unit tests for StringPrefixSearch
Change-Id: If0fa66b212f70ea39d2e7feec117930fcd1b9642
2014-09-23 11:35:27 -07:00
daniel
4f0b2f4241 Allow callback functions for creating SpecialPages.
This enables factory functions to be registered for special
pages, as an alterative to giving a class name. This follows the
same rationale as Ieb85493a7765, which introduced factory functions
for API modules.

Change-Id: Ia2107dc5af7869187ba5dc02a1bef46d6801e138
2014-09-18 14:47:34 +02:00
Nik Everett
1f0d72968d Be more careful with Special: prefix searching
Bug: 70409
Change-Id: I3764bff1bf7b2d11a7c8f8cc8564eeae9953ea30
2014-09-04 19:07:20 +00:00
umherirrender
7ff005407e Remove colon after @deprecated/@param/@todo/@note
Change-Id: I4e66dad85eecf7e8e03ac760af900395e1bc11b6
2014-07-24 11:30:25 +02:00
Chad Horohoe
c30da5b0e9 PrefixSearch: Avoid notice when no subpage exists
Change-Id: I9e09b1c082e099f3b79716da5ab16239e256e4b2
2014-07-14 08:42:59 -07:00
jenkins-bot
d65e736864 Merge "Revert "PrefixSearch (ApiOpenSearch) now supports searching in multiple namespaces"" 2014-06-24 00:13:53 +00:00
Krinkle
392e98fd17 Revert "PrefixSearch (ApiOpenSearch) now supports searching in multiple namespaces"
Caused regression in opensearch results for the main search field on every
page. Special pages are no longer included when they should. 

This reverts commit 0e054bbf1a.

Change-Id: Ib39c6d7816cd3c21ec714f5d6272bebd049ac430
2014-06-24 00:08:31 +00:00
Chad
9ec7cb0868 Merge "PrefixSearch (ApiOpenSearch) now supports searching in multiple namespaces" 2014-06-20 20:30:18 +00:00
Niklas Laxström
0e054bbf1a PrefixSearch (ApiOpenSearch) now supports searching in multiple namespaces
I thought there was just an issue with capitalization, but in fact the code
explicitly only searched one namespace anyway. Fixed that while taking
capitalization differences in namespaces into account.

Bug: 65752
Bug: 30323
Change-Id: I3487bb69eae1867832e0ec9ece497538eca32a2a
2014-06-20 20:24:38 +00:00
Bartosz Dziewoński
ef5c2a62e1 Autocomplete special pages' subpages in search suggestions
Includes basic "example" implementations for:
* Special:Watchlist (predefined subpage list)
* Special:Log (based on config variable)

Bug: 20210
Change-Id: I2b0505df244b9d23bd23d5fb4d3405dc28d57739
2014-06-12 17:01:43 +02:00
Siebrand Mazeland
49cffd699c Make phpcs-strict pass on includes/ (2/~10)
Change-Id: I59fa9af7b16e0a5a4eb8a5cc764a605b18137316
2014-05-11 19:22:05 +00:00
umherirrender
a3983418d5 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.
Also added some missing @param.

Change-Id: I0056b4a8df243cfc0c5f25378de48f7a35170aca
2014-04-22 13:07:02 +02:00
Chad Horohoe
35d77d9a7b Followup af6d9aba: $search is a string, not an object
Reusing variables means you end up turning a string to an object
and then confuse yourself by trying to pass it as a string again.

Change-Id: I82b5ca65864099c180d915055c43e6839bd4f4a2
2014-04-15 11:50:10 -07:00
Bartosz Dziewoński
86e2200f8e PrefixSearch: Remove unnecessary wfSuppressWarnings()
It was added in 4492854f (r68563), where the code this was suppressing
warnings for was something rather different. It doesn't seem necessary now.

Change-Id: Ia501afd1244b94563fe52294945798963f8db1a9
2014-04-11 23:42:45 +02:00
Max Semenik
af6d9aba6d New API module, list=prefixsearch
It's pretty much like action=opensearch but can be used as a generator
which can be handy when you need to retrieve both the list of pages and
some information about them.

Change-Id: Iaffe30a0f7402e1316c4885a805692a34bbe1a6a
2014-04-02 19:14:07 +04:00
umherirrender
65a4ae9fe9 Change Title::getInterwiki() in conditions to Title::isExternal()
Change-Id: Icce26e6194ae96f262029554e05b49117d5e112e
2014-01-02 11:59:10 +01:00
umherirrender
ef2f507d23 Fixed spacing in files direct in includes folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
2013-04-21 06:38:49 +00: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
Yuri Astrakhan
9506e3d812 Spellchecked /includes directory
* Ran spell-checker over code comments in /includes/
* A few spellchecking fixes for wfDebug() calls

Found one very strange (NOOP?) line in Linker.php - see "TODO: BUG?"

Change-Id: Ibb86b51073b980eda9ecce2cf0b8dd33f058adbf
2013-03-13 03:42:41 -04: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
1044b0b8df fix some spacing
Change-Id: I8f976013f33c5818e4402604fe8610aa3f43b0c6
2013-02-04 20:18:33 +00:00
Alexandre Emsenhuber
d1f8640a3b Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: Ia45d0756cd84138da267bf1cbd1a58be7f28c6d1
2012-05-11 10:34:29 +02:00
Happy-melon
2c9cfd7cce Refactor the factory/i18n/list/etc static methods from SpecialPage into their own class; there's no reason we need to be parsing them in every single SpecialPage subclass. Leave all the methods as stubs in SpecialPage.php; if we required PHP 5.3 they could be replaced by a a __callStatic() magic method, but that doesn't work on PHP 5.2.
Also make a few changes to the functions available.  SpecialPageFactory::resolveAlias() now takes an optional subpage and returns array(<name>,<subpage>).  Similarly merge getPage() and getPageByAlias().  There were many examples of (extensions particularly) making dubious assumptions about the presence or absence of subpages or canonical-ness.

I didn't deprecate SpecialPage::getTitleFor() as it's got over six hundred calls.  I'm rather undecided on the best position of getPage()/executePath().  Although the latter needs cleanup anyway.
2011-04-17 11:31:11 +00:00
Jack Phoenix
3b5750adb4 coding style tweaks, doc updates, marked some public functions as such 2011-03-22 20:23:52 +00:00
Roan Kattouw
ec3c2f8f84 Revert r67661 (change Title::makeTitle(NS_SPECIAL, $foo) to SpecialPage::getTitleFor($foo)), caused bug 27671 (search suggestions no longer list canonical names for special pages). Went with makeTitleSafe() instead of makeTitle() just in case weird things make their way into the special page aliases. 2011-03-14 10:03:07 +00:00
Brion Vibber
03fa2561b6 * (bug 25675) Fix search suggestions for Special: pages with spaces
Patch by Umherirrender on https://bugzilla.wikimedia.org/show_bug.cgi?id=25675 - normalizes spaces to underscores for our direct alias list comparison.

The current English names mostly use CamelCase, but this is visible with eg German localization, where ExpandTemplates extension has [[Spezial:Vorlagen expandieren]].
2011-02-14 00:32:13 +00:00
Antoine Musso
c5906068fa Lame documentation, code style 2010-10-27 21:11:36 +00:00
Niklas Laxström
4492854f61 Suppress warnings 2010-06-25 14:21:07 +00:00
Siebrand Mazeland
042585fb9d Replace Title::makeTitle[Safe]( NS_SPECIAL, 'x' ) with SpecialPage::getTitleFor ( 'x' )
And a few other minor changes.
2010-06-08 19:36:44 +00:00
Alexandre Emsenhuber
52ccd25ed2 * Fixed some doxygen warnings
* Removed trailing spaces
2010-01-20 21:06:22 +00:00
Alexandre Emsenhuber
0b8c5ca6b9 * (bug 20885) Search box no longer suggests unavailable special pages 2009-10-02 09:44:34 +00:00
Niklas Laxström
36dbe35374 * STFU E_WARN, please review for correcteness 2009-02-05 19:55:57 +00:00
Ilmari Karonen
34fb6297cd Step 2 in NS_IMAGE -> NS_FILE transition (bug 44) (WARNING: huge commit).
This is a global search and replace of NS_IMAGE and NS_IMAGE_TALK with NS_FILE and NS_FILE_TALK respectively in all core files, excluding those already updated in step 1 (r44004).
2008-12-01 17:14:30 +00:00
Chad Horohoe
8b26c3550b Basic docs for the class. 2008-08-07 23:09:11 +00:00
Chad Horohoe
aaf794947a Remove a bit of useless $wgCapitalLinks logic, all these code paths lead through Title::secureAndSpit() which handles initial-character-capitalization.
*In SearchEngine's case, it gets caught every time further up the page (it never even reaches the upper/lower casing of only first character part)
*PrefixSearch eventually sends it through ApiQueryBase::titleToKey()
*AjaxFunctions immediately sends it to Title::newFromText()
2008-07-25 23:12:27 +00:00
Robert Stojnić
d6fd8e7c13 Ajax suggestions:
* check in a new ajax suggestion engine (mwsuggest.js) which uses 
  OpenSearch to fetch results (by default via API), this should
  deprecated the old ajaxsearch thingy
* extend PrefixSearchBackend hook to accept multiple namespaces for
  future lucene use (default implementation however can still 
  process only one)
* Added to preferences, also a feature to turn it on/off for every 
  input (disabled atm until I work out browser issues completely)
* WMF wikis probably won't be using API to fetch results, but a 
  custom php wrapper that just forwards the request to appropriate
  lucene daemon, added support for that

SpecialSearch:
* moved stuff out of SpecialSearch to SearchEngine, like snippet
  highlighting and such
* support for additional interwiki results, e.g. title matches
  from other projects shown in a separate box on the right
* todo: interwiki box doesn't have standard prev/next links to 
  avoid clutter and unintuitive interface
* support for related articles
2008-04-15 23:06:28 +00:00
Siebrand Mazeland
79d5225c0e * remove end of line whitespace
* remove empty lines at end of file
* remove "?>" where still present
2008-04-14 07:45:50 +00:00
Brion Vibber
7a3227596e * Merged backends for OpenSearch suggestions and AJAX search.
Both now accept namespace prefixes, handle 'Media:' and 'Special:' pages,
  and reject interwiki prefixes. PrefixSearch class centralizes this code,
  and the backend part can be overridden by the PrefixSearchBackend hook.
2008-01-30 01:07:49 +00:00