Commit graph

390 commits

Author SHA1 Message Date
Umherirrender
19925ef026 Add various fallback values for null return values
Found by phan strict checks

Change-Id: I83187b5fd25b015d2c75e22d4b5202803653d743
2022-03-09 20:15:36 +01:00
Umherirrender
0cf2ec2585 Pass rcid as integer to DifferenceEngine::createDifferenceEngine
Found by phan strict checks

Change-Id: I3c0454c1df66f6a04c3392acaf8368040d03eb77
2022-03-05 19:45:57 +01:00
Daimona Eaytoy
662e644a0c Hard-deprecate Article::doDelete
Unused in WMF-deployed code.

Change-Id: If8430aba5d2bebcb8e11e2fc6617187c1fd0302d
2022-02-25 14:29:50 +00:00
jenkins-bot
7e19c4749d Merge "Add OutputPage::disableClientCache() and deprecate ::enableClientCache(false)" 2022-02-10 07:01:21 +00:00
Bartosz Dziewoński
858e7af980 Modernize some warnings about account not being registered
The "error" class nowadays is only supposed to be used by Parser and
related code. It renders as red text with no special formatting.
Instead use Html::warningBox(), which renders a yellow box around the
text. (Not Html::errorBox(), because these are not really errors.)

Change-Id: I7a7046bf9b9765cbb82ec3caa1530de7f05e0da4
2022-02-09 21:25:19 +00:00
C. Scott Ananian
065617f93c Add OutputPage::disableClientCache() and deprecate ::enableClientCache(false)
As far as I can tell, outside of test cases, every single time we call
OutputPage::enableClientCache() we pass it `false` and actually mean to
*disable* the client cache.  Create a new less-confusingly-named method
and deprecate the old one.

Change-Id: I7c89e20528a0d91173f0edcb997dcae631935ee5
2022-02-04 15:51:50 -05:00
jenkins-bot
57b9cb6744 Merge "page: Use MainObjectStash instead of 'db-replicated' cache" 2022-01-17 23:12:36 +00:00
Amir Sarabadani
5954d3edff page: Use MainObjectStash instead of 'db-replicated' cache
This is for page-recent-delete and db-replicated should not be used for
this. Simply use the standard and common service providing the same
functionality.

Bug: T272512
Change-Id: Iabaffd726370f5a580097819fd854da82bf43907
2022-01-11 10:58:31 +01:00
TChin
47adb6d65a Refactor global variables to use MediaWikiServices instead
Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI.

Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228

* This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it.

A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki

Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
2022-01-10 13:55:53 -05:00
Siddharth VP
0d9b49beff Fix typos in comments (A-B)
Change-Id: I852453fbeeebdc4e34c0b35c0fdca4b4ab74fde9
2021-12-26 16:43:47 +05:30
Amir Sarabadani
3cacc7f9c3 Fix local rendering of link in diff view with action=render
We probably should move Linker::expandLocalLinks( $text ) somewhere
better.

Bug: T263581
Change-Id: Iac446e761a709b6ceff5bd83dfa9a80db50a08d5
2021-12-01 17:18:53 +01:00
Reedy
7bf779524a Remove or replace usages of "sanity"
Bug: T254646
Change-Id: I2b120f0b9c9e1dc1a6c216bfefa3f2463efe1001
2021-11-19 23:19:42 +00:00
Ppchelko
643fc535c3 Reapply "Move limit report rendering to ParserOutput"
This reverts commit 2bcb3fe567.

Reason for revert: this is a good change,
just needed more work to not break CI

Change-Id: I23768bee242e3cf81b1493a740cf070e7ad1e224
2021-11-09 11:08:08 -08:00
Ppchelko
2bcb3fe567 Revert "Move limit report rendering to ParserOutput"
This reverts commit 89028e0b8e.

Reason for revert: Temporary until we deal with T295357

Change-Id: I556de18dbf900a9bc58d5ae22d1bf194682d0840
2021-11-09 15:57:18 +00:00
Petr Pchelko
89028e0b8e Move limit report rendering to ParserOutput
This does not move the actual limit report data into
ParserOptions yet, that should be done separately
given that it will require serialization changes.
Let's get this change settled first before messing
with serialization.

This unifies canonical and non-canonical ParserOptions,
so ParserCache can now be used with both. It is hard
to say how this will affect the ParserCache capacity,
so we should monitor it after releasing this.

Change-Id: I154c0a77a5b0287b5572614d56339fb57ac56c33
2021-11-08 12:45:41 -08:00
C. Scott Ananian
f3d7462e37 Set ParserOutput 'injectTOC' based on Skin options for page views
Clean up loose ends from the skin table of contents patch (I44045b3b9).

* Clarify $options -> $skinOptions (because there are so many different
  "options" classes!)
* Remove redundant default when Article::doOutputFromParserCache()
  calls ParserOutput::getText() -- the 'injectTOC' option defaults
  to true inside ParserOutput::getText() as well.

Bug: T287767
Followup-To: I44045b3b9e78e7ab793da3f37e3c0dbc91cd7d39
Change-Id: I04b8d8a4076df551347ec6d6599d597424a2dadf
2021-11-08 18:09:46 +00:00
jdlrobson
24949480eb Give skins more flexibility over table of contents render
* Do not store table of contents in parser output
* Instead inject table of contents via strpos where needed
  inside Article based on Skin "toc" option
* Use <mw:tocplace> as a TOC placeholder; for Parsoid compatibility
  this will be replaced with a <meta> tag in a followup patch.

Bug: T287767
Change-Id: I44045b3b9e78e7ab793da3f37e3c0dbc91cd7d39
2021-10-25 22:26:41 +00:00
Daimona Eaytoy
c0c213ba46 DeleteAction-related cleanup, part 3
Move all output-related code from Article to DeleteAction.
Article::doDelete is now deprecated, because there are some callers in
the wild, although I don't think any caller should need it.

Kill some ancient-PHP-style pass-by-refs that are useless and only make
the code more error-prone for both the caller and the callee.

Bug: T288282
Change-Id: Ic1de0ed8ebba15da5ed9f5cd11625017360a7672
2021-10-06 13:43:54 +02:00
C. Scott Ananian
df3cc40fac Rename ParserOutput::{allow,prevent}Clickjacking() -> ::{get,set}PreventClickjacking()
This name is consist with the rest of the setter and getter methods
in ParserOutput.  Renamed the methods in OutputPage, ImageHistoryList,
ImageHistoryPseudoPager, and ContribsPager as well for consistency;
it also makes chasing down lingering references in codesearch easier.

Soft-deprecated the old name for 1.38.  Hard-deprecation will follow,
but there are a number of users in production that should be chased
down first.

Code search:

https://codesearch.https://codesearch.wmcloud.org/deployed/?q=(allow%7Cprevent)Clickjacking&i=nope&files=&excludeFiles=&repos=

Bug: T287216
Change-Id: I9822c60c180d204bd30cb4447a1120155d456da4
2021-10-01 14:13:47 -04:00
jenkins-bot
eaf10f600b Merge "Expand local URLs to absolute URLs in ParserOutput" 2021-09-27 14:48:02 +00:00
Petr Pchelko
d334de960a Expand local URLs to absolute URLs in ParserOutput
New option 'absoluteURLs' was added to getText method
of the ParserOutput object that replaces all links
in the page HTML with absolute URLs.

Removing the action=render special case from Title
seems safe cause we will end up replacing the result
with absolute URL if we're in a render action no matter
where Title::getLocalUrl was called from.

This change is safely revertable from the perspective
of ParserCache.

Bug: T263581
Change-Id: Id660e1026192f40181587199d3418568f0fdb6d3
2021-09-23 11:48:51 -07:00
Daimona Eaytoy
beadd4454f Move code from PageArchive to a new UndeletePage command
This is just moving code verbatim, removing now-unneeded stuff, and
duplicating tests as well.

Bug: T290021
Change-Id: I540ddaaa11dfabcf0b87b608b151b5e34d199fd8
2021-09-21 16:11:29 +00:00
Daimona Eaytoy
30a4919717 Remove Article::delete() Article::confirmDelete() and ImagePage::delete()
All unused.

Bug: T288282
Change-Id: Ia07ddab8c0ec9b74e58e980798263f6b6685a31f
2021-09-16 19:10:55 +02:00
Ammarpad
55b9c6d387 Provide proper message for no-perm suppressed edit view context
Add 'rev_suppressed_text' failure message to avoid reusing
'rev-deleted-text-permission' for both deleted and suppressed edits.

Additionaly fix qqq documentation of 'rev-deleted-text-permission':
It's used in both privileged and unpriviliged context. The log link
it has links to public log.

Also fix qqq doc of 'rev-suppressed-text-permission': It's only
shown in privileged context. The log link it has links to private
log

Bug: T282203
Change-Id: Iffcbe9d62c2b2947ebb086579f87d977d8a5eb3d
2021-09-13 06:06:31 +00:00
Derick Alangi
db43511e6a Title: Make use of BacklinkCacheFactory service
Change-Id: I48161585de6f329ec4037156234e0b07b3b837e6
2021-09-09 14:04:02 +01:00
Timo Tijhof
e387cd9c35 Change trivial use of getVal('action') to getRawVal
Per docs added in I18767cd809f67b, these don't need normalization
as they are only compared against predefined strings, and besides
are generally entered manually in a form, and even then would not
require the kinds of Unicode chars that have multiple/non-normalized
forms.

In nearby areas to also fix some trivial cases:

* getVal('title') obviously needs normalization.
  Use getText() to make this more obvious.

* getVal() compared against simple string literals within the code
  obviously don't need normalization (e.g. printable === 'no').

* Change hot code in MediaWiki checking for whether 'diff' or 'oldid'
  are set to getCheck (which uses getRawVal) instead of getVal.
  As a bonus this means it now handles values like "0" correctly,
  which could theoretically have caused bad behaviour before.

Change-Id: Ied721cfdf59c7ba11d1afa6f4cc59ede1381238e
2021-08-26 22:11:58 +01:00
jenkins-bot
8d2bdc20c2 Merge "Specify DB to query when checking if a user is blocked from a page" 2021-08-26 17:43:34 +00:00
Daimona Eaytoy
f1978dbd73 Build the page deletion form in DeleteAction, not Article
This is the first patch in that direction, and for now, the code is
**only moved** with minimal changes, to keep the diff small and make it
easier to review. More patches will be sent to clean up this code,
before moving parts of it to a separate service.

Article::delete() and friends were hard-deprecated, given the lack of
callers according to codesearch (searched in "Everything").

The logic for varying the form depending on the page type is also being
moved to DeleteAction, which means there's currently no way for
extensions to customize that (and I couldn't find any extension doing
that at the moment). Should we need this behaviour, we could add a hook to
DeleteAction to allow altering the form.

Bug: T288282

Change-Id: I34525cf3e7c9a82032101b8c2e7b14d6dff59092
2021-08-16 13:02:47 +02:00
Taavi Väänänen
26e32a70a0
Include mediawiki.actions.styles with patrol link
Always add the RL module when the patrolling link is shown.

Bug: T288799
Change-Id: Id0baeb88a080ecf9bdcb075edda3bf609a12e679
2021-08-14 12:17:47 +03:00
Ppchelko
759642ec1e Revert "Build the page deletion form in DeleteAction, not Article"
This reverts commit 2644eba483.

Reason for revert: breaking changes without deprecation. 

Change-Id: I52b843bdd82fc9038504fb7258c3e324e58a1b8e
2021-08-13 14:38:24 +00:00
Daimona Eaytoy
2644eba483 Build the page deletion form in DeleteAction, not Article
This is the first patch in that direction, and for now, the code is
**only moved** with minimal changes, to keep the diff small and make it
easier to review. More patches will be sent to clean up this code,
before moving parts of it to a separate service.

Article::delete() is being removed since there's going to be no
reasonable way to maintain BC, and it's also unused (which I think is
expected, given how many things that method would do).

The logic for varying the form depending on the page type is also being
moved to DeleteAction, which means there's currently no way for
extensions to customize that (and I couldn't find any extension doing
that at the moment). Should we need this behaviour, we could add a hook to
DeleteAction to allow altering the form.

Bug: T288282
Change-Id: Iadb8137d728f4fd4e749a1052f8aef4bab11ec09
2021-08-12 15:48:47 -04:00
Petr Pchelko
c563798b51 Remove hard-deprecated Article::getContentObject
Change-Id: I31eb3cc5574391c9e35d57ac5b2fc83e12f5a1bc
2021-08-12 11:32:28 -07:00
Kunal Mehta
a85f569dd1 Revert "Use CsrfTokenSet as CSRF token source"
This reverts commit 0d75fdb4f7.

Bug: T287542
Change-Id: Iedd3461869f973f8d621a39e6ad4674cbb577551
2021-08-05 15:48:26 -07:00
Petr Pchelko
0d75fdb4f7 Use CsrfTokenSet as CSRF token source
Change-Id: I079d2c802d9b48d6abf7f37fa9ef7dafac631345
2021-07-12 14:19:15 -07:00
Roman Stolar
6ebaa5caf6 Remove the fallback for create rights (covered in PM edit rights check).
Remove key to i18n message, no longer being used.

Bug: T272079
Change-Id: Id6566e5241b06ba377c2eca083221ee02556365f
2021-06-30 17:30:30 +03: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
jenkins-bot
3d487a3b89 Merge "Replace easy usages of User for UserIdentity/Authority" 2021-06-11 11:56:46 +00:00
Petr Pchelko
6a8a786599 Replace easy usages of User for UserIdentity/Authority
Change-Id: Id176ee0fab64707020ac6c47a087ef00f8bed4e3
2021-06-09 07:53:52 -07:00
Petr Pchelko
92564edc7c Use Message::page instead of Message::title
Also modified new APIs added to ApiErrorFormatter to
use PageReference instead of Title.

Change-Id: I093c89f8e1e6d383603f887358be6ece70f23a02
2021-06-09 13:18:22 +00:00
Petr Pchelko
8f644e7b9b Remove some User typehints that are just passthrough
Change-Id: I7183998df9e76c107d46efe17bde0491b500cc62
2021-06-02 20:41:30 -07:00
Roman Stolar
dbe594a3ce Replace RecentChange::getPerformer with RecentChange::getPerformerIdentity
Preparing replace in core (DifferenceEngine.php, Article.php, ChangesListSpecialPage.php)

Bug: T276412
Change-Id: I4fd9cbd9404879d082179b68a9993e7203e43a8d
2021-05-27 11:45:17 +03:00
Thalia
23b9b9c61b Specify DB to query when checking if a user is blocked from a page
When calling PermissionManager::isBlockedFrom, don't query the
primary database when only showing UI elements.

Bug: T283268
Change-Id: I9a79badf8a7cfb6afc7b4d12e4f1fbb5c24b6a86
2021-05-24 16:22:17 +01:00
Marius Hoch
754132a4a3 Article: Use correct timestamp for OutputPage::setRevisionTimestamp
Instead of always (except when reading from ParserCache),
using the latest version.
This can also clearly be seen by visiting an old revision on
Wikipedia (https://en.wikipedia.org/w/index.php?oldid=N)
and looking for "This page was last edited on …". When first
loading the old revision, the TS of the last rev will be shown,
upon reloading, the correct time will be shown (as the output
is fetched from parser cache).

This reverts the test removals from I83a43d651.

Bug: T282648
Change-Id: I517d4970d5c682489f27a65ba01ee30db9c62276
2021-05-12 15:22:35 +02:00
jenkins-bot
d8765841c8 Merge "Article::generateContentOutput: Ensure OutputPage has rev id set" 2021-05-12 00:44:27 +00:00
Marius Hoch
929dbef76d Article::generateContentOutput: Ensure OutputPage has rev id set
This should not default to latest revision id, but
Article::getRevIdFetched() if the ParserCache doesn't
have the id set. Also set the revision id before calling
OutputPage::addParserOutput to make sure the id is
already set when the "OutputPageBeforeHTML" hook is run
(which is the case in other code paths).

Additionally I've made the tests more robust, by no
longer manually getting the revision into parser cache.

Bug: T281587
Change-Id: I999195441f9d75a7e4bde4d843ad7729cdb1bee0
2021-05-11 21:33:12 +02:00
daniel
753b1bcaff Introduce Block interface and replace AbstractBlock.
In order to allow Authority to know about user blocks,
we need a narrow interface to represent such blocks.

This deprecates some methods on AbstractBlocks in favor
of new methods on the Block interface that avoid binding to
the User class.

Bug: T271494
Change-Id: I7bb950533970984a014de0434518fbbefb695131
2021-05-11 11:36:11 +02:00
DannyS712
c0dd682544 Start removing places using Revision objects
- EditPage::$mBaseRevision
- EditPage::getBaseRevision()
- Title::getFirstRevision()
- LinksUpdate::setRevision()
- LinksUpdate::getRevision()
- Article::$mRevision
- Article::getRevisionFetched()
- WikiPage::getOldestRevision()
- WikiPage::getRevision()
- ContribsPager::tryToCreateValidRevision()

To make things easier, instead of rewritting
the Revision tests that were using WikiPage::getRevision,
just delete them, its not worth the effort to rewrite
them since the class is going away. For the WikiPage
tests, replace uses of getRevision with getRevisionRecord,
manually converting to a Revision object where needed

Bug: T247143
Change-Id: I52bc1f49649f8bd25797e3f7a090bec9c63ac2d1
2021-04-30 12:33:15 -07:00
vladshapik
9cc797695b Hard deprecate User ::isIP, ::getOptions
Bug: T275602
Change-Id: Id4be13751ca0a900e51214c1855a4624077a5a62
2021-04-26 16:10:24 +00:00
Cindy Cicalese
fb6b6e058c Fix parameter order of setWatch to match add/removeWatch
Change-Id: I0ea63482a5cab24c23b49b8bbe6c80bdbe8b102b
2021-04-21 04:41:38 +00:00
Cindy Cicalese
a384acffa7 Use WatchlistManager in several classes
Change-Id: I720629e08373736b5fc1e12563b5059311b113e1
2021-04-21 00:37:40 -04:00