Commit graph

87 commits

Author SHA1 Message Date
James D. Forrester
8e940c4f21 Standardise all our class alias deprecation comments for ease of grepping
Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
2024-03-19 20:11:29 +00:00
James D. Forrester
35b2542895 Namespace includes/cache
Bug: T353458
Change-Id: Ic3f3168ef17113f5fb3ec11e0a47f52d65eefba9
2024-02-20 10:28:03 -05:00
James D. Forrester
b16be7a36c Namespace TitleFormatter under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: Ic2d59eb6764b1a273ed7162ecabf641f638b8f66
2023-09-19 05:17:18 +00:00
James D. Forrester
94ece673b2 Namespace TitleValue under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: I4c901d5c32696d8334ec30cede7d9b6f3d8d645e
2023-09-18 18:24:39 +01:00
thiemowmde
e18d363203 Remove duplicate array_keys() from GenderCache::doLinkBatch
What this piece of code does: Collect the page names (without a
namespace) from all namespaces that support a gender discinction.
These are usually the User: and User_talk: namespaces.

In other words: No matter if the input contains "User:Foo" or
"User_talk:Foo" or both, we want the output to contain the user name
"Foo" a single time.

We can just combine the incoming per-namespace arrays with + or
array_merge (doesn't make a difference here, but + is actually a lot
faster).

Change-Id: Ia616d3c3db509c4a02ef6806321ef8ae39ede640
2023-07-03 17:31:51 +00:00
jenkins-bot
dbf8f8d12c Merge "Merge sequences of if that end doing the same thing anyway" 2023-06-17 23:34:51 +00:00
thiemowmde
9b03cde58e Merge sequences of if that end doing the same thing anyway
Motivation:
* Avoid code duplication.
* Hopefully make it easier to read.
* Also order stuff from cheap to expensive, if possible.

Change-Id: I575e3f2027ce60a0d0885be5b9bd3e07bc035eee
2023-06-16 16:09:42 +02:00
Timo Tijhof
8207004738 LinkBatch: Re-apply makeWhereFrom2d/constructSet exception
Follows-up Ifdf3ea54 (678326e6fb) and its
partial revert I665c3a6e8 (d48115b2bf).

Bug: T336964
Bug: T336980
Change-Id: Ia5d8f652d6d1522543ebb8338e68f5ccd8742dac
2023-06-15 21:30:07 +00:00
Umherirrender
d48115b2bf cache: Do not throw on empty set in LinkBatch::constructSet
IDatabase::makeWhereFrom2d no longer returns false (it throws),
so do the check in the calling code and return false

Bug: T336964
Follow-Up: Ifdf3ea54271ea856f2f555a5e087b8f521e348b3
Change-Id: I665c3a6e8d8623ace6a5df4e110527db2f546b30
2023-05-18 21:32:05 +02:00
Amir Sarabadani
d44c45c76a watcheditem: Switch out of LB for picking db connection
A bit of a clean up. Switching out of lbFactory to ICP is not possible
at the moment because there is $this->lbFactory->getLocalDomainID()
for cache prefix. Fixable later.

Bug: T330641
Change-Id: I2d4537f75f5877552c6d9fd2b76c5be1959ea400
2023-05-05 15:42:10 +02:00
Umherirrender
19488997a2 Remove fallback to MediaWikiServices in LinkBatch::__construct
Bug: T325591
Change-Id: I52fe37b4c6d7b7d4ba7ccbc362413a996161156b
2023-04-19 23:52:49 +02:00
Umherirrender
9e0c40424c Hard-deprecate manual construction of LinkBatch objects
Bug: T325591
Change-Id: I4f267b052e98cbb36cb76dae59a5279b01eae97c
2023-03-08 20:43:01 +01:00
Amir Sarabadani
e8032eb8f7 ResourceLoader: Switch to use select query builder in WikiModule
Bug: T311866
Change-Id: I77d711a10b935680682eb2a91dab635460de3cf6
2023-02-28 17:23:58 +01:00
jenkins-bot
293f8dfba8 Merge "Make use of ??= in more places" 2022-12-21 00:33:46 +00:00
jenkins-bot
28fdbf489c Merge "cache: Migrate queries to SelectQueryBuilder" 2022-12-20 10:09:16 +00:00
DannyS712
5dd2f0e73e LinkBatch: fix comment about deprecation replacement
New instances should be created with LinkBatchFactory's
`newLinkBatch`, there is no `makeLinkBatch` method.

Change-Id: Ib72a33eaf93057fa2fc757813b6a9e3b8ee7989a
2022-12-20 08:01:36 +00:00
Amir Sarabadani
962150af83 cache: Migrate queries to SelectQueryBuilder
In LinkBatch and LinkCache

Bug: T311866
Change-Id: Ic95752af922fd417db700cd9846d5497d48d81f7
2022-12-20 08:59:05 +01:00
DannyS712
c1db64b808 Make use of ??= in more places
New feature from PHP 7.4

Change-Id: Ifa7a9bc7b2ec415ad7ecb23f4c1776f51f58fd6b
2022-12-17 01:10:13 +00:00
Matěj Suchánek
a592d47e91 Clean up redundant array manipulation
PHP does this implicitly.

Change-Id: I009a7c93d44fb5e8c430c971cfc637fa04a8e68d
2022-12-11 12:42:29 +01:00
Umherirrender
ea5ea60b31 Various doc fixes about false on method arguments/return types
Doc-only changes

Change-Id: I5177f582ae7ee70c357e9389fed14819faf79463
2022-11-10 19:23:46 +00:00
Tim Starling
0077c5da15 Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

I used regex replacement.

Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
2022-10-21 15:33:37 +11:00
Alexander Vorwerk
8846700ef0 Stop merging LinkCache select fields with page_title and page_namespace
LinkCache::getSelectFields() includes page_title and page_namespace
since If77c2f9879d7bae71eb59944efd8b3798d16aa46, so we don't need
to add those two specifically.

Change-Id: I8fa9d563af3f9da90fb96369dab0ee5bde860081
2022-07-05 22:28:53 +00:00
jenkins-bot
67361d6f04 Merge "Revision: Log traces as 'exception.trace' instead of 'trace'" 2022-05-13 19:49:18 +00:00
Umherirrender
d79fd02d4b Use injection for LinksMigration on LinkBatch, action, api, special page
Even the service does not long stay in that classes,
it should be injected to avoid global state

Bug: T304780
Change-Id: Ib488037f5a6966ab61042ed3cd889ddc50f1ba8e
2022-05-10 20:19:58 +00:00
Timo Tijhof
8ffee67611 Revision: Log traces as 'exception.trace' instead of 'trace'
Various in RevisionStore did this already, but we forgot a few.

Bug: T233342
Change-Id: Ib678868b239bcd4ff4ae62b2ab47022b5a70e8be
2022-04-13 22:18:50 +00:00
Amir Sarabadani
19e77d4fc9 Add more support for read new in links migration
- In Info action and its API counter part
 - In LinkBatch::constructSet
 - In Title::getLinksFrom

Bug: T304780
Change-Id: I449f041986acdd16feecac818e3579987b4b11be
2022-04-12 02:22:17 +02:00
Reedy
11cc2d6993 Consistently use @deprecated since rather @deprecated
Change-Id: I301786f35cd6eb9c63fb72e0b64cffa9efd7b86b
2022-03-06 02:55:54 +00:00
Gergő Tisza
6a7bffaac2
LinkBatch::getPageIdentities(): Fix return type
LinkBatch::getPageIdentities() returns PageIdentityValues, which
are ProperPageIdentities. Indicate this in the return type
documentation to avoid phan complaints.

Change-Id: I461f2964aa9b4178d41e6071763e016b207c77d5
2022-02-19 10:09:57 -08:00
Tim Starling
16979ecf29 Fix pollution of LinkBatch/LinkCache with interwiki link
* In LinkBatch::addObj(), reject interwiki links with a warning.
  Otherwise the link is added to the batch by ns/title and later
  reconstructed as if it were a local link without an interwiki
  prefix.
* In CommentParser, treat interwiki links as always good, don't defer
  the existence check.
* In LinkBatch, inject a LoggerInstance instead of calling LoggerFactory
  in four places.
* Add a regression test, and some general tests for known links.

Bug: T300311
Change-Id: I0e5825eb48a6ba2932aea69a4d0fff3439c50ff5
2022-01-28 10:52:38 +11:00
Reedy
cbfd94c355 LinkBatch/LinkBatchFactory: Minor cleanup
Change-Id: Ieb9219383d343c37876566f9de98fe873b85b543
2021-11-19 18:26:52 +00:00
daniel
316053ed88 LinkBatch: skip bad input
LinkBatch used to be lenient about receiving null or invalid titles.
This patch restores this lenient behavior.

Bug: T282180
Bug: T282070
Change-Id: I2c6378a3a0d508c77bcb290a6ed07f4d5f96d62c
2021-05-07 16:22:24 +02:00
daniel
c829bfc8dd LinkBatch: replace Title with PageReference in method signatures
Bug: T278459
Change-Id: I7ed97f868f2a8a505ca4e529036d7efce6eea3ae
2021-04-26 19:54:24 +02:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
Ammarpad
beeccf8520 LinkBatch: Fix property documentations
* Remove incorrect null type from documentation of properties
that cannot be null.
* Add type doc for $caller and $data

Change-Id: I8d51dca7fd4910acf744361279c441fe4c3a4307
2021-01-22 07:41:07 +01:00
jenkins-bot
e6a6592ecf Merge "Fix some unit tests accessing MediaWikiServices" 2020-11-17 18:36:37 +00:00
Daimona Eaytoy
95e17ee645 Fix some unit tests accessing MediaWikiServices
These are mostly easy fixes. Tests were fixed when that didn't require
any change to the tested code, and moved to /integration otherwise.

MediaWikiUnitTestCase::setTemporaryHook was removed: the
caller should provide a HookContainer, at which point it would just
become a useless wrapper around HookContainer::register. (We don't
really need it to be temporary, if proper DI is used).
The method was only used in the tests touched by this commit.

Change-Id: I2aba02560c41b77eea9dd4bff0e4d1c4bb0da9a2
2020-11-12 19:13:47 +00:00
Thiemo Kreuz
b0130ca649 Update a lot of unspecific "array" types in PHPDocs
This includes fixing some mistakes, as well as removing
redundant text that doesn't add new information, either because
it literally repeats what the code already says, or is actually
duplicated.

Change-Id: I3a8dd8ce57192deda8916cc444c87d7ab1a36515
2020-10-28 11:01:33 +01:00
Umherirrender
8bca04ce5b LinkBatch: Include namespace in warning logging
Also avoid undefined $pdbk for invalid titles

Change-Id: I2a6b02c06284704461243ffb4255b6473199dd0a
2020-07-11 13:46:45 +00:00
Tim Starling
47a1619027 Remove terminating line breaks from debug messages
A terminating line break has not been required in wfDebug() since 2014,
however no migration was done. Some of these line breaks found their way
into LoggerInterface::debug() calls, where they mess up the formatting
of the debug log.

So, remove terminating line breaks from wfDebug() and
LoggerInterface::debug() calls.

Also:
* Fix the stripping of leading line breaks from the log header emitted
  by Setup.php. This feature, accidentally broken in 2014, allows
  requests to be distinguished in the log file.
* Avoid using the global variable $self.
* Move the logging of the client IP back to Setup.php. It was moved to
  WebRequest in the hopes that it would not always be needed, however
  $wgRequest->getIP() is now called unconditionally a few lines up in
  Setup.php. This means that it is put in its proper place after the
  "start request" message.
* Wrap the log header code in a closure so that variables like $name do
  not leak into global scope.
* In Linker.php, remove a few instances of an unnecessary second
  parameter to wfDebug().

Change-Id: I96651d3044a95b9d210b51cb8368edc76bebbb9e
2020-06-03 12:01:16 +10:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
mainframe98
297a89069a Add LinkBatchFactory to inject services into LinkBatch
All services required by LinkBatch are now injected by the
LinkBatchFactory. The constructor for LinkBatch has been
soft-deprecated, but the required services are still optional.

Bug: T239855
Depends-On: If49cbb730d4ac48586b891908cf24601efbc5d6a
Change-Id: I93d931ab60305ad49a6e419f8269c77791a3938d
2020-01-06 17:02:31 +01:00
daniel
e98094956a Don't fail hard on bad titles in the database.
This updates some code that has been constructing TitleValue directly
to use TitleValue::tryNew or TitleParser::makeTitleValueSafe.

Bug: T200055
Change-Id: If781fe62213413c8fb847fd9e90f079e2f9ffc9d
2019-11-25 22:15:38 +01:00
Aaron Schulz
1fb1494c93 Use IResultWrapper in code comments instead of ResultWrapper
Change-Id: Idb813c20bef0d41d0f9f01440daab4fee6cdb38d
2019-06-22 17:58:39 +00:00
Umherirrender
e6c5093515 Use IResultWrapper in LinkBatch and BacklinkCache
Change-Id: If96d6dfeea17e73073b78c19526787e788f7b412
2019-06-06 21:56:18 +02: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
Niklas Laxström
cb74e93b44 Make LinkBatch::setCaller chainable
To allow for one-liners such as $lb->setCaller( __METHOD__ )->execute();

Change-Id: I45cd81d9e583f09aacb578ffb87d7c11b0e13d57
2018-08-15 10:57:21 +02: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
Erik Bernhardson
3370b052fc Batch request titles for cdn purge from db
Xenon shows a significant amount of time is spent individually fetching
the content model for titles being purged. It's probably not a huge
improvement but lets fetch them all in one go instead of lazily as
needed.

Change-Id: I71af6f13c84e740c1367617d7a51210501363b33
2017-08-30 18:22:11 +00:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Thiemo Mättig
d14faa6bed Remove auto-generated "Constructor" documentation on constructors
Having such comments is worse than not having them. They add zero
information. But you must read the text to understand there is
nothing you don't already know from the class and the method name.

Change-Id: I994d11e05f202b880390723e148d79c72cca29f0
2017-07-10 10:15:51 +00:00