Commit graph

381 commits

Author SHA1 Message Date
jenkins-bot
8ffabe23a1 Merge "Fix param type of search terms in search related classes" 2019-06-17 07:54:27 +00:00
Aaron Schulz
a15be13371 search: clean up some type hints in search classes
Change-Id: I357a78b42ea02a63c3b64e8982f04314cbbfdf9f
2019-06-16 23:29:33 +00:00
Umherirrender
9421f6f52f Fix param type of search terms in search related classes
Change-Id: I036434268f1e7992f7f9f23d2c1c0fcd399823c8
2019-06-14 19:50:12 +02:00
Derick Alangi
21e2d71560 Replace some uses of deprecated wfFindFile() and wfLocalFile()
These global functions were deprecated in 1.34 and services made
available to replace them. See services below;

* wfFindFile() - MediaWikiServices::getInstance()->getRepoGroup()->findFile()
* wfLocalFind() - MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()->newFile()

NOTES:

* wfFindFile() and wfLocalFind() usages in tests have been ignored
  in this change per @Timo's comments about state of objects.

* includes/upload/UploadBase.php also maintained for now as it causes
  some failures I don't fully understand, will investigate and handle
  it in a follow up patch.

* Also, includes/MovePage.php

Change-Id: I9437494de003f40fbe591321da7b42d16bb732d6
2019-06-11 13:26:37 +00:00
Derick Alangi
09567cc368 SearchResultSet: MW version number should be a string in wfDeprecated call
Seems this was a typo and I think 1.32 which is a double/float will be
implicitly converted to true (bool) because it will resolve 1.32 to 1 as
integer and then 1 which maps to true (bool).

To avoid this, use '1.32' instead of the integer form of the version.

Change-Id: Ifaf6ab0d36bc02bd1707f8caf375f65a30eb1af5
2019-05-15 15:17:23 +01:00
Derick Alangi
facddc488a SearchResult: MW version number should be a string in wfDeprecated call
Seems this was a typo and I think 1.32 which is a double/float will be
implicitly converted to true (bool) because it will resolve 1.32 to 1 as
integer and then 1 which maps to true (bool).

To avoid this, use '1.32' instead of the integer form of the version.

Change-Id: I2420396e110284f582cd79820ffc6064e247b4b9
2019-05-14 12:36:30 +00:00
Derick Alangi
a1731db5ab SearchEngine: Remove deprecated unused method transformSearchTerm()
I've checked around with code search tool and realized that SMW has
its own implementation of `transformSearchTerm()` which overwrites the
implementation of this method from core as it extends SearchEngine.

So removing this won't break SMW, see usage below;

Usage
=====

https://codesearch.wmflabs.org/search/?q=%5CbtransformSearchTerm%5Cb&i=nope&files=&repos=

Bug: T220656
Change-Id: I3dbe04ecba07700167c894673e23c1eead95460f
2019-05-13 15:37:00 +01:00
jenkins-bot
34d2b3aa23 Merge "Simplify by using ?: operator" 2019-05-09 16:25:22 +00:00
Derick Alangi
15269e9500 SearchEngine: Followup on I623b39e7ec791a66c4cf40
Per https://www.mediawiki.org/wiki/Deprecation_policy#Deprecation,
the version for hard deprecation must be exactly the same as the
one it was soft deprecated in.

Bug: T221431
Change-Id: Ib7c2b569959194e15f50c62fe0eca1c3011bc50e
2019-05-09 15:54:56 +01:00
jenkins-bot
3b0ff76e95 Merge "SearchEngine: Hard deprecate SearchEngine::transformSearchTerm()" 2019-05-07 19:51:34 +00:00
Derick Alangi
20bb2b067e SearchEngine: Hard-deprecate PrefixSearch::titleSearch()
Usage
=====

https://codesearch.wmflabs.org/search/?q=%5B%5E%3E%5D(-%3E%7C%3A%3A)titleSearch&i=nope&files=&repos=

Only the MassEditRegex extension uses this method per the search,
so hard deprecating this method.

Change-Id: Ia10caacd3cde94f08e59f5f8d7e90f61c7de604e
2019-05-06 15:57:21 +00:00
Derick Alangi
f9f2809a38 SearchEngine: Hard deprecate SearchEngine::transformSearchTerm()
As a follow up of it's soft deprecation in 1.32, this method should
be hard deprecated and removed. Also, remove related code that calls
this method.

Usage:

https://codesearch.wmflabs.org/search/?q=(%3A%3A%7C-%3E)transformSearchTerm&i=nope&files=&repos=

Bug: T221431
Change-Id: I623b39e7ec791a66c4cf40178edb80b2ebf4bb06
2019-04-26 19:24:02 +00:00
jenkins-bot
37344b9daf Merge "Define index types as strings" 2019-04-23 08:57:59 +00:00
Stanislav Malyshev
9e035a229e Define index types as strings
This will allow to use them easier in JSON config files.

Bug: T142809
Change-Id: I4053a87fe8e53c9b506604db6fad2f98f7dba150
2019-04-18 23:59:18 -07:00
Derick Alangi
0a4c2670a1 search: Remove unused deprecated methods replaced by MW Services
The following methods deprecated in .27 and no longer used have
been removed;

- SearchEngine::userNamespaces()
  https://codesearch.wmflabs.org/search/?q=%3A%3AuserNamespaces&i=nope&files=&repos=

- SearchEngine::namespacesAsText()
  https://codesearch.wmflabs.org/search/?q=%3A%3AnamespacesAsText&i=nope&files=&repos=

- SearchEngine::create()
  https://codesearch.wmflabs.org/search/?q=SearchEngine%3A%3Acreate&i=nope&files=&repos=

- SearchEngine::getSearchTypes()
  https://codesearch.wmflabs.org/search/?q=%3A%3AgetSearchTypes&i=nope&files=&repos=

- SearchEngine::getNearMatch()
  https://codesearch.wmflabs.org/search/?q=SearchEngine%3A%3AgetNearMatch%5C(&i=nope&files=&repos=

Also, replace deprecated use of searchableNamespaces() in SearchEngine.

Bug: T220656
Change-Id: I330fbfea158f70b2328da7c850fdb833e39b6c7d
2019-04-19 00:09:42 +00:00
James D. Forrester
f84457f8bd SearchEngine: Hard deprecate unused static methods deprecated in 1.27
Change-Id: I96c4454a2f89df0be5de20ca0506c3ce2c75cf7c
2019-04-18 16:54:30 -07:00
Fomafix
8a314d9b43 Simplify by using ?: operator
Change-Id: I2851cc51c9e05dd0599733be5af39e19f12b52e2
2019-04-15 15:05:00 +02:00
jenkins-bot
7f2f49ad23 Merge "Improve documentation of constants throughout the codebase" 2019-04-12 21:38:16 +00:00
Aaron Schulz
449ad97224 search: make legalSearchChars() non-static
No outside callers from code in gerrit are using this statically

Change-Id: I9513a5384bca71f419a9af09908678bcc86c0263
2019-04-11 17:55:54 -07:00
jenkins-bot
b306873222 Merge "Remove references to field rev_text_id" 2019-04-09 15:25:05 +00:00
Kunal Mehta
4ef179e335 Fix/suppress misc phan errors (#5)
Add lots of missing return statements, or remove incorrect doc blocks.

Change-Id: I0881e98fbb9d0d4cf79ecc824064d24538055d3f
2019-04-05 15:53:37 -07:00
Umherirrender
6745cb572a Move class SearchEngineDummy to own file
Each class should have its own file, even it is a no-op

Change-Id: I90124ed35e354c546fcd69d52dc1febb71b2c71f
2019-03-29 20:35:35 +01:00
Umherirrender
8d5a8fb181 Move PrefixSearch classes to own files
Move all into search subfolder

Change-Id: I4097b9745d22545afe6761da1fa67cf98af5b811
2019-03-27 21:40:33 +01:00
Bill Pirkle
8f03082521 Remove references to field rev_text_id
Field rev_text_id is being retired as part of MCR Schema Migration.
Remove references to this field from the Postgres search queries.

Bug: T198341
Change-Id: Id3cbf853aacc06709f441a93248b55943097cd11
2019-03-26 10:41:29 -05:00
Thiemo Kreuz
18741b9306 Improve documentation of constants throughout the codebase
The most notable improvements I was able to fit into this patch can be
seen in the User class, as well as in AbstractRestriction.

Our documentation generator ignores the @const tag. It's not needed. Just
have a comment above a constant and it will show up in the generated
documentation.

Using @var is misleading because a constant is not a "variable". The type
of a constant is strictly derived from it's value. Documenting the type
typically does not provide useful information. Doxygen does not understand
the type, but ignores any @… tag and renders everything else as plain text.

I can split this patch if you prefer. Please tell me.

Change-Id: I8019ae45c049822cdc1768d895ea3e3216c6db5f
2019-02-26 14:02:50 +01:00
James D. Forrester
5cc3a2ae4e Drop SearchEngine::getNearMatchResultSet(), deprecated in 1.27 and unused
Change-Id: I87987af702b9b92c4d1b3578e69f1b2e68529b52
2019-02-09 08:43:30 +00:00
Thiemo Kreuz
734a969d55 Safe replacement of a lot of !count() with === []
This was originally a global search and replace. I manually checked all
replacements and reverted them if (due to the lack of type hints) either
null (that would be 0 when counted) or a Countable object can end in the
variable or property in question.

Now this patch only touches places where I'm sure nothing can break.

For the sanity of the honorable reviewers this patch is exclusively touching
negated counts. You should not find a single `!== []` in this patch, that
would be a mistake.

Change-Id: I5eafd4d8fccdb53a668be8e6f25a566f9c3a0a95
2019-01-15 17:28:49 +01:00
Max Semenik
1da14005d9 Hard deprecate SearchEngine::getNearMatchResultSet()
Deprecated in 1.27, no callers.

Change-Id: I6084a114fe8d0b4681e2e4b55eada06b684c719c
2018-12-08 22:23:24 -08:00
jenkins-bot
bd78869618 Merge "No yoda conditions" 2018-12-09 01:34:23 +00:00
Jakub Vrana
45435d05a5 Change typehint callback to callable
Found by PHPStan.

Change-Id: I09f21da69ad9b9357cee85a47717dbe1bca04070
2018-12-01 10:10:41 +01:00
Fomafix
3ee1560232 No yoda conditions
Replace
  if ( 42 === $foo )
by
  if ( $foo === 42 )

Change-Id: Ice320ef1ae64a59ed035c20134326b35d454f943
2018-11-21 17:54:39 +01:00
jenkins-bot
5466734477 Merge "doc: Modernise parameter names and documentation for 'replica' DBs" 2018-11-13 21:39:14 +00:00
jenkins-bot
fbc9e214e7 Merge "Add docstrings for text search index field types" 2018-11-01 10:21:55 +00:00
Adam Wight
861d718768 Add docstrings for text search index field types
Change-Id: Icd34ec79db4d8fd024a82045aaa9bedb6556caa8
2018-10-31 17:30:58 -07:00
James D. Forrester
903e8b63de doc: Modernise parameter names and documentation for 'replica' DBs
Non-breaking change. Remaining uses are public interfaces (a constant, two
globals, a config sub-parameter, SQL queries, storage function names), one i18n
message key, and a whole lot of maintenance scripts with calls to the deprecated
function wfWaitForSlaves().

Change-Id: I6ee5ca92ccf6a80c08f53d9efe38ebb4b05064d7
2018-10-31 10:36:48 -07:00
Fomafix
43244db9a2 Use PHP 7 '??' operator instead of if-then-else
Change-Id: If9d4be5d88c8927f63cbb84dfc8181baf62ea3eb
2018-10-21 21:46:46 +02:00
Fomafix
5632815976 Write Latin and other scripts with captial letter
Change-Id: I16c660e54191b63cd6eb3407cb00504665930c4e
2018-10-05 18:49:08 +02:00
Erik Bernhardson
b357416273 Go search to consider fragment only title invalid
When submiting using the 'go' feature of Special:Search (standard
usecase for autocomplete) a nearby title can be selected.
Unfortunately a fragment only title is considered valid, which
sends the user to Main_Page#searchterm.

Instead don't allow a search starting with # to trigger the go
feature.

Bug: T182452
Change-Id: I8ce3ce8633e23db41ae6eafb9996ca7294f8445a
2018-09-11 13:03:53 -07:00
Zoranzoki21
1f2e9c1b54 Fix common typos in code
Bug: T201491
Change-Id: Id962b79f2590c51380cb977e727b7548abc11d33
2018-09-02 09:03:07 +00:00
jenkins-bot
9171317645 Merge "Add Special:Search sort parameter without ui" 2018-08-21 14:57:13 +00:00
Umherirrender
40d3ce8d17 Reduce calls to MediaWikiServices::getInstance()
In some functions MediaWikiServices::getInstance() was called twices or
in loops. Extract the variable to reduce calls.

Change-Id: I2705db11d7a9ea73efb9b5a5c40747ab0b3ea36f
2018-08-18 06:02:39 +02:00
Erik Bernhardson
c6a83871b5 Add Special:Search sort parameter without ui
Search engines support the sort parameter, it would be nice if we
could pass it to be rendered in the web ui. This avoids implementing
any ui, which can be done at a later time.

Bug: T195071
Change-Id: Id7bd35bd4259bb1f1f856933d279dbd6eddfa2e2
2018-08-16 17:12:05 -07:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
Timo Tijhof
64892ce978 search: Use self::class instead of __CLASS__ in SearchResultSet
For ease of understanding, use the same technique for both
sides of the comparison. Follows-up c2a308075f.

Change-Id: I66475fd4baaa6ab7cd24ad884e9fe01a1cd30d9f
2018-08-08 01:08:37 +01:00
David Causse
cf41c48f8d Deprecate SearchEngine::replacePrefixes
This should be handled internally by SearchEngine implementations.

Bug: T198860
Change-Id: Ifbfd0fcb81fcacf5228bd2ffcac7b80fca872b2a
Depends-On: I7d4ff9498fa1f4ea66835c634b8931f4c29993fb
2018-07-17 21:56:14 +00:00
David Causse
3115b3202d Unify SearchEngine normalizeNamespace and parseNamespacePrefixes
These methods are very similar there should be no need to have
two differents way to extract the namespace prefix.

Bug: T198860
Change-Id: I22802278452559d35a3d8f6068549c1fef1a5e86
2018-07-17 21:56:05 +00:00
David Causse
46c17ddb1f Deprecate usage of SearchEngine:transformSearchTerm
This method was introduced in 4115586000
to support the prefix URI param introduced by the InputBox extension.
There are no reasons that this logic is exposed to SearchEngine users
and should be handled internally by SearchEngine implementations
that supports it.
Previously the search query was updated, now the prefix param will passed
along using SpecialSearch::$extraParams.

Bug: T198318
Change-Id: I33518d3f3ddee741ff4f3b47eb4928009bea66d1
Depends-On: I67c7f1886dd6a2d07c12015e2711c138e9f140e9
2018-07-17 14:41:08 -07:00
jenkins-bot
ef97002179 Merge "Simplify PHP by using ?? and ?:" 2018-07-11 09:09:18 +00:00
Fomafix
6866cfec37 Simplify PHP by using ?? and ?:
Also remove not necessary surrounding parentheses.

Change-Id: I0eb5c9c1bdfb09a800258379cdcefb5fd4d3d21c
2018-07-10 20:03:17 +00:00
C. Scott Ananian
0935e47a72 Remove most uses of deprecated Language::truncate()
The Language::truncate() function was split into
Language::truncateForVisual() (which measures characters) and
Language::truncateForDatabase() (which measures bytes) in 1.31, but
the patch which soft-deprecated Language::truncate() didn't actually
remove all the uses in the codebase.  Replace most of those old uses
now, which should actually improve the situation for
non-latin-alphabet users who were getting unfairly squeezed in a
number of places.

Bug: T197492
Change-Id: I2291c69d9df17c1a9e4ab1b7d4cbc73bc51d3ebb
2018-07-09 13:36:27 -04:00