Commit graph

398 commits

Author SHA1 Message Date
WMDE-Fisch
e1518660e1 Use ExtensionRegistry instead of class name
Use the ExtensionRegistry instead of checking for the main class
name of the Cite extension. - I'm not entirely sure if this is much
better. A hook would still be the better option. But at least Cite
could be refactored and the class name changed.

Bug: T89151
Change-Id: I35e5aa9955141b575de68a5be2c0d5b87585eb77
2019-08-14 19:07:39 +02:00
Aaron Schulz
2eb5bdbac6 rdbms: remove DatabaseSqlite::checkForEnabledSearch() in favor of explicit queries
Change-Id: I0f13b9f054d7732f0e9694ec75c415f91a36ede9
2019-08-07 18:47:36 -07:00
jenkins-bot
bb844b11ba Merge "Deprecate SearchEngine:getTextFromContent() and SearchEngine::textAlreadyUpdatedForIndex()" 2019-08-02 06:40:17 +00:00
jenkins-bot
f585244a77 Merge "Document SearchDatabase::doSearchTextInDB to return null" 2019-08-01 21:51:36 +00:00
David Causse
63e199226d Deprecate SearchEngine:getTextFromContent() and SearchEngine::textAlreadyUpdatedForIndex()
It was just a wrapper to Content::getTextForSearchIndex(), simply use
this method rather than depending on (and sometimes constructing) a
SearchEngine.

Change-Id: I8541248ffdca303f0af3b959cf2f051dcb497925
2019-08-01 17:59:32 +02:00
David Causse
c6b4bdf0ab Deprecate SearchEngine::userHighlightPrefs()
was only returning two constants and forced a cyclic dep bewteen
SearchEngine and its SearchResult instance.
Simple make these values a constant in SearchHighlighter and use
them as default values for the highlight methods.

Change-Id: Ia78408d5266d0a305006027fe6265a2a1d68b0b9
2019-08-01 17:16:41 +02:00
Umherirrender
b037a852f8 Document SearchDatabase::doSearchTextInDB to return null
The function calling this abstract function allows to return null,
so it should be okay to return null here

The null for empty result in SearchOracle

Change-Id: I66a8fb3a4190bf5506f358a47f6f4833b1715c7f
2019-07-31 18:15:13 +02:00
David Causse
ff6b6a758a Add SearchResultSetTrait
trait meant to hold methods that rarely overridden or that are
non trivial to implement.

Bug: T228626
Change-Id: I4fba27b22860109d648e830a435d4a036d26ad06
2019-07-25 15:52:36 +02:00
David Causse
e97ff3524b Add BaseSearchResultSet
Meant to hold the B/C behaviors and be the base class implemented
by extensions.

Bug: T228626
Change-Id: I072a9bd0f94bd785d1ff51f0e6ee13790e37b417
2019-07-25 15:47:01 +02:00
David Causse
7a8ef16670 Add explicit visibility to SearchResult methods
Change-Id: Ifaa2f6b683690a130eef3439ffd9c1debfb188fe
2019-07-24 12:01:46 +02:00
David Causse
79895c7882 Add explicit visibility to ISearchResultSet methods
Change-Id: Ic1ad60fac6183004c4dfc110c8dfde95b57cdd9b
2019-07-23 10:59:41 +02:00
David Causse
6af636fb03 Add ISearchResultSet
Bug: T228626
Change-Id: I3306bf6107c97dd58adf578fd965bd11a422627d
2019-07-22 18:27:39 +00:00
David Causse
5420bf307b Deprecate SearchResultSet::free
Was only called by SpecialSearch, according to IResultWrapper::free()
this method is rarely worth being called. Therefor it does not seem wise
to expose it in the upcoming interface defining a search result set.

Bug: T228626
Change-Id: I12d41a488025eb2d6dd543c9fbdc1c803c840316
2019-07-22 17:46:00 +02:00
Aaron Schulz
f72ae0f6e6 Switch various LoadBalancer::getConnection() callers to getConnectionRef()
This is the preferred method as it enforces read-only mode for DB_REPLICA
and handles LoadBalancer::reuseConnection() calls automatically.

Change-Id: Iab9439ba8e0810fa14c302661ed7a3534f6bfc0d
2019-07-12 10:56:30 -07:00
David Causse
92c20832f1 Deprecate SearchResult::termMatches()
And start indicating that hooks relying on this data might become
unreliable as this data is only populated by SearchDatabase search
engines.

This information was only populated by SearchDatabase implementations
and due to bad initial design of SearchResult[Set] (now fixed) it forced
users of these classes to carry this information for the sole purpose of
highlighting.
Because SearchEngine can now own their SearchResult[Set] implementations
nothing that is engine specific should be exposed outside of these
specific implementations.
If there are some logic that still requires access to such list of terms
they should be made engine specific by guarding their code against
instanceof SqlSearchResult.

Change-Id: I38b82c5e4c35309ee447edc3ded60ca6a18b247a
Depends-On: I53fe37c65c7940f696c1e184125e01e592a976e4
2019-06-27 08:44:06 -07:00
Aaron Schulz
d16fb6515b search: refactor DatabaseSearch to take a load balancer instance
Also make the update() methods of the subclasses use DB_MASTER as they
should. This avoids read-only errors.

In addition, avoid passing a dummy argument of null in some cases
within SearchEngineFactory::create(). Fix some dynamic calls to
static methods too.

Change-Id: Id94f34994b0f9c18e23ef30cb2fe895e6dedd09c
2019-06-26 03:03:37 +00:00
James D. Forrester
ac5b9e53df PrefixSearch: Drop titleSearch(), deprecated in 1.23
Change-Id: I3e11421953bfe63856e29b928727c8264275cd25
2019-06-24 11:11:17 -07:00
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