Commit graph

62 commits

Author SHA1 Message Date
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Stanislav Malyshev
a735346f58 Fix deprecation message - use correct method name (defaultPrefixSearch)
Change-Id: Ie4dbb28b4ca11ecfeaccd331db55f92130f6cdf1
2016-12-17 12:13:04 +00:00
Stanislav Malyshev
e421158b1a Rank aliases in search in order they appear in the messages file.
This will ensure the local page name (which is the first alias) is prioritized.

Bug: T151660
Change-Id: I3cc266024f5e052d20ff55c4b2c6cbd2945e3dd3
2016-11-29 15:15:42 -08:00
dcausse
bd7df68603 Do not run exact db match if offset is > 0
When scrolling results on prefix search api the exact Title
match is always at pos 0 even if we want to scroll the results
by setting offset to > 0.

Change-Id: Ib02c9d3e479d739e6fe79014d962db50b6fd9de8
2016-09-27 15:28:14 +02:00
Niklas Laxström
64670b28d2 PrefixSearch: Implement 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.

This by extend also brings support for multiple namespaces to the
opensearch API.

Follows-up I3487bb69.

Bug: T67752
Bug: T32323
Change-Id: I4bec7b5548fc27ac51a1b4d4961c3bbc31eb7337
2016-09-15 14:48:35 +02:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Stanislav Malyshev
027972a20f Include completion search into SearchEngine
By default it still uses PrefixSearch and supports PrefixSearchBackend
but it can be deprecated and phased out and SearchEngine extensions used
instead.

New APIs:
- SearchEngine
	public function defaultPrefixSearch( $search );
	public function completionSearch( $search );
	public function completionSearchWithVariants( $search );

Search engines should override:
protected function completionSearchBackend( $search );

Bug: T121430
Change-Id: Ie78649591dff94d21b72fad8e4e5eab010a461df
2016-02-03 23:41:49 +00:00
dcausse
353ae71963 Extracted some code from PrefixSearch for re-usability by other search engines.
(This patch is needed for Ida9b9f8)

Bug: T112028
Change-Id: I35aece88333a65f6b1f55f7a87e2d14de4f5bea7
2015-12-02 17:18:08 +00:00
Timo Tijhof
b7f078c75e Remove redundant null-handling for Title::newFromText
* Linker: Follows-up 9ce5ca9886. null is already handled.

* PrefixSearch: Follows-up 337b1e2e. null is already handled.
  If other types are bassed, we want to find these.

* UploadBase: Follows-up 11f5ebec28. null is already handled.
  WebRequest::getVal($name) can only return string or null.

Change-Id: I3dc3b700cde735f5cd9d497f0867a2b4e3b61f46
2015-11-17 01:53:30 +00:00
Chad Horohoe
119a792d74 PrefixSearch: avoid looking for titles that don't exist
WikiPage::getRedirectTarget() can very easily return null. Don't
blow up when that happens.

Properly document PrefixSearch::getRedirectTarget() while we're
here.

Bug: T116029
Change-Id: Ib509e8e3e6ec04a787de3857a4b5ee9b01560559
2015-10-26 11:50:23 -07:00
Chad Horohoe
337b1e2ecd PrefixSearch: Avoid passing non-strings to Title::newFromText()
We already handle the invalid title gracefully here anyway, so
just rely on that behavior and just skip the Title construction
bit :)

Bug: T109975
Change-Id: I0dc3d91b6b4cfb97664aa6ca39c5c8f086d70db5
2015-09-02 22:57:09 -07:00
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