Commit graph

319 commits

Author SHA1 Message Date
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
Matěj Suchánek
61289e0290 Deprecate replaced PageArchive methods
Change-Id: I07fe12e6e96c6a27b66655f179c09f624180daa3
2021-10-21 18:28:03 +02:00
jenkins-bot
f0123b83b5 Merge "Make ArchivedRevisionLookup a service" 2021-10-20 18:51:32 +00:00
jenkins-bot
91a9e2db75 Merge "Move methods from PageArchive to new ArchivedRevisionLookup" 2021-10-20 18:47:42 +00:00
Roman Stolar
fa5237eb48 Replace Content::getParserOutput call to ContentRenderer::getParserOutput
Bug: T287158
Change-Id: I8a13f45027e08e2d8ddefa140dd47a0c55094934
2021-10-20 12:11:24 +03:00
Petr Pchelko
2ae3e55f64 Remove Title dependency from RenderedRevision
Change-Id: I8da86277e0c8406a49ebd86faddf3dc2abbf5328
2021-10-19 07:53:26 -07:00
C. Scott Ananian
06ab90f163 Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean
flags in ParserOutput.  It allows extensibility in core (by adding new
field names to ParserOutputFlags) without exposing new getter/setter
methods to Parsoid.  It replaces the ParserOutput::{get,set}Flag()
interface which (a) doesn't allow access to certain flags, and (b) is
typically called with a string rather than a constant, and (c) has a
very generic name.  (Note that Parser::setOutputFlag() already called
these "output flags".)

In the future we might unify the representation so that we store
everything in $mFlags and don't have explicit properties in
ParserOutput, but those representation details should be invisible to
the clients of this API.  (We might also use a proper enumeration
for ParserOutputFlags, when PHP supports this.)

There is some overlap with ParserOutput::{get,set}ExtensionData(), but
I've left those methods as-is because (a) they allow for non-boolean
data, unlike the *Flag() methods, and (b) it seems worthwhile to
distingush properties set by extensions from properties used by core.

Code search:
https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos=

Bug: T292868
Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
2021-10-15 14:25:54 -04:00
Matěj Suchánek
01913e4731 Make ArchivedRevisionLookup a service
Dependency injection and cleanup. Rename ::isDeleted
to more clear ::hasArchivedRevisions.

Bug: T290022
Change-Id: Ifff6076f79ee2ad08e4635fba8fd141e4de93b01
2021-10-08 11:01:32 +02:00
Matěj Suchánek
21ec2fb282 Move methods from PageArchive to new ArchivedRevisionLookup
Copy and paste methods. Subsequent patches will tidy this up.
Also improve test coverage.

Bug: T290022
Change-Id: I549ecc3ec89f0303a3cc342916f06da4bf77595e
2021-10-08 10:30:49 +02:00
Tim Starling
f7f84dddb3 Introduce CommentFormatter
CommentParser:

* Move comment formatting backend from Linker to a CommentParser service.
  Allow link existence and file existence to be batched.
* Rename $local to $samePage since I think that is clearer.
* Rename $title to $selfLinkTarget since it was unclear what the title
  was used for.
* Rename the "autocomment" concept to "section link" in public
  interfaces, although the old term remains in CSS classes.
* Keep unsafe HTML pass-through in separate "unsafe" methods, for easier
  static analysis and code review.

CommentFormatter:

* Add CommentFormatter and RowCommentFormatter services as a usable
  frontend for comment batches, and to replace the Linker static methods.
* Provide fluent and parametric interfaces.

Linker:

* Remove Linker::makeCommentLink() without deprecation -- nothing calls
  it and it is obviously an internal helper.
* Soft-deprecate Linker methods formatComment(), formatLinksInComment(),
  commentBlock() and revComment().

Caller migration:

* CommentFormatter single: Linker, RollbackAction, ApiComparePages,
  ApiParse
* CommentFormatter parametric batch: ImageHistoryPseudoPager
* CommentFormatter fluent batch: ApiQueryFilearchive
* RowCommentFormatter sequential: History feed, BlocklistPager,
  ProtectedPagesPager, ApiQueryProtectedTitles
* RowCommentFormatter with index: ChangesFeed, ChangesList,
  ApiQueryDeletedrevs, ApiQueryLogEvents, ApiQueryRecentChanges
* RevisionCommentBatch: HistoryPager, ContribsPager

Bug: T285917
Change-Id: Ia3fd50a4a13138ba5003d884962da24746d562d0
2021-09-28 11:13:03 -07:00
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