Changes to the use statements done automatically via script
Addition of missing use statement done manually
Change-Id: I73fb416573f5af600e529d224b5beb5d2e3d27d3
Implicitly marking parameter $... as nullable is deprecated in php8.4,
the explicit nullable type must be used instead
Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a
Break one long line in SpecialPage.php
Bug: T376276
Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
A constant is not a variable. The type is hard-coded via the value
and can never change. While the extra @var probably doesn't hurt much,
it's redundant and error-prone and can't provide any additional
information.
Change-Id: Iee1f36a1905d9b9c6b26d0684b7848571f0c1733
Callers should not catch an unchecked exception, so it doesn't belong
in a function signature. Unchecked exceptions indicate a coding error,
which by definition the code will not be able to handle correctly.
If any of these exceptions were supposed to be in response to an edge
case, user input, or initial conditions, then they should be changed
to a runtime error. If the exception class cannot be changed, then
the annotation should include a comment explaining its purpose and
prognosis.
Bug: T240672
Change-Id: I2e640b9737cb68090a8e1cb70067d1b74037d647
wfGetUrlUtils() is also deprecated, but less so, so we can do this first
and then properly replace the individual uses with dependency injection
in local pieces of work.
Also:
* Switching Parser::getExternalLinkRel to UrlUtils::matchesDomainList
exposed a type error in media.txt where $wgNoFollowDomainExceptions
was set to a string (which is invalid) instead of an array.
Bug: T319340
Change-Id: Icb512d7241954ee155b64c57f3782b86acfd9a4c
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.
Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.
Change-Id: I2606072015d71b4bdda70a7c149d9f55ac205a3c
* footerHtml() contained seemingly unused logic for extracting
the host name for use in the "search-interwiki-resultset-link"
message.
This was added during in change I9498a070da (T307468, 0d1184e501).
It seems to be a left-over from the "search-interwiki-default"
message that Special:Search used previously.
Overrides for specific wikis are now in the heading based on the
the "search-interwiki-custom" message, which feeds customCaptions
which takes precedence over the entire message, instead of requiring
wikis to e.g. switch/if-case inside wikitext based on "$1" or something.
The qqq.json entry for "search-interwiki-resultset-link" mentions
no parameters, and none of the translations use it either. I've
also checked WikimediaMessages extension, en.wikipedia.org, Commons,
and Wikidata in case they use the parameter there, but found nothing.
* headerHtml() used wfExpandUrl() combined with wfParseUrl().
This is problematic for Phan analysis since both can fail and
technically require a fallback. This is currently tolerated by Phan
because it doesn't yet understand that `false[key]` yields the
same kind of warning PHP as `null[key]`.
https://github.com/phan/phan/issues/4879
It seems this code has evolved over the years into what it is
now, and it's not clear that this is all intentional or by design.
In 2011, r95011 (92ff782a9) changed this code from parse_url to
wfParseUrl to handle protocol-relative URLs, which has long been
fixed in PHP: https://3v4l.org/sSkfX.
In 2017, If78cb0c29a (6e155624fa) changed further switched from
Title->getUrl() to Interwiki->getURL() with wfExpandUrl() to handle
same-site destinations, e.g. when an interwiki is on the same
domain, and defined on Special:Interwiki without any hostname.
The code had a note saying:
"hostname of the other wiki which might suck if there are many wikis
on one hostname" which appears to remain true today.
I've changed this all back to parse_url(), with an explicit fallback
to $iwPrefix for invalid urls or same-site interwikis. If we
want to display the current domain name there instead, we can do
that explicitly by falling back go $wgServerName instead.
* Fix potential escaping problem by pasing $caption to element()
instead of rawElement() since in headerHtml() at least one of the
values in the assignment chain caption is plain text, not escaped
HTML. Move escaping down to the last mile by storing plain text
instead.
Idem for footerHtml(), although that one is safe and simple as-is,
I've switched it similarly to plain text and let Html::element do
the escaping.
Change-Id: I3281e12ee52af168f85cdb12ac4d53fc25c9f38d
Avoid assigment in conditions
foreach starts at begin of iterator, the while loop can process the next
from within the result, but all the iterator in search are rewinded
before iterator starts
Change-Id: I38b2729418e8389c681c6cd84858f5e5ed25bd3e
get_debug_type() does the same thing but better (spelling type names
in the same way as in type declarations, and including names of
object classes and resource types). It was added in PHP 8, but the
symfony/polyfill-php80 package provides it while we still support 7.4.
Also remove uses of get_class() and get_resource_type() where the new
method already provides the same information.
For reference:
https://www.php.net/manual/en/function.get-debug-type.phphttps://www.php.net/manual/en/function.gettype.php
To keep this safe and simple to review, I'm only changing cases where
the type is immediately used in an exception message.
Change-Id: I325efcddcb58be63b1592b9c20ac0845393c15e2
Avoid the call to internal constructor of AndExpressionGroup and
OrExpressionGroup by creating a factory function similiar as the
IReadableDatabase::expr function for Expression objects.
This is also a replacement for calls to ISQLPlatform::makeList with
LIST_AND or LIST_OR argument to reduce passing sql as string to the
query builders.
Created two functions to allow the return type to be set for both
expression group to allow further calls of ->and() or ->or() on the
returned object.
Depending on the length of the array argument to makeList() it is
sometimes hard to see if the list gets converted to AND or OR, having
the operator in the function name makes it easier to read, so two
functions are helpful in this case as well.
Bug: T358961
Change-Id: Ica29689cbd0b111b099bb09b20845f85ae4c3376
It was asked in a patch review to apply fully import
InvalidArgumentException where possible. I was guessing some
of my other already merged patches have but turned out such
thing exists other places style so for the sake of consistency
I've turned rest of inline import of the specific exception at
top of the file.
There are instances of source files that aren't in any namespace but
have fully qualified import which this patch doesn't touch.
Change-Id: I4071fc698b65746d9594cf4d5f45bae82843d436
This patch introduces a new namespace declaration,
MediaWiki\Xml and adds Xml and XmlSelect to it
and establishes class aliases marked as deprecated
since version 1.43.
Bug: T353458
Change-Id: I45cccd540b6e15f267d3ab588a064fbeb719d921
This skips ones that have been marked but were never in the then
RELEASE-NOTES and later HISTORY file, and so weren't properly
deprecated ever.
Change-Id: I31df2d7e83182b5bf9524237fc4a1862356bfd5a
This patch uses the recommended MW practice for injecting
settings into MW services. Instead of passing in the full
config object, pass in service options which MW service wiring
will use to lookup settings/options from config sources.
So in this patch, the various options have been identified
and put into `CONSTRUCTOR_OPTIONS` constant and inject via
service wiring.
Test plan
=========
Ensure that the special page: `Special:Search` still works
with this patch checkout on your local test wiki.
When you visit `Special:Search` on your local wiki, you should
see a search form view. Type in something like: "Main Page" and
then hit search. If everything works well, then local test passes.
NOTE
====
This patch also resolves a TODO which mentions the removal of
the `getConfig()` method from the SearchEngineConfig class.
Change-Id: Ib5dfc10f3f210c6c35247f4f30f9549dd60e0af7
Pages that are "unlisted", i.e. SpecialPage::isListed returns false,
are now excluded from auto-completion. These are essentially pages
that are for scripted/non-human purposes (e.g. Special:RunJobs) and
redirect pages (e.g. Special:AllMyUploads).
Note that redirect pages can opt-in to being listed, and thus do
appear on Special:SpecialPages and thus remain included in search
suggestions, such as Special:Diff.
This patch creates a getListedPages utility instead of re-using
SpecialPageFactory::getRegularPages for two reasons:
1. Consistency with Special:SpecialPages.
2. Avoid hiding major and popular user-facing features that require
logging in and/or some user right, such as Special:Watchlist,
Special:Block, and Special:Upload.
This patch doesn't use SpecialPageFactory::getUsablePages because it
is unsafe outside index.php page views (invokes user session), and
make the results incompatible with HTTP caching of OpenSearch API.
Bug: T358938
Change-Id: I1cb5f4c3cedb02eb41fcac3b8f785616ce54d73c
Only docs needs adjust, but phan is using this needs changes in the
search related classes.
Doc change in IForeignRepoWithDB is needed, the implementation in
LocalRepo returns the value from IConnectionProvider::getReplicaDatabase
Change-Id: I01a1aa0ddbc756226d8e3404ac1cc3350ad5df64
If we are serious about getting rid of wfGetDB(), we should start
replcing callers with proper replacement.
These classes don't have any injection so it doesn't make sense to
introduce it for this specific usecase.
Bug: T330641
Change-Id: I645f67324d441288c63787c7e42390b59106c585
Updating name & email addresses for Brooke Vibber.
Re-ran updateCredits.php as well so there are some new entries in
there as well.
There are a couple of files in resources/libs that will have to
be changed upstream to keep tests happy, I will do patches
later. :D
Change-Id: I2f2e75d3fa42e8cf6de19a8fbb615bac28efcd54
Found via (?<!IDBAccessObject)::READ_
We are planning to deprecate and remove implementing IDBAccessObject
interface just to use the constants.
Bug: T354194
Change-Id: I89d442fa493b8e5332ce118e5bf13f13b8dd3477
The TitleFactory should really be where TitleArrayFromResult should
live as it's a place where Title objects are created based on certain
specifications.
This patch tries to consolidate the creation of TitleArrayFromResult
via the TitleFactory services and in the future, we will consolidate
more of the logic and kill TitleArrayFromResult.
Follow up on: a99ec1b and e54665d.
Change-Id: I98215af3252d756de4435b77d1280dacda8e85dc
This patch amends the FauxSearchResult class by
adding a call to the parent constructor within its own
constructor method. Previously, the FauxSearchResult
class was not calling the parent's constructor, which
could lead to initialization issues.
Change-Id: Ib3d569daa49605e32b3bf2675d41ab20c6a000eb
There are a couple of user options related classes already,
and the T321527 work on dynamic defaults is going to add
even more. Let's move them into a separate namespace
to make core a bit more organized.
Old name is kept as an alias for compatibility purposes.
Bug: T321527
Bug: T352284
Change-Id: I9822eb1553870b876d0b8a927e4e86c27d83bd52
I was getting terrible performance on searches, and discovered that the
query planner was first using the page namespace index to quickly find
pages with the right namespaces, then doing a separate full text search
for each page. To fix this durably, use CROSS JOIN instead of "," for
the join, which is semantically the same but acts as a hint to the query
planner that indexes on the first table listed should be searched first.
https://www.sqlite.org/optoverview.html#manual_control_of_query_plans_using_cross_join
Change-Id: I756f6b43f84894c76e46b3a3221107d9834a493a
When the search engine returns a match to a redirect R1 pointing to a
page P1 as part of its results, if the user typed an exact match to
another redirect R2 that targets the same P1 we should:
- rerank R1 to the top (what was done)
- replace R1 with R2 as the preferred form (what is done now)
Bug: T346920
Change-Id: I77c4870aacb9c3ffa215cc0b0f3c417484cc98fd
the pageMap is a cache of page ids often used to quickly verify the
presence of a page in the set.
When shrinking this map should be updated to properly reflect the set of
page ids.
Not keeping pageMap updated caused a bug to appear when the exact match
is found by the underlying search engine at position limit+1 (overfetch
technique). Shrinking the set to limit did not properly remove the exact
match entry from pageMap which prevented the prepend method from adding
the exact match as part of the SearchExactMatchRescorer.
Bug: T347786
Change-Id: Id524cc5af8e62e64f0a680b8e08078d14872f97d
TitleArray is just a tiny little wrapper to TitleArrayFromResult,
so use the latter instead of the former. I have plans of killing
the former soon.
Change-Id: Ia06a6bb370ce313f38d3ec9a221ed7296aec0ee2