Commit graph

154 commits

Author SHA1 Message Date
Umherirrender
2e4ee47c3d Cleanup mixed space/tab line indent
Change-Id: I833052a656b1ce419c0929f6f0514f2a33c2c4cc
2021-09-04 00:52:31 +02: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
56bfbb2d1c Merge "Make RevisionAccessException normalized" 2021-08-31 09:42:47 +00: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
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
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
Petr Pchelko
0dfa846653 Use null coalecing operators everywhere consistenctly.
Auto-generated with rector.

Change-Id: I4f27e10cf029bb067b7bc57d82f7a64e21ea8d42
2021-06-03 21:42:06 -07: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
Petr Pchelko
695e61ce14 Clean up hard deprecated Title methods
Depends-On: If27bb6b5142d09bc9293d080e97b6642462219f4
Change-Id: I37f012e53d1c881292a19aac87eb107636c6bfbe
2021-05-11 07:41:18 -07: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
daniel
fe9430947d Use PageStore in RevisionStore
This introduces PageStoreFactory as well.

Change-Id: I7abd3c6a8ea70a68e8f8e9460d3bdd8c6f45338a
2021-04-05 20:58:54 +02:00
jenkins-bot
bda0196304 Merge "Add support for derived MCR slots" 2021-03-18 20:55:17 +00:00
Cindy Cicalese
29862dd51d Add support for derived MCR slots
Bug: T277203
Change-Id: I1c70abc00c912b283e3e6eb2266633ae3f57673b
2021-03-18 15:34:46 -04:00
daniel
afa236ef53 RevisionStore: getRevisionbyId should take a PageIdentity
Providing a PageIdentity to getRevisionById removes the need
to look up page related data, and to construct a Title.

Bug: T275531
Bug: T273284
Depends-On: I8d0dc30ecd0c0c65c337170d271c2e2531914686
Change-Id: I683362ccd669acf2aadf56853afeb1ca6dee6f8c
2021-03-17 13:46:41 +00:00
daniel
ed7e42e42e RevisionStore: create getPage, deprecate getTitle
The new getPage() handles cross-wiki access correctly. It's not a direct
replacement for getTitle(), since it is private.

getTitle() cannot work properly for RevisionStore instances connected to
a sister-wiki. It was already discouraged, and is nearly unused outside
of RevisionStore. Remainign usages should be replaced with
RevisionRecord::getPage().

Note that PageIdentityValue is not lazy loading, while Title is.
Code in newRevisionFromRowAndSlots() was adjusted to take advantage of
any fields from the page table that may already be present from a join,
to avoid an additional query to the page table.

Bug: T275531
Bug: T273284
Change-Id: If4525d76a578b92dbcfe1f5150028f7a28811119
2021-03-17 10:53:40 +00:00
daniel
806792281f ActorNormalization should require a DB connection.
ActorNormalization should only be used in contexts where a DB connection
is already being used, or at least easily available.

Bug: T276986
Change-Id: Ie8aadaffa4a30e63fcad0502d45b8ec364fc79ef
2021-03-10 21:43:49 +01:00
Petr Pchelko
1abe2e5318 Remove ActorStore::getUserIdentityByAnyId.
Adding this method was a mistake, there's no good use
for is really.

Change-Id: I0b2ecee7420573092f85f4e19da731a6bd56c50b
2021-03-01 17:41:42 -07:00
daniel
74723d21cc Don't use getUserId in RevisionStore.
We are in the process of moving from getUserId() to getId() anyway. That
should resolve the issue in addWiki for now. It will however break again
in the future, when we requrie a matching wikiId in User::getId().

The real fix would be resolving T200471.

Bug: T275452
Change-Id: I9a7c383a6c31929e25899fd627131afc25584d5b
2021-02-23 16:19:35 +01: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
jenkins-bot
c6161a7aaa Merge "Make RevisionStore to pass $wikiId to RevisionRecord's methods." 2021-02-10 23:24:24 +00:00
Peter Ovchyn
0cacd9cd5b Make RevisionStore to pass $wikiId to RevisionRecord's methods.
Bug: T273284
Change-Id: I516afe659fe8d9b4fd77c3671c248f094c1f0690
2021-02-11 00:19:11 +02:00
Petr Pchelko
4d8dc6b992 Use ActorStore in RevisionStore
Bug: T273290
Change-Id: Iff9b67455d337ea03cb728dd570c4ce760c39e49
2021-02-10 14:37:54 -06:00
Peter Ovchyn
8a06301738 Update RevisionStore public interface to be using PageIdentity
The following methods have beed converted:
::getRevisionByTitle
::getRevisionByTimestamp
::newRevisionFromArchiveRow
::newRevisionsFromBatch
::getKnownCurrentRevision
::getFirstRevision
Appropriate tests were adjusted to test both old interface (with
Title) and new interface (with PageIdentityValue)

Bug: T272886
Change-Id: Ica8da21d2413df885365475eaa498214edbcfd1d
2021-02-08 18:33:25 +02:00
Peter Ovchyn
b171edc200 Remove mentions of dbDomain from RevisionStore, RevisionRecord
In this patch I replaced RevisionStore::$dbDomain to
RevisionStore::$wikiId, RevisionRecord::$mWiki to
RevisionRecord::$wikiId and changed all hierarchies
and tests accordingly

Bug: T272901
Change-Id: I439515cfb6aa8a8697c2a5a0458ec8925522363a
2021-02-05 22:42:40 +02:00
Peter Ovchyn
e7e0db5b34 Hard deprecate RevisionStore::newMutableRevisionFromArray
Bug: T272560
Depends-On: I171537c3346a7dd4aeb4fc612d7dd9fba5d64679
Change-Id: If8d079a5d0e9bc9103cf4a6893a9c961d2728534
2021-02-03 22:29:44 +00:00
Petr Pchelko
d62ecb7b5f Make RevisionStore use PageIdentity where easy
Change-Id: I41b71dd4bffc642e28fd22202d80ef73429414cb
2021-02-01 12:29:25 -06:00
vladshapik
117982da96 RevisionRecord: make RevisionRecord::getId() take a wiki ID
Bug: T272485
Change-Id: Ic1a8a406c2163844b14aa34ab259f0836687887e
2021-01-29 15:01:31 +02:00
jenkins-bot
0fed44f70a Merge "RevisionStore: better exception when rev belongs to wrong page" 2021-01-27 21:41:52 +00:00
Petr Pchelko
1fb76fefbb Change RevisionStoreCacheRecord callback signature
In order to convert the tests into tru unit tests.

Bug: T272669
Change-Id: I6055b43381fdcc6dcdf69e9311979db0dccdb16b
2021-01-26 15:14:35 +00:00
daniel
b02b0d55a3 RevisionStore: better exception when rev belongs to wrong page
When a revision row does not belong to the page we expected it to belogn
to, throw RevisionAccessException instead of IllegalArgumentException,
since this situation generally indicates data corruption rather than a
coding error.

Bug: T263340
Change-Id: Ib48f92e0cb2ef26b4f73e94d82f907cefdffcd94
2021-01-26 12:58:12 +01:00
jenkins-bot
329b4cc6a7 Merge "RevisionStore: Prevent useless DB query" 2021-01-22 07:43:24 +00:00
Ammarpad
85a042cc10 RevisionStore: Prevent useless DB query
Ideally typehinting $id would be more effective, but a lot of
callers are just passing RevisionRecord::getId() directly which
is documented to return int|null. Typehinting the param here would
require first fixing those callers to ensure they are passing the
required int.

For now this patch will prevent the useless query, in case the
RevisionRecord::getId() call do return null where it's used as an
argument for this method. A case for <= 0 is also checked, while
not strictly necessary, it will also lead to useless query if such
value ever reaches here for whatever reason.

Bug: T270149
Change-Id: I5c23955e29efed4bec4c2e9652af1c2c3bf79218
2021-01-22 05:19:43 +01:00
Petr Pchelko
b6793aafb4 Migrate RevisionStore from User to Authority where possible
Change-Id: I9034d707a5abfca61343bf431d0c95e28b3f9358
2021-01-21 21:51:37 +00:00
Petr Pchelko
16fab630f7 Remove hard-deprecate param fallbacks in RevisionStore
Change-Id: I5808a9a5d25ed2ea85ee45ed631522d0ec0770a1
2021-01-21 08:13:36 -06:00
Umherirrender
ba15428253 Change object to stdClass type hints in revision related classes
Change-Id: If8fe228512abbc974369b3c10ebe9063cf136cfb
2020-11-17 22:07:29 +01:00