Commit graph

1336 commits

Author SHA1 Message Date
Matěj Suchánek
61289e0290 Deprecate replaced PageArchive methods
Change-Id: I07fe12e6e96c6a27b66655f179c09f624180daa3
2021-10-21 18:28:03 +02:00
jenkins-bot
40d14fee7d Merge "Change return format of DeletePage entrypoints" 2021-10-20 22:18:33 +00:00
Daimona Eaytoy
965f6db3c1 Change return format of DeletePage entrypoints
Instead of putting logID/false in the status' value, add getters that
can be used to retrieve this information. Also, make it return an array
of log IDs, which is easier to expand later on to account for deletion
of related pages (e.g. associated talk page).

Note: this change will be backported to 1.37.

Bug: T288758
Change-Id: I7ef64242ae0cb7018a4b1e8eb004a5563925b9a4
2021-10-20 19:26:12 +00: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
Petr Pchelko
cf4b335aaf Don't pass nulls to CommentFormatter::formatStrings
Bug: T292797
Change-Id: I00607ef2a65076a34f99d2f5fdc658e1c6e11832
2021-10-20 06:56:13 -07:00
Lucas Werkmeister
3393545f44 Fix return type of PageStore::newSelectQueryBuilder()
Only the PageSelectQueryBuilder subclass has the methods that are
interesting for users of this method.

Bug: T291288
Change-Id: If73748cc24d2ab2ee7999db14201d7fc19b2cd34
2021-10-18 11:56:17 +02:00
jenkins-bot
c99c6eb384 Merge "Pre-format comments for non-local files too" 2021-10-12 15:46:39 +00:00
jenkins-bot
ce1c6b7002 Merge "Migrate WikiPage::doEditUpdates() to using PageUpdaterFactory" 2021-10-11 11:36:50 +00: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
Derick Alangi
6407361b46 Migrate WikiPage::doEditUpdates() to using PageUpdaterFactory
WikiPage::doEditUpdates() has been deprecated. Using the PageUpdaterFactory's
newDerivedPageDataUpdater() is the new way forward. Also, I made sure to have
the `$options` array with the `causeAction` and `causeAgent` key/value pairs.

Change-Id: I9f2c212d7c83a46799f9f947dc372dc364289680
2021-10-07 11:17:43 +01: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
Petr Pchelko
087d9f076b Pre-format comments for non-local files too
Bug: T292570
Change-Id: I068f29f6e66c7af853c5762a2a052c362158dd52
2021-10-05 12:38:18 -07:00
Daimona Eaytoy
249306e112 Add perm checks to UndeletePage and make it a real service
Add entry in MediaWikiServices, add wiring code, inject all dependencies.

Also add an alternative entry point with permission checks, like for
DeletePage.

The new service is no longer @unstable, and the relevant methods in
PageArchive were deprecated.

Bug: T290021
Change-Id: I452a98679f5bfea3f7367aacd5c930acffd32102
2021-10-04 20:25:49 +00:00
jenkins-bot
08766dcad4 Merge "Check change tags permissions in DeletePage" 2021-10-04 19:56:20 +00: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
Daimona Eaytoy
42a24c3e98 Use fluent setters instead of optional params in UndeletePage
Also make $comment a required parameter, for symmetry with DeletePage.

Bug: T290021
Change-Id: I0bb2c6b782bf4d61396657d367e182295f913f0e
2021-10-01 17:32:10 +00:00
jenkins-bot
85f805bb6b Merge "Deprecate the UndeleteForm::undelete hook" 2021-09-28 19:21:39 +00: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
Daimona Eaytoy
eedd8a7774 Deprecate the UndeleteForm::undelete hook
It allowed replacement of the PageArchive object, which is so horrific
that I'm going to have nightmares for a while after seeing that code.

A new hook, PageUndelete, was added to give users something to migrate
to that is also used by API requests etc, and for symmetry with
DeletePage.

This change needs to be in 1.37, since the capability of replacing
PageArchive will be removed in 1.38 by the addition of the UndeletePage
service. Note that in 1.37, errors from the status will not be used
since PageArchive::undeleteAsUser returns false in case of errors.

The only usage of this hook in WMF production (ext:Newsletter) is fixed
in a dependent patch. A non-WMF usage in ext:Video is not fixed since
that one does replace PageArchive and I'd rather not mess with that.

SpecialUndelete has two other similar hooks that pass a PageArchive by
reference, but in those places PageArchive is used as a lookup (not an
undeletion command), so they're not affected by the ongoing undeletion
work, and we cannot deprecate them since we'd have to provide
replacements first. I've left some comments anyway.

Bug: T290021
Change-Id: If434c7ff9de92482f84d535baae5139c18081174
2021-09-28 15:40:50 +00:00
jenkins-bot
6108f30c52 Merge "Move some methods from FileDeleteForm to a subclass of DeleteAction" 2021-09-27 22:54:42 +00:00
jenkins-bot
cc4c8a0cbb Merge "Change return format of UndeletePage::undelete()" 2021-09-27 16:26:42 +00:00
Daimona Eaytoy
d24641a2a0 Change return format of UndeletePage::undelete()
- Make it consistently return a StatusValue, as is expected by this
  kind of methods.
- Omit the comment in the returned status, as it matches the one
that was passed as method parameter to undelete().
- Return a good status if there was nothing to undelete. Callers can
  check the status value to determine if something was deleted.

The new format will make getRevisionStatus and getFileStatus
unnecessary, and will also make it impossible to distinguish between
file-related and revision-related errors. I don't think this is really
important (only SpecialUndelete uses the respective methods).

PageArchive is responsible for maintaining backwards compatibility with
the old format.

Bug: T290021
Change-Id: I51179fa7707b5fc44d2257cc927edc0bd798a4d9
2021-09-27 15:41:45 +00:00
jenkins-bot
eaf10f600b Merge "Expand local URLs to absolute URLs in ParserOutput" 2021-09-27 14:48:02 +00:00
jenkins-bot
07f3f8053b Merge "UndeletePage cleanup, part 1" 2021-09-27 14:24:53 +00:00
jenkins-bot
5c570f46da Merge "Move code from PageArchive to a new UndeletePage command" 2021-09-27 14:22:05 +00:00
Daimona Eaytoy
bbcdb855c9 Check change tags permissions in DeletePage
Checking whether the given tags can be added is permissions-related, so
it should be checked in authorizeDeletion(). Not doing so means that the
caller has to do the check, but this wouldn't work well if the user is
not allowed to add the specified tags AND to delete the page: if tags
are checked before calling deleteIfAllowed(), the caller would
presumably die with a message like "cannot add tags", but it would
make more sense to die with a message like "cannot delete pages".

Also fix broken logic in DeletePage that, when the hook error was the
empty string, caused it to be converted to an array with a single
element (the empty string), and causing the deletion to fail without
errors if mergeLegacyHookErrors is true. This shouldn't be affecting
anything, since the deprecated WikiPage::doDeleteArticleReal sets
mergeLegacyHookErrors to false.

Bug: T288758
Change-Id: Iba51fcf38efbf3acd4f89de10e4221e00043c6ca
2021-09-27 12:38:20 +02:00
Umherirrender
769bdbf091 docs: Fix nullable documentation for class properties
Change-Id: I6d0577124d852103f485ffdc819876a13f6641c3
2021-09-24 00:54:53 +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
c0f64981bf UndeletePage cleanup, part 1
Bug: T290021
Change-Id: Idaf25a209a65b9a36a0a24473c76523ee3a17e8d
2021-09-21 18:13:57 +02: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
3370bb8750 Drop the ArticleUndeleteLogEntry hook
No known uses, deprecated in I00b4b1ae89606330e0a907c25bcd40d9c797bc84

Change-Id: Icb5c3fe188a7c771de8e2b225d7ca7f677cef0ce
2021-09-20 13:50:19 +02:00
DannyS712
f5072723e8 Deprecate the ArticleUndeleteLogEntry hook
So that it can be removed shortly - no known callers.
This should be backported to 1.37

Change-Id: I00b4b1ae89606330e0a907c25bcd40d9c797bc84
2021-09-17 22:00:53 +00:00
Daimona Eaytoy
0ef73ec13e Move some methods from FileDeleteForm to a subclass of DeleteAction
This is where the UI logic is supposed to live. The remaining methods in
FileDeleteForm will later be deprecated in favour of a dedicated command
object.

This patch tries to move the code to the new class with minimal changes,
with cleanup left to do for later.

Also change return typehints and docs for getFile(): WikiFilePage::loadFile()
is guaranteed to load a file. The "|bool" would confuse PHPStorm and
phan.

Note that FileDeleteForm is unused everywhere, except for some static
methods not touched by this patch.

Bug: T288282
Change-Id: I4fa1dfa096cd2ae7a58067764b12a275b1cce1d5
2021-09-17 22:13:19 +02:00
jenkins-bot
6b887d5e49 Merge "Deprecate WikiPage methods replaced by DeletePage" 2021-09-16 21:01:54 +00:00
Daimona Eaytoy
a8200aa5a8 Deprecate WikiPage methods replaced by DeletePage
Also remove the "@unstable" annotation from DeletePage.

Methods without known usages were hard-deprecated, the others
soft-deprecated.

Bug: T288758
Bug: T288759
Change-Id: I30c62572fd533526779a8ade3ab178f35bebb522
2021-09-16 20:17:45 +00:00
Petr Pchelko
2c2ffb0bef Move revert detection code from WikiPage to EditResultBuilder
WikiPage is not the right spot to compute all the revert
related stuff - we already figure out manual reverts when
building the EditResult, lets figure out rollbacks and undos
in there as well.

Change-Id: I9fdc5f24c1db1eb0452b90bf4af1ef5ffbce6cb8
2021-09-16 12:24:34 -07:00
jenkins-bot
76fdc1fc91 Merge "Deprecate and replace legacy hooks in DeletePage" 2021-09-16 18:39:29 +00:00
Daimona Eaytoy
377342de86 Deprecate and replace legacy hooks in DeletePage
In both cases the typehints were changed to the new interfaces. For the
ArticleDelete hook, the replacement has no $error param and requires the
caller to set a fatal status if it wants to abort.

Bug: T288758
Change-Id: I9540f6ab2075bcf56bd4fdc79c611c883246cdce
2021-09-16 19:13:35 +02: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
jenkins-bot
5af89e32c7 Merge "Emit deprecation warnings reading from $wgUser" 2021-09-16 15:27:44 +00:00
DannyS712
a2b20b63d7 Emit deprecation warnings reading from $wgUser
With this patch deprecation warnings will be emitted
if $wgUser is accessed or written into. The only pattern
of usage still allowed is

$oldUser = $wgUser;
$wgUser = $newUser;
// Do something
$wgUser = $oldUser;

Once there is no deprecation warnings, we know that nothing
legitimately depends on $wgUser being set, so we can safely
remove the code that's still allowed as well.

Bug: T267861
Change-Id: Ia1c42b3a32acd0e2bb9b0e93f1dc3c82640dcb22
2021-09-15 20:17:04 -07:00
jenkins-bot
a7e6a04334 Merge "Remove Title from signatures in CategoryViewer" 2021-09-14 19:04:18 +00:00
Aryeh Gregor
ceda8ac60e Remove Title from signatures in CategoryViewer
Co-authored-by: Daniel Kinzler <dkinzler@wikimedia.org>
Change-Id: Ie880482fe58b96809fdfd08ebf0825bdcf1d19d1
2021-09-13 16:14:06 +00: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
AntiCompositeNumber
5ab0ad50c7 ImagePage: Compare thumbnail bounding box sizes to bounding box size
Currently, ImagePage::openShowImage compares the actual size of the main
thumbnail to the bounding boxes of the additional thumbnail links to
exclude duplicate links. However, rounding on portrait images can mean
that neither the height nor width of the thumbnail exactly match the
bounding box size.

This patch adds an additional comparison between the main thumbnail
bounding box and the additional size bounding boxes. The comparison
between the main thumbnail actual size and the additional size bounding
boxes remains to prevent any edge cases on that end. It may be
redundant.

Bug: T272201
Change-Id: Ib947f4a3ee26a1f885c0f38014fa23aa218e6ebe
2021-09-10 21:52:53 +00:00
jenkins-bot
5a53d57449 Merge "LinkCache: soft deprecate addGoodLinkObj()" 2021-09-10 17:22:02 +00:00
jenkins-bot
7ece0e7afd Merge "Title: Make use of BacklinkCacheFactory service" 2021-09-10 14:31:23 +00:00
daniel
855988fd0e LinkCache: soft deprecate addGoodLinkObj()
addGoodLinkObj() has many optional arguments, but omitting them actually
means corrupting the cache.

Nearly all existing callers are in tests.
So LinkCacheTestTrait::addGoodLinkObject() was created only
for testing. It is better to have this method in the
trait, because building the row directly in each test
would make these tests brittle against schema changes.

The only usage in WMF production code was in WikiPage and has been
fixed.

Bug: T284955
Change-Id: I03a2bd9ed64fcc0281ee29a286c8db395a9e03d9
2021-09-10 16:00:02 +02:00