Commit graph

91 commits

Author SHA1 Message Date
Tim Starling
960a7925ae Add hook UserEditCountUpdate
Add a hook which runs at the end of UserEditCountUpdate. The idea is to
allow CentralAuth to keep its own similar edit count. There's no
other hook appropriate for this purpose since
UserEditTracker::incrementUserEditCount() has multiple callers.

Convert the private associative array in UserEditCountUpdate to a class.
Instances of the class are passed to the new hook. A class is better
suited to a public interface.

Bug: T300075
Change-Id: I16a92e6a6e9faf1be4c7fbe25354a08559df163d
2022-01-31 17:00:49 +11:00
Tim Starling
d7cb90dc5e Add a ParserModifyImageHTML hook for PageImages
PageImages is expensively loading and reparsing the lead section during
LinksUpdate because the parser's image link hooks do not give enough
context to tell whether the image is in the lead section.

So, add a hook which allows PageImages to add a marker to image links.
The marker can be associated with the section number in ParserAfterTidy.

Bug: T296895
Bug: T176520
Change-Id: I24528381e8d24ca8d138bceadb9397c83fd31356
2021-12-15 15:33:16 +11:00
C. Scott Ananian
4a04259070 Rename variables to disambiguate OutputPageParserOutput hook
It can be difficult to distinguish between ParserOutput and OutputPage
values, since both are often named $out or $output.  Use more
distinctive variable names to make it easier to read the code (and use
code search) for uses of the OutputPageParserOutput hook, where both
types are present in close proximity.

See T293860 for an instance of this confusion biting us in production,
and I386e99df01f889a80de26e861142bdb606aa649d for a related tidying-up
in Wikibase.

Change-Id: I0ccb7484eb3b2e2ae6a5a85c3e08d7d48b1e6146
2021-11-23 15:50:01 -05:00
Petr Pchelko
164ec5cb29 UserOptions: remove deprecated hooks.
After the hooks were removed we are finally ready to stop
reading user options from primary before writing them on save.
The new save hooks only work on modified options, so options
saving code can be significantly simplified.

Change-Id: I48df616c9f35d9a0b2801ada1b7dbef0bd4ad058
2021-10-26 12:55:01 +00:00
jenkins-bot
5535b42559 Merge "Add SpecialExportGetExtraPagesHook" 2021-10-11 22:00:33 +00:00
Cindy Cicalese
37a9e60ca5 Add SpecialExportGetExtraPagesHook
This hook allows extensions to add additional pages to the list of
pages being exported. For example, if an extension creates supplemental
pages that must be exported along with a content page, this hook will
allow the extension to export the supplemental pages automatically when
the content page is exported.

Bug: T292378
Change-Id: I3b6b466b6ed32b1939674872df9e431bd6941645
2021-10-04 10:33:04 -04:00
Daimona Eaytoy
e021602204 Remove UndeleteForm::undelete hook
Bug: T290021
Change-Id: If684bd5967825591cc3e21243e23a73e06da2179
2021-09-30 22:20:23 +00: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
DannyS712
20aa78f213 Drop deprecated BeforeResetNotificationTimestamp hook
Deprecated in 1.37 and unused

Allows a bunch of cleanup for WatchedItemStore.

Bug: T271715
Change-Id: I328cf49c3e85da2069b620f8c63670d93608a784
2021-09-21 23:09:18 +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
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
6e4a17b1be Remove PHPUnit hooks
Now unused: https://codesearch.wmcloud.org/search/?q=onMediaWikiPHPUnitTest__(end%7Cstart)Test%7CMediaWikiPHPUnitTest%3A%3A(end%7Cstart)Test&i=nope&files=&excludeFiles=&repos=

Bug: T243600
Change-Id: Ie41fc026e6db6b9c9f5ec659e3ce8c27727cd3fe
2021-08-30 00:28:32 +02:00
jdlrobson
dc15f6caa1 SkinTemplateToolboxEndHook is removed
Deprecated in 1.35, removed in 1.37
Existing skins using the hook will not necessarily
break as many of the skins run their own version of the hook.

Extensions using the hook will no longer output links
to the toolbox in the sidebar.

Bug: T256511
Change-Id: I1ba018ced266ac27f3e038ba9102ab54a669df81
2021-08-05 15:45:29 +00:00
Bartosz Dziewoński
6d361d61bd Add a hook 'GetActionName' to allow overriding the action name
The use case is to change action=edit into action=view in some
scenarios where we want to offer a more limited interface or a
gentler introduction to editing than MediaWiki provides, for example
I2e7b2682da7beb3c1c469bb784a9a8ec3998aeb9 in DiscussionTools.

Bug: T282204
Change-Id: Ib9302e2fda7dadf1edc43c0107db7234eb4bdf7a
2021-08-02 09:44:27 -05:00
Ammarpad
2e10b1b46c Remove SkinTemplateOutputPageBeforeExec Hook
Bug: T287773
Change-Id: Ieac3ca6a37c7991284851d6124febde0db8bb198
2021-07-30 22:31:27 +01:00
Clare Ming
91cc5389a3 Remove BaseTemplateToolbox hook
Bug: T256509
Change-Id: I9bc4e35e4062a6e77da66de46d0199be583c9d9a
2021-07-28 15:40:49 -06:00
TChin
c9861afba6 Adjust method signature of onSaveUserOptions
This allows hook callers to compare before and after the save

Bug: T287397
Depends-On: I20098ae076b282296670d1116e14bbd29ea76b11
Change-Id: I4d09008bc2bc10afc3742b74564e5ef90ecfe5bf
2021-07-26 21:18:21 +00: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
Roman Stolar
a9e35df62a Remove deprecated hook 'SecondaryDataUpdate'.
Bug: T232878
Change-Id: I4a795436e560a19c8918177edeb3c792eeb9dd72
2021-07-21 17:36:24 -07:00
Petr Pchelko
b27d33cc5c Introduce new hooks for UserOptionsManager
Bug: T286576
Change-Id: Ib960ec594d376e086da868d216dd85c8ea6bba14
2021-07-21 06:20:54 -07:00
Petr Pchelko
691b128efb Remove deprecated ArticleEditUpdates hook
Change-Id: If3487ab495306ea4afef30398690a6bbeabc9ce4
2021-07-20 17:32:44 -07:00
jenkins-bot
46d60bc8d2 Merge "Add warning to MediaWikiServicesHook interface." 2021-07-12 18:15:16 +00:00
daniel
9877b671fd Add warning to MediaWikiServicesHook interface.
Hook handlers for the MediaWikiServicesHook must not use services,
since the service container is not fully initialized when the hooks is
called. This is by nature of the hook itself, which exists to allow
configuration and wiring to be manipulated.

Depends-On: I1519aea8bca2f3977fcf15ee8776a1b3319687b5
Change-Id: Ifbc60e72167e5280e3609d14a47ffa6232fabca6
2021-07-02 22:11:19 +02:00
Sam Smith
3bcf989f72 hooks: Remove deprecated SkinTemplateBuildNavUrlsNav_urlsAfterPermalink hook
The SkinTemplatePreventOtherActiveTabs hook was marked as deprecated in
MediaWiki 1.35.

Bug: T284950
Change-Id: I9a4806047f8d31d59a00e02145906672b85c004c
2021-06-24 17:25:46 +01:00
Sam Smith
a11aceb214 hooks: Remove deprecated SkinTemplateTabAction hook
The SkinTemplateTabAction hook was marked as deprecated in MediaWiki
1.35.

Further, there are no SkinTemplatePreventOtherActiveTabs hook handers in
codebases that we index [0].

[0] https://codesearch.wmcloud.org/search/?q=SkinTemplateTabAction

Bug: T284950
Change-Id: I998bf8ffe6be43ad3eb38b1a9388a35aa94d7685
2021-06-24 17:25:15 +01:00
Sam Smith
99786a9492 hooks: Remove deprecated SkinTemplatePreventOtherActiveTabs hook
The SkinTemplatePreventOtherActiveTabs hook was marked as deprecated in
MediaWiki 1.35.

Further, there are no SkinTemplatePreventOtherActiveTabs hook handers in
codebases that we index [0].

[0] https://codesearch.wmcloud.org/search/?q=SkinTemplatePreventOtherActiveTabs

Bug: T284950
Change-Id: I37c5bdcc8875a23798f641161e53be3e4d073d7d
2021-06-24 17:24:39 +01:00
DannyS712
9435fd1303 Remove the TitleArrayFromResult hook
Hard deprecated in 1.36, unused
Note that this is separate from the TitleArrayFromResult class

Change-Id: I7cc2176c386529061fa6bd590ab9d60a86b064ba
2021-06-02 13:48:30 +00:00
DannyS712
40eda16b0e Remove deprecated talk page message handling in User class
Most needed for moving forward with the removal of uses
of the Revision class, and remove User::getNewtalk at
the same time to be consistent. All of this code was
already hard deprecated in 1.35.

- User::getNewtalk
- User::getNewMessageLinks (could return Revision objects)
- UserRetrieveNewTalks hook (could return Revision objects)
- User::getNewMessageRevisionId (used ::getNewMessageLinks)
- User::setNewtalk (accepted Revision object parameters)

Bug: T247143
Bug: T277511
Change-Id: Ib4fd1e4cbc5ba1497658190b6c6ea3c6a5dc97f0
2021-05-04 19:21:06 +00:00
DannyS712
c6216377bb Remove deprecated https-related hooks
All hard deprecated in 1.35
* BeforeHttpsRedirect
* CanIPUseHTTPS
* UserRequiresHTTPS

Also soft deprecate the wfCanIPUseHTTPS
method, which always returns true. Will
be hard deprecated once callers are updated

Change-Id: Ie6d71809d09edf6be9b8280debeb152ef7fce398
2021-04-30 11:53: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
STran
df89e2fb49 Add GetAllBlockActions hook
Call onGetAllBlockActions to add to the blocked actions array.
This allows extensions to define blockable actions.

Bug: T279562
Change-Id: Ia72fdabba1dcca0e2f71e4c09400453295f0e05c
2021-04-28 08:59:18 -07:00
James D. Forrester
f6667ab415 Remove ArticleEditUpdatesDeleteFromRecentchanges hook, deprecated in 1.35
Also move RC purging code.

Bug: T244613
Depends-On: I743b764ccd031df448cfac31a9bba3c60442d250
Change-Id: Ib455501c266f8482f56d08041de0f5beba651a0b
2021-04-21 14:38:59 -07:00
jenkins-bot
d09e9812fc Merge "Allow hooking into shell and eval maint scripts for convenience" 2021-03-18 04:03:31 +00:00
jenkins-bot
7f907d657d Merge "OutputPage: Mark MakeGlobalVariablesScriptHook as void and improve docs" 2021-03-15 06:48:56 +00:00
Timo Tijhof
7d41328cc2 OutputPage: Mark MakeGlobalVariablesScriptHook as void and improve docs
No extension is meant to be able to prevent other extensions from
using this hook. Incidents of that have only been accidents.

Change-Id: I048e3ac4a6a6889fc55681b8d49d6fd433e8b3fc
2021-03-14 06:39:24 +01:00
jenkins-bot
14059be192 Merge "Add list of thumbnail urls to LocalFilePurgeThumbnails hook" 2021-03-12 16:35:14 +00:00
addshore
d873fa15a2 Allow hooking into shell and eval maint scripts for convenience
First intended use in I11bc2b4b43a1eb0578be50a47485e233e15d8dba

Change-Id: I14e58d5f125236f9a95823c25a78a9ebab28fd17
2021-03-12 14:18:09 +00:00
Umherirrender
4469addf9e Fix documentation for hook error in UserCanSendEmailHook
Use the documentation for EmailUserPermissionsErrorsHook,
because both are called with the same argument on SpecialEmailUser

Rename variable to match all usages

Change-Id: Ie1f4a9ad15da3818632141b84b3dfdf6aa4f076c
2021-03-09 00:16:12 +01:00
C. Scott Ananian
0676256ccc parser: new BeforeParserFetchTemplateRevisionRecord hook
This new hook provides for the use case in T47096 (allowing the
Translate extension to transclude a page from another language) by
adding a new hook which would let us deprecate and replace two awkward
legacy hooks (one with an embarrassing capitalization issue).  The new
hook is a little more tightly scoped in terms of what it allows and
gives access to, and it uses the new RevisionRecord API.

In addition, the new hook uses LinkTarget instead of Title per
current best practices. (PageIdentity is not appropriate for
reasons documented at the hook invocation site.)

The original BeforeParserFetchTemplateAndtitle (sic) hook allowed
redirecting the revision id of a template inclusion, but not the
title. The only known current use is Extension:ApprovedRevs; the
FlaggedRevs extension replaces the entire function using
ParserOptions::setCurrentRevisionRecordCallback().

Extension:Translate would like to redirect the title as well, possibly
recursively (for a limited number of hops) to handle fallback
languages.  That is, when invoked on Foo/fr, including Template:Bar
would redirect to Template:Bar/fr -- and, if that doesn't exist, then
Template:Bar/fr would redirect to its fallback language, say
Template:Bar/en. It uses the top-level page title as context to set
the desired page language.  This would require 2 invocations of the
hook; we've set the recursion limit to 3 to provide a little bit
of future-proofing.

The hook added in this patch uses RevisionRecord instead of int
$rev_id, and thus can handle the case where the redirect is to a page
which doesn't exist (by setting the RevisionRecord to a
MutableRevisionRecord with the correct title and no main slot content)
in the fallback language case above.

The new hook deprecates BeforeParserFetchTemplateAndtitle and replaces
ParserFetchTemplate as well (deprecated in 1.35).  Code search:

https://codesearch.wmcloud.org/search/?q=BeforeParserFetchTemplateAndtitle&i=nope&files=&repos=

Bug: T47096
Change-Id: Ia5b5d339706ce4084c16948300e0e3418b11792e
2021-02-05 09:37:32 -05:00
brandonxlf
1262ca1897 Use OOUI for protection form
Breaking changes:
  * Ids 'mwProtectSet', 'mw-protect-table3', and
    'mw-protect-table-$action' are no longer present on page.
  * Module 'mediawiki.legacy.protect' has been removed and replace by
    'mediawiki.action.protect'.

Deprecations:
  * ProtectionForm::buildForm has been replaced by
    ProtectionForm::addFormFields with backwards compatibility.

Other changes:
  * Expiry is no longer editable when "Allow all users" is selected
  * When "Unlock further protect options" is disabled, the expiry of
    the first section is used for the other sections
  * Legacy form elements added by extensions are added to a separate
    section which uses a blank i18n string as the header
  * Unprivileged users see the expiry selector instead of the expiry
    text input as it has the expiry date

Changes to ProtectionForm.php are based off of
I95d0289acceaa7ede789d5a6ea094fae757af6dc.

Bug: T235424
Bug: T236218
Change-Id: Ib22a3b53c1933e107ef5609bb2262aa44b5abb7a
2021-01-30 00:19:02 -05:00
C. Scott Ananian
8fe7e1d26a Add new ArticleParserOptions hook
This hook allows discussion tools to toggle a parser option based on
artice title (namespace) and user identity.  In particular, it sets a
flag to generates reply links (a) on talk pages (b) if the user's
preferences opt in to discussion tools.  Other extensions may also
wish to be able to customize article parsing based on title or user.

Change-Id: I883a37fd67108243e7a20683b1a5d59fd0f6e39f
2021-01-05 11:17:32 -05:00
Ostrzyciel
b25d48ea03 Add hook to Linker::generateRollback()
Add a hook that would allow extensions to modify the default
rollback link in MW's interface.

Bug: T252518
Change-Id: Ia6920e601a4b9433f4083a386ff35f5478dc4e3c
2020-12-06 20:44:34 +01:00
Reedy
e141c9eade Add list of thumbnail urls to LocalFilePurgeThumbnails hook
Bug: T268310
Change-Id: Iaa84edfe215e71d3d5fd814053d4b787652fa3b5
2020-12-05 21:58:43 +00:00
daniel
afb3d6a504 ArticleViewHeaderHook: fix order of parameters.
onArticleViewHeader() had the parameters reversed. The new parameter
order is consistent with how the method is called in Article, and also
with existing hook handlers in extensions like Scribunto, SMW, Memento,
etc.

Change-Id: Iaf9e879211098c5ab3a706020c364ceee48237cf
2020-11-05 11:16:50 +01:00
jenkins-bot
229bb3f2ab Merge "Add forgotten import hook interface" 2020-11-02 22:56:50 +00:00
Petr Pchelko
f11ed7e46f Add forgotten import hook interface
When making primitive tests for HookRunner in
I8d0a34e185aad79a391acdd47e506c8911c75257 I've
notived that coverage was not 100% and found that
this hook interface was forgotten.

Change-Id: Ic877fd1f2bbac5a1af708f283e9e0b7a49f89d88
2020-11-02 08:17:34 -07:00
shubham656
6c7991b989 Make SpecialMuteModifyFormFields hook to not pass the entire special page
Bug: T257183
Change-Id: I7af57455d412dc5e93617ca0b3d6e7aac8ef500f
2020-11-02 02:31:19 +05:30
Daimona Eaytoy
0739abc372 Add typehints to three hooks
The handlers for these have been typehinted in AbuseFilter for quite a
long time, but switching to the new system requires removing them, see
If699917c3d2e9e22525c7d0495554e25f6b45125. Note that this change
preserves BC.

Change-Id: I95bb47104ad3dc0a69c812c627ffa631c5dc6ace
2020-10-07 11:20:55 +00:00
jenkins-bot
2cbf3de509 Merge "Remove ParserBeforeStrip/ParserAfterStrip hooks, deprecated in 1.35" 2020-09-23 09:26:01 +00:00
jenkins-bot
d652917452 Merge "resourceloader: Use a local HookRunner" 2020-09-21 21:45:09 +00:00