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
This patch introduces a namespace declaration for the
MediaWiki\Content to TextContent and establishes a class
alias marked as deprecated since version 1.43.
Bug: T353458
Change-Id: Ic251b1ddfcf6db9c85cb54cddf912aa827d2bc3a
If a news: or mailto: URL is specified with two slashes, it will have a
'host' rather than a 'path' after all, so this workaround is unnecessary
and should be skipped in that case; compare also change Idc6b389da9
(commit ec1b572362) for makeIndexes().
I’m not very sure that the test case makes much sense, but it’s at least
enough to trigger the error and verify the fix.
Bug: T364743
Change-Id: I09be813e661b80968da00d8a898b2add8c95fec7
Avoid use of array.
It removes some extra parenthesis from the query which are only one
expression and no longer a AndExpressionGroup, as a group with one
element is not needed.
Bug: T358961
Change-Id: I9daad5e3703bd4a94f56d384c922cb415b5c2fb4
Update cases where one of the IConnectionProvider methods is called
immediately.
This doesn't really change anything, but I hope it helps promote
getConnectionProvider() as the common way to do this.
Follow-up to 8604c384f6.
Change-Id: Id0e7d02bab0c570343c2b1f03c70b44ee39db112
The wfParseUrl function is deprecated as of MediaWiki 1.39 and has been
replaced with the UrlUtils::parse method provided by the UrlUtils class.
Change-Id: I5df192af99b38774c458bd4e0836fdce581683dd
Instead of replacing 1 character at a time the functions used here
can replace sequences of any length. This can dramatically reduce the
function call overhead.
Also make use of the `fn ()` syntax because we can.
Change-Id: I2dbc2271aa7847d9b687703f837cb0d850596ef0
This setting can be used to optimize externallinks queries for certain
domains that have many entries in the externallinks table, but also big
“gaps” where the table contains no entries for that domain. By putting
those gaps (whose el_id values would usually have been obtained on the
analytics databases) into the configuration, we can have MediaWiki tell
the database to skip those ranges of the table instead of scanning
through them. (This is only relevant for domains that have enough
entries that the database chooses to scan the table in primary key order
rather than using the el_to_domain_index_to_path index and filesorting.)
Bug: T341000
Change-Id: Iec4fe01aaa595fbaf3b427b7baa68a9d7209b117
Already dropped from production
Also dropping FixExtLinksProtocolRelative as it's not useful anymore and
it has been run in previous releases so it's not worth fixing.
Bug: T312666
Change-Id: I1dd6e704b34e685ada6e316da11243d10827d769
wfGetDB() has been deprecated since 1.39 (or more?) and it's better to
inject LBF and call ::getReplicaDatabase() or ::getPrimaryDatabase()
which is not straightforward in classes but for static functions, there
is no way to inject the method so we can simply call
MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
While I was here, I migrated one call to SelectQueryBuilder.
Bug: T330641
Change-Id: Idd2278cef647035dce05a2d461a620e145fe1167
This hack was originally added to wfParseUrl
as a fix for T10324 specifically for LinkFilter,
however according to the RFC 3986 this is wrong.
RFC defines that in URLs the authority component
must start with //, so in urls without //, e.g. news:
or mailto: there is no authority component, and thus
no host component, everything after : is actually a path,
so default PHP parse_url is correct.
RFC even has an example:
> For example, the URI <mailto:fred@example.com>
has a path of "fred@example.com".
It's fairly ugly to just copy-paste the hack
into LinkFilter, but I didn't find an easy and
elegant way to rewrite it without making any
changes to the link indexes values stored in the DB.
See https://datatracker.ietf.org/doc/html/rfc3986
Co-Authored-by: 沈澄心 <dringsim@qq.com>
Change-Id: I3dd04495db9c7a66f62c3914c0eff06754b7d560
Currently, if the query is *.wikipedia.org, it still makes an exact
match to only wikipedia.org and not any of the subdomains.
Bug: T326251
Change-Id: Ib372c35220a89ad9cd4d9879f4436ed153a830c7
This is not providing much value and on top of that it makes using the
el_to_domain_index_to_path index possible by turning like into exact
match.
Bug: T326251
Change-Id: Icace8725ab8b19e78072ed45f306ccf4ef90e2eb
Clean up doc blocks. Remove redundant file-level description and
ensure the description and any ingroup are on the class block.
Ref https://gerrit.wikimedia.org/r/q/owner:Krinkle+message:ingroup
Remove mention of outdated `el_index` field and instead describe
the purpose more generally. The internal column names should mostly
not matter to the callers anyway.
Follows-up I123662f40f6efb, mostly pre-existing issues except for
the duplicate `'protocol'` default being specified in two places
which this patch improves upon.
Change-Id: Ief9b733377ce4611881b15b7faeedc5ee13916ae
Now that el_to_domain is much smaller and indexed, this shouldn't be
taxing on the database anymore.
It's not perfect but it works beautifully.
Bug: T14810
Change-Id: I123662f40f6efbfd24f280984cd824ced6892840
Fixed tests and such. It's not the prettiest patch I have ever written
but I'm planning to refactor the whole class once we are done with the
data migration.
Bug: T337149
Change-Id: I3303a063455cf444b78f4d5832d6bf243b290556
This can be useful to get https://foo.com out of proto-relative one or
add trailing / to end of URLs without one, etc. So we could compare
content of externallinks with the URLs provided.
Bug: T337149
Change-Id: I921728974cde0a095fb3034fc80f7f4bb046f380
It's one-class namespace and I know it's not great but:
- I hope to add more classes with the redesign of externallinks table
- It's not named very well either, it's a collection of URL-related
functionalities
- Making it clear LinkFilter is about external links, not internal or
interwiki or templatelinks etc.
Bug: T321882
Change-Id: I0dd530237f45e4fec786178ec03ee941c6bcd982