Commit graph

310 commits

Author SHA1 Message Date
Thalia
21ab535b83 Fix filename in PageUpdater documentation
Change-Id: I7e3d238286f03b785c896a9b5db05af8c5f12fd9
2021-02-24 14:22:18 +00:00
Umherirrender
ef7fc91327 DerivedPageDataUpdater: Skip all data updates when page is deleted
There is nothing the updates can do,
LinksUpdate also fails if there is no id for the given title on master

Bug: T271356
Change-Id: I7fb690bec8dbfadf71eb9caacb4edbfe6b785e73
2021-02-17 22:54:08 +01:00
DannyS712
5e2d63b205 phpcs: remove some unneeded suppressions
Were not removed in doc review following creation
of hook interfaces. Fix line length where needed

Change-Id: I2eafffcf3a1c40d0f5613a893c53e0aa14eed6a2
2021-02-17 16:16:24 +00: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
James D. Forrester
abdc94a3da Swap out uses of User->isLoggedIn() with ->isRegistered()
Bug: T270450
Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
2020-12-22 03:13:37 +00:00
Gergő Tisza
43651eb161
Make the documentation of change tags easier to access
Add constants for the core change tags, and use the constant's
phpdoc to describe them. Also document ct_params format.

Change-Id: I03e70df3598ad71d80a8d09af8a314e7200a1264
2020-11-10 22:02:21 -08:00
Umherirrender
c85a43561e Improve class property documentation
Reformat existing documentation to match the format

Change-Id: I190b54b5e962f17bab6502dd1b3c02f11dc926d2
2020-10-30 10:38:58 +01:00
Ostrzyciel
1a27021526 Reverted tag: do not mark null revisions as reverted
This is to prevent move and protection entries from being marked
with the mw-reverted tag. Thanks to DannyS712 for a suggestion on
how to fix it :)

Bug: T265312
Change-Id: I127acdec69d37b3d0886ac1b7059bf35f1233f51
2020-10-15 19:08:28 +02:00
jenkins-bot
72a90d3d06 Merge "Document hook names in hook interfaces." 2020-10-02 16:15:21 +00:00
Umherirrender
d790580fda Fix typos related to repeated words
Change-Id: Ibc187d95b003017255bc87adf56afae7a59bd3db
2020-09-27 10:25:36 +00:00
daniel
2e57447c58 Document hook names in hook interfaces.
Bug: T258665
Change-Id: Ifddbf57f8aa2e3eb0d5845601376cbafa08ed407
2020-09-27 12:03:12 +02:00
jenkins-bot
9b810a8ddf Merge "Remove unwanted parse step" 2020-09-22 03:57:13 +00:00
Ostrzyciel
a47778d5c0 Add mw-reverted change tag
The tag is added to reverted edits as described in T254074.

Functionality:
* Adding the mw-reverted tag to reverted edits (duh)
* Limiting the maximum depth of the update through a config variable
(mitigation #2 from T259014).
* Only applying the reverted tag after the edit has been somehow
approved. Only the patrol subsystem currently implements this, but
there's a hook that extensions can use (mitigation #4 from T259014, more
explanation in T259103).
* When performing the delayed update, it is checked whether the reverted
edit was reverted itself. If so, the update is ignored. This is
probably the only way to make the feature work due to the lack of an
explicit "disapproval" mechanism other than reverting.
* The update is also ignored if the revert is marked as deleted.

Technical design:
* The update code is in RevertedTagUpdate.php, which is a deferrable
update, but is not used as such. It's separated to allow for better DI,
testing and better code reusability in the future.
* The update is queued / ran using the Job subsystem. The relevant job
is in RevertedTagUpdateJob.php
* PageUpdater determines whether the edit is approved or not and passes
that to the DerivedPageDataUpdater.
* The BeforeRevertedTagUpdate hook lets extensions decide whether the
update should be ran right away or await approval.
* DerivedPageDataUpdater checks whether the edit is a revert and if so
either enqueues the job (if it's auto-approved) or caches the EditResult
for later use (if it needs approval).
* RevertedTagUpdateManager allows for easy re-enqueueing of the update
for extensions. Thus, it has a very minimal interface.

Other notes:
* The unit testing setup for RevertedTagUpdate is a bit complicated,
but it was the only way I could make this class testable while using
the static ChangeTags class.

Bug: T254074
Depends-On: I86d0e660f0acd51a7351396c5c82a400d3963b94
Change-Id: I70d5b29fec6b6058613f7ac2fb49f9fad9dc8da4
2020-08-31 13:40:50 +00:00
Ostrzyciel
299cd0db9f Implement EditResultCache
EditResultCache is meant to be an easy way for storing and retrieving
EditResults associated with revisions. It stores the data in the main
object stash which is supposed to be mostly persistent. In case the
main stash method fails, it falls back to trying to find the
EditResult in the ct_params field of revert change tags.

EditResultCache is to be used for delaying the execution of
RevertedTagUpdateJob until the edit is approved. The code for that
will be in the next commit in the relation chain.

This is a separate commit just for clarity.

Bug: T259103
Change-Id: I6c0c6556b6d98fcd131beb0957230ce7c7d268da
2020-08-31 08:59:10 +02:00
Umherirrender
d6c83c11ad Avoid getContent in PageUpdater::getAtomicSectionUpdate
Only needed for the legacy hooks

Change-Id: Ic682d22c31d9dae3c7270ba25b0a04539465faab
2020-08-25 20:18:57 +02:00
jenkins-bot
6608c80fc8 Merge "Revision: Point to findBadBlobs.php in exception messages" 2020-08-23 01:15:25 +00:00
daniel
353d985620 Revision: Point to findBadBlobs.php in exception messages
Advertize the fact that production errors resulting from corruption in
the content storage layer can be remedied using findBadBlobs.php.

Change-Id: I4eab773d0d2da57a545f211c2fef36146331c570
2020-08-23 00:50:32 +00:00
Aryeh Gregor
a24e8a06b5 Mark CONSTRUCTOR_OPTIONS as internal
These were never meant to be part of the public interface and should not
ever have been marked with @since. They're only useful for constructing
the respective objects, which no outside users should be doing.

Change-Id: I86e01272d46fc72af32172d8a12b9180971d4613
2020-08-21 00:18:45 -04:00
Ostrzyciel
a3f9ed68ce EditResult: update undo-related docs
Updated the doc block to reflect the changes made in
I9279230303a01461039ae8a4641d9897ce194f73

Bug: T259014
Change-Id: I6aeec4ba75f1e5ac939ef526171d7268902f1f57
2020-08-18 11:08:50 +02:00
jenkins-bot
ac9cb958a8 Merge "Fix a typo: tabel -> table" 2020-08-07 22:11:36 +00:00
DannyS712
360b12790a Fix a typo: tabel -> table
Bug: T201491
Change-Id: I830619b99ed85c3a9e30e80f19f80b1feed01f73
2020-08-07 21:47:44 +00:00
Ostrzyciel
5488a33340 Save additional info about reverts in ct_params
This aims to persist the EditResult object associated with reverts
in the ct_params field of change_tag table for revert tags. This can
be later used for analytics or when performing a delayed
RevertedTagUpdateJob (see T259103).

The code doing that has to be in the RecentChange class, as only it
knows the relevant rc_id and rev_id.

Bug: T259733
Change-Id: I365cf44484aa5bf907128a075fcff890649504c4
2020-08-07 06:45:50 +00:00
Ostrzyciel
67b5a4214c EditResult: enable serialization
Serializable EditResult will be required to save it for later use by
RevertedTagUpdateJob.

Additionally I decided to save the serialization format version in
case we want to modify it in the future.

Bug: T259732
Change-Id: I0cddc9c0439c8a59b5f66cea9e7db5bb151cb53b
2020-08-05 20:38:14 +02:00
Ed Sanders
7683f7d839 Use strict (in)equality with namespaces constants when LHS is definitely an integer
Change-Id: I8fede00dfe1270d93c5d78d3c36e788cddfc8a99
2020-07-31 18:03:28 +01:00
Ostrzyciel
8de0f3a883 PageUpdater: fix handling of null edits
Previously null edits were not properly marked in EditResult objects
provided by the PageUpdater. This change should fix it, by ensuring
the original revision ID is always set on the EditResultBuilder if
the edit is a null edit.

I've also added some code to test this, so we hopefully don't
encounter an issue like this in the future. :)

Bug: T257766
Change-Id: I04bb058c64483967617958d86aa40a67c31071cb
2020-07-21 12:22:33 +02:00
Yuki Shira
954dc9a05a PageUpdater: Update @since tag from 1.35 to 1.36 for $wgManualRevertSearchRadius
Follow-up to I4e38b382391b42e252cb66584be1e174cdfe348c

Bug: T256001
Change-Id: Iaf3dada238b4790ce2eb121541067a26bb8e3b6f
2020-07-18 06:52:48 +00:00
Ostrzyciel
435d5f4d55 Add mw-manual-revert change tag
Based on the patch that introduces manual revert detection, this is
to create a software-defined change tag that will be applied to all
edits that restore a page to an exact previous state. This is also
for consistency with mw-undo and mw-rollback that will make a
"reverted" tag appear on reverted edits in the future.

Note about the REST API tests: in the next patch in this chain
I encountered even more issues with comparing returned changed tags
with expectations, so I decided it'd better if we just checked the
change tags applied manually in these tests. Otherwise we can run into
nasty race conditions, as the reverted tag is processed after sending
the response to client in the deferred update. It also makes the test
hard to maintain.

Bug: T256001
Change-Id: Ic367886f39faedcb823222b7d63bf4d5cb236ae9
2020-07-16 13:29:12 +02:00
Ostrzyciel
1dc2319c1a EditResultBuilder: manual revert detection
The code for manual revert detection is ran when building the
EditResult and the edit was not marked as a revert yet. It's
based on a SELECT looking for recent edits that match the new
revision's SHA1. There is no index over rev_sha1 field, so we
limit the search to N most recent edits, in order not to cause a
full table scan.

I think this shouldn't break any extensions by setting the
originalRevisionId in situations that weren't expected, almost no
extension uses that anyway:
https://codesearch.wmflabs.org/search/?q=%5C%24originalRevId&i=nope&files=&repos=

Bug: T256001
Change-Id: I4e38b382391b42e252cb66584be1e174cdfe348c
2020-07-14 15:34:57 +02:00
daniel
e6e0ad2472 Replace "@stable for implementation" with "@stable to implement"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: I17e5e92e24c708ffc846945a136347670a3a20c7
2020-07-13 11:05:49 +02:00
Ostrzyciel
7d5fa77324 EditResult: improve documentation
As the EditResult class changes a few things slightly and may be
a bit confusing for developers, I clarified it a bit in the
comments.

It would be probably useful to document this properly on mediawiki.org,
which I'll do once a few things with EditResult are sorted out.

Bug: T254074
Change-Id: Ic8d654ce2c10f079c5a3f417cb2dc0f6e5d7b5b2
2020-07-09 14:19:38 +00:00
daniel
102c9573b3 Mark exceptions as @newable
Exceptions classes are nearly always value objects, and should in most
cases by newable.

Bug: T247862
Change-Id: I4faa8ec6ea8bc44086cfc8075b32d10eea61e9df
2020-07-08 17:51:38 +00:00
jenkins-bot
804abf07f3 Merge "Fix some incomplete PHPDocs in Revision and related" 2020-07-03 11:57:32 +00:00
Ostrzyciel
881a1b9a90 EditResultBuilder: use RevisionRecord::hasSameContent
This is a tiny change to use RevisionRecord's hasSameContent
method instead of comparing SHA1s directly. This should also be
marginally faster.

Bug: T254074
Change-Id: Ifbdbf889eab2167ae2510dc9760771c9d4c3c3e0
2020-07-02 22:00:09 +02:00
DannyS712
fe201ad436 Don't create Revisions for deprecated hooks if hook is not registered
Once the Revision class is hard deprecated, we will still need to
run hooks that use Revision objects; even though the hooks will be
deprecated, Revision objects still need to be created for them.

To ensure that deprecation warnings aren't triggered by creating
Revision objects in deployed code, for deprecated hooks only
create the Revision object if the hook is registered.

All hooks that pass Revision objects have already been hard deprecated.

Bug: T246284
Change-Id: I7e718551822825cd390662bb201dd13e2e527e8b
2020-07-01 03:44:36 +00:00
DannyS712
52051a996b Hard deprecate the TitleMoveComplete and PageContent(Insert|Save)Complete hooks
Bug: T250023
Bug: T250566
Change-Id: I7e701e0aac0b09acae448df3a7c72f2047bc2118
2020-07-01 00:22:56 +00:00
DannyS712
9ab8615d36 PageUpdater: set DeprecatablePropertyArray to hard deprecate Revision
Bug: T254952
Change-Id: Idfdbdcf00b875bd88045c71a30c6a8ddd1057a78
2020-06-30 15:59:57 +00:00
jenkins-bot
465c3eccfb Merge "DerivedPageDataUpdater::prepareUpdate deprecate passing a Revision" 2020-06-24 03:15:37 +00:00
DannyS712
f47b779f56 DerivedPageDataUpdater::prepareUpdate deprecate passing a Revision
Revision can be in the $options array
Callers also need to be updated

Bug: T255909
Change-Id: I22aa89aaab546b98b516cf344655589550a13457
2020-06-23 23:48:30 +00:00
Ostrzyciel
de602706c8 Modify PageSaveComplete hook to use EditResult
This hook was introduced in 1.35 and the EditResult parameter makes
$originalRevId and $undidRevId params redundant.

I also uploaded cross-repo dependent patches for extensions that
already use this hook.

Bug: T254074
Depends-On: I3922d9a92242c9a6469058a2a2c2a95891e9e429
Depends-On: I52e7d6198c000100e9c1013ebc865c1f9b836fe4
Change-Id: I551702327c6e2b6dab9e0eda52f03ebb9382d050
2020-06-23 12:10:29 +00:00
jenkins-bot
52f1bfa61b Merge "PageUpdater: create EditResult class" 2020-06-23 10:18:32 +00:00
Ostrzyciel
3d73bdf568 PageUpdater: create EditResult class
EditResult is an immutable object created during a page update by
the PageUpdater using a builder object, the EditResultBuilder.

EditResult is a container for information on how the edit
interacted with the page and previous revisions. It also aims to
provide a standardized way of describing reverts and reverted
edits. It is as simple as possible, with no dependencies on the DB
or global variables. Most of the logic is encapsulated in the
builder.

PageUpdater::getEditResult() replaces the following methods:
* getOriginalRevisionId()
* getUndidRevisionId()
They are both available in the EditResult object.

PageUpdater::markAsRevert() replaces
PageUpdater::setUndidRevisionId()

Bug: T254074
Change-Id: Ie04c38043d9c295552e488109436ec1df20bb2ca
2020-06-23 11:49:02 +02:00
Thalia
7c65a81ed1 PageUpdater: Fix typo in documentation for grabParentRevision
Change-Id: I00f6f5b6400514277f5d04bbd7fe8356d3a55d2a
2020-06-22 15:40:26 +01:00
jenkins-bot
f34d26672e Merge "Add PageSaveComplete hook to replace PageContent(Insert|Save)Complete" 2020-06-10 21:02:49 +00:00
DannyS712
0e915c0b63 Add PageSaveComplete hook to replace PageContent(Insert|Save)Complete
Bug: T250566
Change-Id: I8e515ad9d344cb31e59bcfc87a717ca2b93feee2
2020-06-10 20:41:00 +00:00
DannyS712
a6d16bd03d Remove unneeded creation of revision objects
Clean up some technical debt; use MutableRevisionRecord instead of
manually constructing a Revision from an array, remove last uses of
RevisionStoreDbTestBase::revisionToRow and remove the method.

Each file can be reviewed separately (except that the removal of
revisionToRow depends on replacing its usage)

Bug: T246284
Change-Id: I0bdc069b21a5c41ef8f9e972c5b17ff189d4a741
2020-06-10 09:09:55 +00:00
Petr Pchelko
2704be7df8 Introduce DeprecatablePropertyArray and use it for PageUpdater
Bug: T250638
Change-Id: I53e39be59228ac5a57f34d51d733d1647331889c
2020-06-09 07:09:00 -07:00
Thiemo Kreuz
0904c27af9 Fix some incomplete PHPDocs in Revision and related
Change-Id: I295332b987a553f6b55b2fbab463c44ae05c6c8d
2020-06-08 13:53:12 +02:00
Umherirrender
fd1ed0c092 Pass function name to database functions
Useful for logging

Change-Id: Ia2160fb6be5fc93f28ab51f7ae23d7f078247481
2020-06-07 14:16:52 +02:00
jenkins-bot
2db34afa49 Merge "Replace core uses and hard deprecate Parser(Options) Revision methods" 2020-06-03 23:58:34 +00:00
jenkins-bot
08dae812d0 Merge "resourceloader: Use RevisionRecord in WikiModule::invalidateModuleCache" 2020-06-03 23:00:31 +00:00