Commit graph

368 commits

Author SHA1 Message Date
thiemowmde
70aa9c8e35 Make use of ?:, ?? and ??= operators in mostly trivial cases
The motivation is to make the code less confusing. I hope this is the
case.

?? is an older PHP 7.0 feature.
??= was added in PHP 7.4, which we can finally use.

Change-Id: Id807affa52bd1151a74c064623b41d950a389560
2022-12-05 21:37:13 +01:00
Amir Sarabadani
09b18a8f4c Reorg: Move Title-related classes to title/
These three classes:
 - TitleArray
 - TitleArrayFromResult
 - TitleFactory

We need to move these and the rest of files under title/ to Title/ (and
namespace them) but the patch will become way too big given that Title class is
also one of them.

Bug: T321882
Change-Id: Iac1688172ee457348a08a470c86e047571feb8e0
2022-11-26 09:30:32 +00:00
Tim Starling
072dc385e9 Address contravariance todos
Bug: T278139
Change-Id: If451415b8acbc764b8f2b277dc8635dcfc88ff53
2022-11-16 13:05:19 +11:00
jenkins-bot
55eb9810e6 Merge "blobstore: rename confusing $blobKey parameters" 2022-11-15 22:31:31 +00:00
jenkins-bot
47f7896653 Merge "RevisionRenderer: Avoid deprecated ParserOptions::newCanonical()" 2022-11-15 19:11:28 +00:00
Aaron Schulz
b4c879c4e3 blobstore: rename confusing $blobKey parameters
Bug: T309126
Change-Id: Iebd2ff3b323ca79946e4a60c671a42bec379779f
2022-11-14 17:23:20 +00:00
Bartosz Dziewoński
dc2ddec1e0 RevisionRenderer: Avoid deprecated ParserOptions::newCanonical()
Change-Id: I8b2acf091a54ac9c4231764fa00468ac42b116c9
2022-11-14 18:08:13 +01:00
daniel
118d4980b2 Track the reason for rendering.
Allow the causeAction that triggers page rendering to be looped through
to ParserCache, so we can count what causes writes to the cache.

Change-Id: I6ad8e105a3ce457e3ab4f85cd154f47a32085e0d
2022-11-09 09:38:57 +00:00
Timo Tijhof
37f380aac6 Storage: Minor docs and file header cleanup
* Move description and ingroup annotations from PHP file docblock to
  class docblock, where IDEs and Doxygen (and humans!) tend to read it
  from.

  This is in part evidences by the fact that for numerous classes,
  the file docblock was copy-pasted and actually about a different
  class.

  Follows-up Ia3b9b8c22 (page), I301f471f86 (language),
  I216d85c6df (PageEditStash), and others that apply similar doc
  improvements.

* Add missing `@defgroup` for page. Without this, the group is ignored
  and not added in the sidebar at
  <https://doc.wikimedia.org/mediawiki-core/master/php/>

* Clean up the file header, similar to other commits under
  <https://gerrit.wikimedia.org/r/q/message:ingroup+owner:Krinkle>.

Change-Id: I94de8299c184fee8c05b7108448255fcf36f8260
2022-11-04 22:25:46 +00:00
Umherirrender
1b342a8893 Various doc fixes about false and null on method arguments/return types
Doc-only changes

Change-Id: Ice974b3ba41708859dfe646e94b31c5ebbf26410
2022-11-03 18:55:47 +01:00
jenkins-bot
8d785f979d Merge "Use buildComparison() instead of raw SQL in RevisionStore" 2022-11-02 10:12:18 +00:00
Amir Sarabadani
bbe704b5c1 Reorg: Move some of request related classes to MediaWiki/Request
Redoing I5ea70120d74 but without moving WebRequest that caused issues
with phan-taint-plugin.

Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequestUpload

Bug: T321882
Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
2022-10-28 10:15:31 +00:00
Zabe
f6b9381d7f Revert "Reorg: Move some of request related classes to MediaWiki/Request"
This reverts commit 2bdc0b2b72.

Reason for revert: T166010#8349431

Bug: T166010
Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
2022-10-27 13:14:16 +00:00
Amir Sarabadani
2bdc0b2b72 Reorg: Move some of request related classes to MediaWiki/Request
Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequest
 - WebRequestUpload

Bug: T166010
Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
2022-10-26 16:49:10 +02:00
Bartosz Dziewoński
76a8eff722 Use buildComparison() instead of raw SQL in RevisionStore
Bug: T321422
Change-Id: I78dd1623895a74806867ca4c974df100031dbf0e
2022-10-22 02:07:57 +02: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
Umherirrender
5c5498a202 Remove unused key variable from foreach loops
Change-Id: Id2d91e30a6f7cc4eb93427b50efc1c5c77f14b75
2022-09-21 21:18:43 +02:00
Bartosz Dziewoński
ec79aa3943 SQLPlatform: Introduce buildComparison()
Builds a condition comparing multiple values, for use with indexes
that cover multiple fields, common when e.g. paging through results
or doing batch operations. Can also be to generate a simple comparison
without writing raw SQL (see T210206).

Update a few manually constructed conditions to use this method.
There are more maintenance scripts and API classes that use the
same patterns, but this is a start.

As you can see by the code I'm replacing, there are many ways to do
this. I picked the one used by maintenance/TableCleanup.php, since
I found it the easiest to understand.

Change-Id: Ic368a87fb5ce4c13608b03206cd68518ec9732d4
2022-09-10 04:22:19 +02:00
Umherirrender
cbe949410d Improve docs of various ::getQueryInfo functions
Explict types helps phan to detect errors with keys like ef82d95

Change-Id: Iee4d964ecc58273eb9c73356ed34e13f29fbd275
2022-08-13 21:18:44 +02:00
Matěj Suchánek
1865180ae7 Do minor code cleanup
Remove dead code and fix typos. Should cause no change in behavior.

Change-Id: I5d293b842bc93a28b8bcd799a31b5e6e30fe692e
2022-06-24 13:52:42 +02:00
jenkins-bot
6d0023a890 Merge "Simplify assertion for false around wiki id and domain id" 2022-06-18 08:24:47 +00:00
Umherirrender
05a175b439 Simplify assertion for false around wiki id and domain id
false is accepted by Assert::class since 9090085

Change-Id: I243a63dca310a198c6f7a8bc52298c5c95939eb6
2022-06-18 09:49:13 +02:00
Umherirrender
69b6c4983d Pass array to Assert::parameterType when asserting multiple types
Change-Id: I6db78db18b2d8982ce5158f44c03bfdb8d48f97c
2022-06-18 09:34:36 +02:00
jenkins-bot
778494c6bf Merge "Remove deprecated MediaWiki\Storage namespace for revision related class" 2022-05-29 07:09:17 +00:00
Umherirrender
f07295ade1 content: Remove UnknownContent/UnknownContentHandler class alias
Renamed in a67cad6 in 1.36
The fallback content is designed for internal use only

Change-Id: I6977a9cf1eab0e701fd6969b1a2b5d1dfcecfdfa
2022-05-29 06:20:45 +00:00
Umherirrender
a2a1a4ecd2 Remove deprecated MediaWiki\Storage namespace for revision related class
All revision related classes are namespaced MediaWiki\Revision
instead of MediaWiki\Storage since 1.32. The old namespaced
class names are deprecated and only kept for backwards-compatibility.

Bug: T305784
Change-Id: I48cdc65301a8cd20d2bedd031dbdae33b8c2a34d
2022-05-29 06:17:01 +00:00
Umherirrender
68461b259f RevisionStore: Cast revid to int from db result
Each field of a database result is a string,
the revid is known integer and also used on further database query,
where a int looks better when looking at the sql

Change-Id: I5557ff7d0f01cf569b2983b09ac715447d3e65a1
2022-05-24 21:10:22 +02:00
jenkins-bot
40abc7d834 Merge "Use User::isRegistered for readability instead of ::getId falsy check" 2022-05-23 04:06:10 +00:00
jenkins-bot
67361d6f04 Merge "Revision: Log traces as 'exception.trace' instead of 'trace'" 2022-05-13 19:49:18 +00:00
Matěj Suchánek
e47c441078 Fix many typos in comments
Found using IntelliJ's "Typo" code inspection.

Change-Id: I746220ebe6e1e39f6cb503390ec9053e6518cf16
2022-05-10 12:46:11 +00:00
Matthias Mullie
2a25d90807 Remove duplicate contentRenderer assignment
AFAICT, this is a rebase artefact. See
https://gerrit.wikimedia.org/r/c/mediawiki/core/+/730808/11#message-6c552144fd4a0194942b268a441e050fa865ec96

Change-Id: I3a32335f3ad0792a9bb9eedf28dab821a04c65ec
2022-05-09 09:26:14 +02:00
Umherirrender
49ad716948 Use User::isRegistered for readability instead of ::getId falsy check
Change-Id: I42aab149559e3e899cde6c77af76c66936ed0ef0
2022-04-29 21:15:57 +02: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
jenkins-bot
ffe375bc27 Merge "RevisionStore::getRelativeRevision: use the supplied timestamp, if any" 2022-03-22 23:01:04 +00:00
Umherirrender
1f71eccf63 phan: Disable null_casts_as_any_type setting
Make phan stricter about null types by setting null_casts_as_any_type to
false (the default in mediawiki-phan-config)
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T242536
Bug: T301991
Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
2022-03-21 18:25:07 +00:00
Tim Starling
dde7141481 RevisionStore::getRelativeRevision: use the supplied timestamp, if any
Optimise RevisionStore::getRelativeRevision() by using the timestamp
from RevisionRecord::getTimestamp(), if it is non-null, instead of
getTimestampFromId(), which always requires a DB query.

Change-Id: Ibf0ab45ddfebbf6f188d3630610946c3c7376f9f
2022-03-18 16:52:16 +11:00
Umherirrender
53e31e63d8 RevisionStore: Inline one-use condition in ::getPage
Helps phan to understand the not-null part of the conditions

Change-Id: Icd9c3d99a18d55de4abcca73be9665b568739884
2022-02-18 22:14:59 +01:00
Siddharth VP
38295f9226 Fix typos in comments (N-R)
Change-Id: I2d1bdb7531ff5126114a391550c2615ea6e244b3
2022-01-09 23:14:44 +05:30
Amir Sarabadani
a0138ce2c6 Revision: Inject local cache to RevisionStore
Follow up to I630603eaffcae3700b2843fb97c5bedf8d29da9e

Bug: T297147
Change-Id: Ie3a7c345671d7d4f37978e513dd69bfe546d6c33
2021-12-17 19:23:19 +01:00
Amir Sarabadani
98abda8044 Revision: Bypass checking the cache if it's not found
It must call the db function, not the one that goes through cache.

Follow up to I630603eaffcae3

Change-Id: I1e8c94df6cb008091dee674b8101f0b59bf2263c
2021-12-16 19:21:36 +01:00
jenkins-bot
2d7a86b365 Merge "Revision: Add two caching layers to loadSlotRecords for template pages" 2021-12-16 14:47:32 +00:00
Amir Sarabadani
38b8bceff2 Revision: Add two caching layers to loadSlotRecords for template pages
This is currently making a lot of (serial) DB queries during every page
parse. At least one for every transcluded page.

Using Memcached should significantly reduce DB load, and apcu should
notably reduce latency when parsing large articles.

This is currently limited to NS_TEMPLATE to avoid overwhelming caches
with a long tail of unlikely re-used metadata about non-transcluded
pages (every parsed article) and rare non-template transclusions.

Bug: T297147
Change-Id: I630603eaffcae3700b2843fb97c5bedf8d29da9e
2021-12-16 14:21:55 +00:00
Bartosz Dziewoński
10aee72aa8 RevisionStore: Pass $flags in getRelativeRevision()
Change-Id: Ia926d852c14aed76f445f359942649e132058de7
2021-12-10 13:06:47 +01:00
Thiemo Kreuz
0c5802ec4e Use PHP's [ $this, 'fn' ] callback syntax where possible
PHP 8.1 will give us "first class callables" that look like e.g.

 $result = array_map( $this->fn(...), $array );

For now we can use

 $result = array_map( [ $this, 'fn' ], $array );

Change-Id: I7278c80c075d162da73aa45af1b6578310ce0624
2021-12-03 09:08:57 +01:00
jenkins-bot
0aef7a462b Merge "Hard deprecate TitleFactory::newFromIDs and Title::newFromIDs" 2021-11-29 21:28:11 +00:00
TChin
8371b19662 Hard deprecate TitleFactory::newFromIDs and Title::newFromIDs
Bug: T291288
Change-Id: I1789bccc276ec7c01928775f9bcb8ff301af54ff
2021-11-29 14:23:26 -05:00
Majavah
7e3df796b0 Revert "Remove last User dependencies from File"
This reverts commit 73a25838b4.

Reason for revert: T296508

Bug: T296508
Change-Id: I8af37665eeb284b85157a72459d43261ec4829ed
2021-11-26 17:06:36 +00:00
Petr Pchelko
73a25838b4 Remove last User dependencies from File
Change-Id: I953fcc66b5cde1ef481178b08e16c50b8a118702
2021-11-26 05:42:00 +00:00
Reedy
7bf779524a Remove or replace usages of "sanity"
Bug: T254646
Change-Id: I2b120f0b9c9e1dc1a6c216bfefa3f2463efe1001
2021-11-19 23:19:42 +00:00
Matěj Suchánek
b411cbfdaa Split PageArchiveTest
Create ArchivedRevisionLookupTest to test ArchivedRevisionLookup.
Expand tests a bit and add two more for ::getPreviousRevisionRecord.

Change-Id: I3e176b24a13479464b7e73d062639ecb4db86f8f
2021-10-25 10:41:33 +02:00