Commit graph

309 commits

Author SHA1 Message Date
Umherirrender
769bdbf091 docs: Fix nullable documentation for class properties
Change-Id: I6d0577124d852103f485ffdc819876a13f6641c3
2021-09-24 00:54:53 +00:00
Petr Pchelko
5afc62f258 Remove stub threshold feature
Bug: T284917
Change-Id: I5c9ea04a9deca136bb7210f07200d18f97fd6686
2021-09-13 09:26:38 -07:00
jenkins-bot
fe175a9d28 Merge "Use LinkRendererFactory in ContributionsLookup service" 2021-09-10 17:49:32 +00:00
Umherirrender
44fd53fee3 Using @return never documentation on always-throw-function
This helps phan to detect unreachable code and also impossible types
after the functions.
It helps phan to avoid false positives for array keys
when the keys are checked before

Bug: T240141
Change-Id: I895f70e82b3053a46cd44135b15437e6f82a07b2
2021-09-07 17:29:03 +02:00
Umherirrender
07b499fbcf build: Update mediawiki/mediawiki-phan-config to 0.11.0
Addition and remove of suppression needs to be done with the version
update.

Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
2021-09-07 17:19:05 +02:00
jenkins-bot
1e76c7bfb0 Merge "Remove unneeded variable assignment" 2021-09-04 23:48:21 +00:00
Umherirrender
2e4ee47c3d Cleanup mixed space/tab line indent
Change-Id: I833052a656b1ce419c0929f6f0514f2a33c2c4cc
2021-09-04 00:52:31 +02:00
Umherirrender
032b03dc7a Remove unneeded variable assignment
The variable already has the value

Change-Id: I75f25cc944e30d91a65e1d2bb0abce7d671b19b8
2021-09-03 22:51:22 +00:00
James D. Forrester
8a659ca2fe ILoadBalancer/ILBFactory: Rename hasOrMadeRecentMasterChanges to hasOrMadeRecentPrimaryChanges
Bug: T282894
Change-Id: I1d6130bcd09019f9e2de2974878902c7aafe8f0a
2021-09-02 16:34:44 -07:00
Umherirrender
4d42b5e86e docs: Change wording master to primary in comments and log text
Bug: T254646
Change-Id: I5379dc79be60c99f0a30f74e5d624f81fe6f921b
2021-09-01 23:04:40 +02:00
jenkins-bot
e2bcd5b878 Merge "Add typehints to several methods" 2021-08-31 16:50:57 +00:00
Daimona Eaytoy
9cca05a8e8 Add typehints to several methods
These not only make the code more robust, but also help a lot when
writing unit tests: if a method is return-typehinted and its class is
mocked, the mock method will automatically return a mock of its declared
return type. Otherwise it will return null, and developers are forced to
manually mock the method if the return value is used by the SUT in a way
that doesn't accept null.

Depends-On: I628fcb1807133390c7b9b47984f512f5b1ae58d0
Depends-On: I7080bc505f5838b2f51a368da562104e206063b0
Change-Id: I59068cfed10aabf6c6002f9e9312a6ef6e7e9441
2021-08-31 16:19:13 +00:00
jenkins-bot
56bfbb2d1c Merge "Make RevisionAccessException normalized" 2021-08-31 09:42:47 +00:00
Umherirrender
c234eb1be1 Use LinkRendererFactory in ContributionsLookup service
Avoid use of global user from LinkRenderer service

Change-Id: Iad28931bf3524730662f112f2dbc7666d1d049d5
2021-08-26 21:02:20 +02:00
Tim Starling
ba5c3039ce Reduce Special:Contributions query count
ContribsPager was doing an actor table query from User::load() for
every row. Instead pass a UserIdentity to the constructor which can
cache the user ID. Most callers already had a UserIdentity with the
data already cached.

There are some weird kinds of targets which are not really users, but
UserIdentity was constructed unconditionally already, so I'm not
changing that. I did allow the target option to still be used in case
there is any future problem with round tripping strings through
UserIdentity.

Add integration tests.

Change-Id: Ifd05103fa648d0778ef5185fc73128d38d5fce74
2021-08-25 16:19:10 +10:00
TChin
ef908318e1 DeletedContribsPager row filtering with RevisionStore::isRevisionRow
A continuation of Id0316886d770cd905897d515b3eb658a5875bd80

Bug: T289014
Change-Id: I55f27190e8a292011c15f71b33efbbb6ecf8af0f
2021-08-18 15:18:24 -04:00
Tim Starling
088a313fec ContribsPager row filtering with RevisionStore::isRevisionRow
Flow hooks into ContribsPager, causing formatRow() to be called with
FormatterRow objects instead of stdClass objects. formatRow() is
expected to silently decline to format such objects, leaving formatting
up to a subsequent hook.

Instead of calling newRevisionFromRow with all warnings suppressed and
all exceptions caught, provide isRevisionRow() which determines whether
the row is valid. Thus, unexpected exceptions will be visible and the
code does not depend on details of how newRevisionFromRow() validates
its arguments.

Bug: T288563
Change-Id: Id0316886d770cd905897d515b3eb658a5875bd80
2021-08-10 17:59:30 -07:00
TChin
077b9af960 Replace Assert::parameterType with typehints
Bug: T287530
Change-Id: I6060e194339614b53e3a9c036ff3a3ac2e68f8df
2021-08-03 10:03:48 -04:00
jenkins-bot
03cdd6af12 Merge "Narrow PageUpdater dependency from Title" 2021-07-27 21:38:53 +00:00
Petr Pchelko
12997e1f14 Narrow PageUpdater dependency from Title
Note: this contains a b/c incompatible change to
SlotRoleHandler, but it's never used in any extensions
and never was used.

Change-Id: I898ab18467f7f8c605a579cc6236859b9d86c7f5
2021-07-26 19:45:11 -07:00
Petr Pchelko
3158ba5dfb Move EditResultBuilder::findIdenticalRevision to RevStore
Additionally it switches the query from DB_PRIMARY to DB_REPLICA.
I understand the idea with a quick revert, but I do not think
it can be that quick - to revert a newest revision of a page,
an editor or a bot needs to actually read it first, and reads
come from a replica. So we know at least some replicas already
had the latest revision showing to the user. Very likely by the
time revert is made, we'd have it in all replicas. If not - oh well,
we can't be perfect. But we shouldn't really do such a query on
primary - it's too heavy.

Change-Id: I2fae8dbe5f19635f4d99e26242e3b08ddad8f8af
2021-07-25 07:36:31 -07:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
daniel
0ddc69fc5b Add sanity check to newRevisionFromRowAndSlots.
This avoids a TypeError in case $page is null for some reason.

Bug: T286877
Change-Id: Ib182e70c2690386e07d2d676fb3a60724108ca3d
2021-07-19 13:56:42 +02:00
Petr Pchelko
005160df54 Make RevisionAccessException normalized
Change-Id: I92d2418d728473d3d13719bc6e6112ab55bb797f
2021-07-15 21:49:17 -07:00
James D. Forrester
719cf161f2 More master -> primary documentation and internal var renaming
Bug: T254646
Change-Id: I63cc8895033714bdfbf09aee933a8f0a43b387f3
2021-07-15 11:20:20 +01:00
Reedy
180a45aca7 Fix who's typo
Change-Id: I91564b6cbfc655108ad1f6fba8753b94582ea43b
2021-07-15 01:06:40 +01:00
Petr Pchelko
d6b3cd1a12 Remove hard-deprecated methods from RevisionStore
Bug: T274209
Change-Id: I1cdc9f2d4445cd5a32d90e9bbbfe16c65f1167ff
2021-06-24 12:42:49 -07:00
DannyS712
47d70dbfba Post Revision-removal cleanup
Updates for the removal of the Revision class itself
and the various methods/hooks/variables removed in the
process, including:

- Update some documentation removing most references
to the Revision class and updating the MCR migration
notes to reflect the past tense for Revision methods.

- Change some capitalization from "Revision" to "revision"
to make it clear comments are about revisions in general,
not the Revision class in particular.

- Minor code tweaks including removing unused variables that
were around for the old hooks that were removed, and
removing the use of DeprecatablePropertyArray where no
longer needed for anything.

- Fix incorrect documentation for PageUpdater::getStatus(),
the status value changed a while ago to have revision-record
in addition to revision, and recently to only have the
revision-record, but ironically PageUpdater was never updated.

- Removed Parser::$mRevisionObject, used to be a Revision object
and was deprecated in 1.35, missed earlier because it was no
longer being set to Revision objects, always null.

- Add RevisionRecord typehints in DummyLinker to match those
in the corresponding Linker methods

This should be a no-op in terms of functionality.

Bug: T247143
Change-Id: I03bbb94fc29085855448780b1a5ad9063911ecc4
2021-06-24 00:32:39 +00:00
Petr Pchelko
f312a6bfe8 Make RevisionStore::getKnownCurrentRevision work for foreign wikis
Bug: T274067
Change-Id: Ia4efa113b4f3dda5a0ed77a8acd2276fc8c3b13c
2021-06-21 07:31:35 -07:00
Thiemo Kreuz
2ba01c7ee7 Remove some more comments that literally repeat the code
… including PHPDoc tags like `@return <type> $variableName`.
A return value doesn't have a variable name. I can see that
some people do this intentionally, repeating the variable
name that was used in the final `return $var;` at the end
of a method. This can indeed be helpful. I leave a lot of
these untouched and removed them only when it's obviously
wrong, or does not provide any additional information in
addition to what the code already says.

Change-Id: Ia18cd9f25ef658b08ad25b97a744897e2a8deffc
2021-06-18 21:23:56 +00:00
jenkins-bot
96c6af6878 Merge "Use null coalecing operators everywhere consistenctly." 2021-06-04 15:31:52 +00:00
Petr Pchelko
0dfa846653 Use null coalecing operators everywhere consistenctly.
Auto-generated with rector.

Change-Id: I4f27e10cf029bb067b7bc57d82f7a64e21ea8d42
2021-06-03 21:42:06 -07:00
daniel
bf3951c91b Use getArchiveQueryInfo in DeletedContribsPager.
Bug: T282844
Change-Id: I32b7462f444f24dd3171cb3a6ecff97f68379313
2021-06-02 20:42:11 +00:00
DannyS712
c80841f58b Remove comments that repeat the code
Don't provide any addition information

Change-Id: I4f474537056e34bac74b0d0cd5b4beb800664f90
2021-06-02 08:03:09 +00:00
daniel
f47e5ba389 Add getQueryInfo to RevisionFactory
RevisionFactory is typically used when selecting from the revisions or
archive table, and then constructing RevisionRecords from the resulting
rows. Since RevisionFactory expects certain fields to be present in the
row, it makes sense to have the getQueryInfo methods that define these
lists exposed via the same interface as well.

Bug: T282844
Change-Id: I16908a4fcbdf72d4b765614d628bee5c6ce278eb
2021-05-21 00:08:38 +00:00
James D. Forrester
f2f9345e39 Replace uses of DB_MASTER with DB_PRIMARY in documentation and local variables
This is just a start.

Bug: T254646
Change-Id: I9213aad4660e27afe7ff9e5d2e730cbf03911068
2021-05-14 12:40:34 -07:00
Tim Starling
d0a30ef04f Revert "Add assertions about page IDs during undeletion."
Completely breaks Special:DeletedContributions.

This reverts commit b019b9ee24.

Bug: T282844
Change-Id: If2dc77a12407307f83bb1f92b67d914efff95ae8
2021-05-14 11:59:23 +10:00
Petr Pchelko
695e61ce14 Clean up hard deprecated Title methods
Depends-On: If27bb6b5142d09bc9293d080e97b6642462219f4
Change-Id: I37f012e53d1c881292a19aac87eb107636c6bfbe
2021-05-11 07:41:18 -07:00
daniel
b019b9ee24 Add assertions about page IDs during undeletion.
The additional assertions should help with identifying the cause
of T271644

Bug: T271644
Change-Id: Ic75069545f45ebc2eb09909f68581bc8429a929c
2021-05-10 15:14:53 -04:00
DannyS712
7bd7d2a6c1 Remove hooks that use Revision objects
All hooks were previously hard deprecated
in 1.35. Affected hooks:
* ArticleRevisionUndeleted - use RevisionUndeleted
* ArticleRollbackComplete - use RollbackComplete
* DiffRevisionTools - use DiffTools
* DiffViewHeader - use DifferenceEngineViewHeader
* HistoryRevisionTools - use HistoryTools
* NewRevisionFromEditComplete - use RevisionFromEditComplete
* PageContentInsertComplete - use PageSaveComplete
* PageContentSaveComplete - use PageSaveComplete
* ParserFetchTemplate - use BeforeParserFetchTemplateRevisionRecord
* RevisionInsertComplete - use RevisionRecordInserted
* TitleMoveComplete - use PageMoveComplete
* TitleMoveCompleting - use PageMoveCompleting
* UndeleteShowRevision - no replacement

Includes a fix for setting the associated rev id
of page protections, which previously was only done
using $nullRevision which was a Revision object created
if any hooks needed it; those hooks were hard deprecated
and so for WMF prod the rev id was not being set.

Bug: T247143
Depends-On: Idfa345193ae99fb2f1c9a8f8d28d8d540a6e3d62
Change-Id: I519167f76a5a3c1f5410415b2721462a3dcc3ec8
2021-04-30 17:28:20 +00:00
jenkins-bot
23d5d441c9 Merge "Replace uses of DB_MASTER with DB_PRIMARY" 2021-04-29 19:04:17 +00:00
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
daniel
46e877d182 RevisionStore: don't die on mismatching Titles
When we find that a revision we loaded doesn't belong to the expected
title, log the error and continue, instead of failing hard.

This could happen if a caller to e.g. getRevisionById supplied a Title that is
plain wrong. In this case, we should ideally throw an IllegalArgumentException.
However, it is more likely that we encountered a race condition during a page
move (T268910, T279832) or database corruption (T263340). That situation
should not be ignored, but we can allow the request to continue in a reasonable
manner without breaking things for the user.

Note that this patch does not resolve the mentioend bugs. It only
reduces impact for users. We still need to find out when and why we are
gettign mismatching titles.

Bug: T259022
Bug: T268910
Bug: T263340
Bug: T279832
Change-Id: Ia64ad3b8a6e3c3348bc0a276d528ead127c6b0e0
2021-04-28 11:23:15 +02:00
Tim Starling
419dde00f5 Stop using legacy ActorMigration field "ar_user"
Bug: T278917
Change-Id: Ib6bdb727d58a1732448a2034732269f2f125be7e
2021-04-20 12:44:29 +10:00
jenkins-bot
37ab31298c Merge "Remove $actor field from UsererIdentityValue" 2021-04-14 14:40:12 +00:00
daniel
fed7f0b179 Remove $actor field from UsererIdentityValue
Code that needs to store an actor ID in the database to
represent a UserIdentity, or needs to construct a UserIdentity based on
an actor ID loaded from the database, should use the ActorNormalization
service.

Note: The getActorId() method is removed from the UserIdentity interface,
but all concrete classes continue to support it for now.
UsererIdentityValue::getActorId() is hard deprecated and should
be removed in 1.37. It always returns 0.
User::getActorId() is not deprecated at this point.

Bug: T274179
Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237
Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1
2021-04-13 18:18:06 +00:00
jenkins-bot
2f7456c731 Merge "Use PageStore in RevisionStore" 2021-04-05 19:54:40 +00:00
daniel
fe9430947d Use PageStore in RevisionStore
This introduces PageStoreFactory as well.

Change-Id: I7abd3c6a8ea70a68e8f8e9460d3bdd8c6f45338a
2021-04-05 20:58:54 +02:00
jenkins-bot
22570181d4 Merge "RevisionStoreRecord: Use MWTimestamp::getTimestamp for detailed errors" 2021-04-01 02:06:38 +00:00
jenkins-bot
f7d96094f1 Merge "Revert "Re-apply "Deprecate constructing revision with non-proper page""" 2021-03-31 19:45:17 +00:00