Commit graph

1206 commits

Author SHA1 Message Date
Thalia
bf5464614b Deprecate the GetBlockedStatus hook
This was replaced by GetUserBlock in 7a5508573a.

Handlers in production were updated to use GetUserBlock in
I952aa7d40 and Ibbcd3a239.

Bug: T229035
Change-Id: I95f9fabc6e795243cfe0a1e8737ca6abfb865538
2019-09-09 23:29:25 +01:00
Thalia
af24fc1a7a Deprecate the UserIsHidden hook
This was replaced by GetUserBlock in 7a5508573a.

Handlers in production were updated to use GetUserBlock in
Ibbcd3a239.

Bug: T228948
Change-Id: I3e6da73e595e2bd6a96600fe2a6dc68a54d06a2e
2019-09-09 20:31:02 +01:00
Jack Phoenix
495f9fa290 resourceloader: Add $conf parameter to the 'ResourceLoaderGetConfigVars' hook
Change-Id: I3cca8ce87b303ef7dfd96bfe1fdda0c51c441f6f
2019-09-07 15:30:40 +00:00
Huji Lee
0a611b47a8 Skin: Add new hook, UndeletePageToolLinks, for Special:Undelete views
This allows extensions to add further links; the particular use case
in mind is for the AbuseFilter extension, but others may want this
too.

Bug: T231055
Change-Id: I671a0479e877e6c37606b688064cb9c893717709
2019-08-23 20:51:21 +00:00
Thalia
7a5508573a Ensure block hooks keep user state consistent with realistic blocks
Several block-related hooks allow the user to be put into in a state
that is inconsistent with blocks that can actually be made:
* With UserIsHidden, User::mHideName can be set to true without there
  being a block
* With UserIsBlockedFrom, a user can be blocked from editing a page
  without there being a block
* With GetBlockedStatus, public block properties can be arbitrarily
  set on a user

These problems are mostly theoretical, but mean that it is impossible to
make some basic assumptions, e.g. that a user who is blocked from a page
must have a block. The hooks are not widely used, and with a few changes
we can make them more robust so such assumptions can be made.

This patch:
* Ensures UserIsBlockedFrom is only called if there is a block. This
  would be a breaking change if any extensions were using this to block
  an unblocked user; the intended use case is clearly for extensions to
  allow user talk page access to blocked users.
* Adds a new hook, GetUserBlockComplete, which passes the block for
  modification. This should be used instead GetBlockedStatus and
  UserIsHidden, which will be deprecated in the future.
* Allows the 'hideName' option to be passed into the AbstractBlock
  constructor so that suppressing system blocks can be made.

Bug: T228948
Bug: T229035
Change-Id: I6f145335abeb16775b08e8c7c751a01f113281e3
2019-08-21 17:38:52 +01:00
jenkins-bot
0f80b077fc Merge "Add instrumentation to Special:Mute" 2019-08-20 17:34:29 +00:00
DannyS712
b01fbfeb40 hooks.txt: Convert docs to modern extension registration style
This changes the examples in hooks.txt from using the old format of
manually entering additions into `wgHooks` to instead use the new
`"Hooks“: {}` object format.

Bug: T230397
Change-Id: I48a9986e4243eb933088d36b4bb095b345ab62fd
2019-08-20 13:56:40 +00:00
Dayllan Maza
db4aaa1a3e Add instrumentation to Special:Mute
We are already tracking pageviews and with following change we should be able
to answer the following questions:
* Of the users who land on this page, what percentage of users actually
  mute or unmute someone
* Of the users who mute a user, which option(s) did they check/uncheck in order
  to mute/unmute the user

EventLogging Schema: https://meta.wikimedia.org/wiki/Schema:SpecialMuteSubmit

Bug: T224958
Change-Id: I655dbd999fd5d3d8f792c4f53b7cc502fe05afd5
2019-08-19 15:18:11 +00:00
jenkins-bot
4001c3892c Merge "Add ISearchResultSet" 2019-07-22 22:11:09 +00:00
jenkins-bot
d1f681a77d Merge "ChangesList: Add $groups parameter to FetchChangesList hook" 2019-07-22 21:45:41 +00:00
jdlrobson
d7f8c45856 ChangesList: Add $groups parameter to FetchChangesList hook
This parameter is needed for consumers trying to return a $list object.

Bug: T228280
Change-Id: Ib68ff8fa782ac12479ef02247cdf78e405b64bad
2019-07-22 21:31:40 +00:00
David Causse
6af636fb03 Add ISearchResultSet
Bug: T228626
Change-Id: I3306bf6107c97dd58adf578fd965bd11a422627d
2019-07-22 18:27:39 +00:00
James D. Forrester
714797861b Drop the UploadVerification hook, deprecated in 1.28
Change-Id: Ic1917fc95223cbf97845c2702ddf98accf8ba9c2
2019-07-19 13:50:13 -07:00
Dayllan Maza
b5f384f943 Add support for extentions to change Special:Mute form
The hook (SpecialMuteModifyFormFields) is used to append
the option to mute/unmute notifications from a specified user.

Special:Mute handles posting and saving the fields, the only
requirement is that the field name is the same as the property
that wants to be modified.

Currently there are only two notifications "blacklists":
* `email-blacklist` is directly handled in this page 'cause it is part of core.
* `echo-notifications-blacklist` is part of Echo, so this change is required
  to support it. See I77b3ccfdce9b501e

Bug: T220163
Change-Id: I2b3eee0802cb086091f35ecce13ae77a8e7d518d
2019-07-18 15:21:00 +00:00
jenkins-bot
a76cc0bf39 Merge "Remove $purgeBlobs parameter from LocalisationCacheRecache hook" 2019-07-16 00:13:53 +00:00
Roan Kattouw
cac26b713c Remove $purgeBlobs parameter from LocalisationCacheRecache hook
No longer allow hook functions to prevent message blobs from being
purged. Pass in an always-true variable for backwards compatibility,
which is then ignored.

Change-Id: I27ac9599711f2f0df2514a3934270af0ce03da7f
2019-07-15 15:32:03 -07:00
James Montalvo
8e28a4b8b8 Add ImgAuthModifyHeaders hook to img_auth.php to modify headers
Change-Id: I3c6fd7b0c39d7fd52c484494233241093d152f88
2019-07-15 21:50:48 +00:00
James D. Forrester
f3dbb9ce93 Drop ChangePasswordForm hook, deprecated in 1.27
Change-Id: Ia9281596e0d620b360ccd6cb7392d9516b9240b8
2019-07-12 10:41:01 -07:00
RazeSoldier
b95a76ae9e Drop APIEditBeforeSave hook
Removed the source code and the test code.

Bug: T220656
Change-Id: I3674da6d9c33c08ec2f1774cb793b3a952480571
2019-07-02 02:58:47 +08:00
jenkins-bot
8f8374204e Merge "Add support for xml dump schema 0.11" 2019-06-28 04:23:58 +00:00
daniel
fdc3e9f952 Add support for xml dump schema 0.11
Bug: T174031
Change-Id: I2717019ea7efe36694bd2b2fba4dc2952a987cfc
2019-06-27 21:56:01 +00:00
David Causse
92c20832f1 Deprecate SearchResult::termMatches()
And start indicating that hooks relying on this data might become
unreliable as this data is only populated by SearchDatabase search
engines.

This information was only populated by SearchDatabase implementations
and due to bad initial design of SearchResult[Set] (now fixed) it forced
users of these classes to carry this information for the sole purpose of
highlighting.
Because SearchEngine can now own their SearchResult[Set] implementations
nothing that is engine specific should be exposed outside of these
specific implementations.
If there are some logic that still requires access to such list of terms
they should be made engine specific by guarding their code against
instanceof SqlSearchResult.

Change-Id: I38b82c5e4c35309ee447edc3ded60ca6a18b247a
Depends-On: I53fe37c65c7940f696c1e184125e01e592a976e4
2019-06-27 08:44:06 -07:00
James D. Forrester
06a34d5895 Drop the UserLoadFromSession hook, deprecated in 1.27
Change-Id: Ic86d9ee1fe6763270e79e31296ecd027e5d41be2
2019-06-24 14:12:33 -07:00
James D. Forrester
614f15682c Drop the UserRights hook, deprecated in 1.26
Change-Id: Ib4dc6f495c0d1d2aa1f41c1f61e09437f33c9077
2019-06-24 11:11:17 -07:00
Umherirrender
9421f6f52f Fix param type of search terms in search related classes
Change-Id: I036434268f1e7992f7f9f23d2c1c0fcd399823c8
2019-06-14 19:50:12 +02:00
Umherirrender
8a14f73a64 Document $rows on hook ChangesListInitRows as IResultWrapper
Change-Id: I243b460c4788a2bee095cb76b76106577f06b96f
2019-06-03 21:35:51 +02:00
Thiemo Kreuz
177211eb28 docs: Fix UploadVerifyUpload/UploadStashFile hook docs
1. FSFile::getPropsFromPath() is not used by any code any more.
https://codesearch.wmflabs.org/search/?q=FSFile%3A%3AgetPropsFromPath&i=1
The only remaining usage is in one test. We might as well remove the
function.

2. The $props array is passed to the hook for convenience, in case all
the file properties are already available. Fetching them from a file on
disc can be an expensive operation, and should be avoided if the
information is already available. But the caller does not guarantee this
is set. Other callees already know this can be a falsy value, notably
LocalFile::upload().

Change-Id: I43724d18467b6fb68a963b2206332cf553c81b2c
2019-05-18 08:38:20 +02:00
Niklas Laxström
855b1794b6 Unstub $wgLang for PageContentLanguage hook
This is to avoid annoying fatal errors when someone annotated their
hook handler to only expect Language objects, but that expectation
is violated due to this code possibly passing StubUserLang to hooks,
some of which may also assign it to $pageLang.

Even with this in place, it is probably a good idea for hook handlers
to refrain from type hinting parameters that are passed by reference
because their types cannot be guaranteed.

Bug: T214358
Change-Id: I88405a8de4b13675eb5a9d11e9ddc87e20a85fb4
2019-05-16 18:49:53 +02:00
Fomafix
f0483b35c7 Remove parameter 'options' from hook 'SkinEditSectionLinks'
The generated links are now always known links.

All users of the hook 'SkinEditSectionLinks' in extensions set
'options' => [ 'noclasses', 'known' ]
5f48eb9acd/TinyMCE.hooks.php (291)
857c1bd3d1/includes/VisualEditorHooks.php (617)

This change makes it easier to migrate to LinkRenderer in
Ifc170abc958add28a2fe08aa0c44af83c6f7cad8 without legacy options.

Change-Id: Ia5d151b81dabce9560045b45886f2c77abf975da
2019-05-03 15:01:57 +02:00
Aaron Schulz
2775ad190c rdbms: drop inappropriate and poorly documented "DatabaseOraclePostInit" hook
Change-Id: I3152e80d99b040b7918927e6c2a215cab59a9b10
2019-04-12 14:41:44 +00:00
Aryeh Gregor
76661cf129 NamespaceInfo service to replace MWNamespace
MWNamespace::clearCaches() has been removed entirely, along with the
$rebuild parameter to MWNamespace::getCanonicalNamespaces(). The rest of
MWNamespace is deprecated.

Diff best viewed with -C1 so git notices that NamespaceInfo is a copy of
MWNamespace.

Depends-On: Icb7a4a2a5d19fb1f2453b4b57a5271196b0e316d
Depends-On: Ib3c914fc99394e4876ac9fe27317a1eafa2ff69e
Change-Id: I1a03d4e146f5414ae73c7d1a5807c873323e8abc
2019-04-10 02:07:36 +00:00
jenkins-bot
a38af7ba26 Merge "Improve docs for Title::getInternalURL/getCanonicalURL" 2019-04-07 17:25:33 +00:00
Lucas Werkmeister
187b1d48b3 Add &$tags argument to MarkPatrolled hook
This will allow the OAuth extension to subscribe to this hook and add an
“OAuth CID: $consumerId” tag to patrols made via OAuth.

Bug: T219655
Change-Id: Ie5e6f820bbf399ec639e715afd908f78bf5c8e9a
2019-04-01 10:10:34 +02:00
Bill Pirkle
4d5edb65f3 Allow extensions to add params to the update.php maintenance script
T110209 caused maintenance scripts to fail on unknown parameters,
which is normally desirable.  However, some extensions (notably
SemanticMediaWiki) need to support additional params and had no
way to add them to the list of expected parameters.  It will
now be possible them to update.php via a new hook:
MaintenanceUpdateAddParams.

Bug: T213893
Change-Id: Ia40949ccb2f32090f21e0f3f7e5b9c4aef322330
2019-03-26 21:12:49 -05:00
jenkins-bot
28b8d632ad Merge "docs: Update outdated PageContentSave hook documentation" 2019-03-25 06:40:12 +00:00
Piotr Miazga
384ab964cd Define ManualLogEntryBeforePublish hook
This hook is required by extensions like MobileFrontend to tag
log entries when actions are performed on the mobile web.

There is a possibility to tag log entries by using
'RecentChange_save' hook, but that works only when the log entry
is published to 'rc' or 'rcandudp'. This means, that tagged log
will appear also on the Special:RecentChanges page which is something
what extensions like 'Thanks' wants to avoid.

In the future we should avoid using 'RecentChange_save' as an
indirect way to tag log entries, and use the
'ManualLogEntryBeforePublish' hook instead.

To cover ourselves in the future, instead of passing &$tags only,
we pass the $this (the log entry object) so extensions can perform
additional checks before using setTags().

Bug: T215675
Change-Id: I747eded4bc5406cd5d4676fc93b0bb55c99f9a4d
2019-03-19 00:49:53 +01:00
Umherirrender
febf5f7a15 Improve docs for Title::getInternalURL/getCanonicalURL
Both calling fixUrlQueryArgs, which handle the array case
Also improve hooks docs for the similar functions getLinkUrl/getLocalUrl

Change-Id: I77df39711c7d6b2ee0a3709a6bdaf9cde6a616c6
2019-03-15 18:56:04 +01:00
jenkins-bot
787da207a2 Merge "Improve documentation of the PageContentLanguage hook" 2019-03-12 07:33:57 +00:00
Niklas Laxström
a08fc9eed6 Improve documentation of the PageContentLanguage hook
Clarify that the type of second parameter that is being passed
to the hooks can be anything because one hook can change it and
then it is passed to another hook without the hook caller having
possibility to check or modify the value.

Clarify that hooks should only return Language objects.

Rename $wgLang to $userLang in the hook parameter documentation to
avoid false posivite matches for the global.

Fix some typos, use Title::inNamespace and add a test assertion.

Also, the $content parameter is unused by all implementations of
this method, and on quick look never passed by any caller. I kept
it for now, however.

Bug: T214358
Change-Id: Iae49d2998c2b762565d232c0337d84d43a4a900c
2019-03-12 08:05:59 +01:00
James D. Forrester
3f717984c1 Drop AuthPlugin and related code, deprecated in 1.27
Bug: T215843
Depends-On: Ie49709faa6f67b0a31bd546823d29dbfea0a70eb
Depends-On: If8109dbfdeeb88a6265f4cd79d1ae81bff48d934
Depends-On: I36b195fa2d6c23a76631ebaf869c787e44427d60
Depends-On: Iaa171b085fde331eab7d85c7de74523e27fc625a
Change-Id: I330b30d6582034a233fed204c0680b1ce84eec6e
2019-03-05 08:23:14 +00:00
Roan Kattouw
10f7497eab Add UserSendConfirmationMail hook
Allow extensions to modify the confirmation email.

Bug: T215665
Change-Id: I4bcf76699a5114292fc19085fe441de8b898a8d3
2019-02-27 16:44:43 -08:00
Thiemo Kreuz
0df33031fa docs: Update outdated PageContentSave hook documentation
I updated https://www.mediawiki.org/wiki/Manual:Hooks/PageContentSave
already.

Inspired by Id8f2ac2.

Bug:  T216893
Change-Id: I41a310c04be37693c1ba3f8ce15d1405674c1eae
2019-02-26 14:15:35 +01:00
Timo Tijhof
d1666a89ff resourceloader: Support TestModules registration via extension.json
Bug: T126091
Change-Id: I27ecebe27d7aaebe6d1317bc5eaea9cca368b45d
2019-02-05 15:27:37 -08:00
Timo Tijhof
5b02c8e3a0 maintenance: Fix detection of bad hooks (wfRunHooks -> Hooks::run)
It was still looking for wfRunHooks, which no longer exists
as of MediaWiki 1.32.

After this, it is now able to find one bad hook:

> Unclear hook calls:
> - Hooks::run( $action . 'ArticleComplete', [ .. ] ); # SpecialEditWatchlist

Also, remove the matching of wfRunHooks generally, given it no
longer exists. And also remove the historic notes from hooks.txt.

Change-Id: I4ac52ed75fb99d7775d4b4755e3f0871003d70a8
2019-01-10 11:33:10 -08:00
Gergő Tisza
07a27f19cf Include bot password app ID in audit data
Authentication audit logs should indicate whether a login is via the
normal password or a bot password (and which one). For failed logins
it could be included in the error message, and it usually is, but
for successful ones there is no message, so we'll send the app ID as
a new AuthManagerLoginAuthenticateAudit parameter.

Bug: T194338
Change-Id: I8aab48177b81a8e80dae118e6476a8f6a32089f1
Depends-On: Id482d2e2205960a0facd334e456d3a23bcad0ece
2018-12-13 19:18:17 +00:00
Krinkle
4b275c60de Revert "Pass $context to 'GetPreferences' hook"
This reverts commit d685694594.

Change-Id: I1e9299b8fdc4727895fdac60f04cc5dfa4d09b7a
2018-12-10 02:58:59 +00:00
Daimona Eaytoy
495331ff07 Add a Status and a $reason parameter to TitleMove hook
So that using this hook it's possible to prevent the move, also
providing some more context.
Also, clean error message: instead of going with "you do not have
permission blah blah" for *every* kind of error, use it only when the
error is actually about permissions, and use a generic message
otherwise.

Bug: T208907
Change-Id: I4733724075b7514e9db59e7be772d9409aa9da87
2018-11-13 08:51:02 +00:00
jenkins-bot
a63c458127 Merge "Pass $context to 'GetPreferences' hook" 2018-11-01 04:00:23 +00:00
James D. Forrester
77ddd5faf0 Drop the LanguageGetSpecialPageAliases and LanguageGetMagic hooks
Deprecated since 1.16 and unused in known git.

Bug: T199291
Change-Id: Idcaf1b2c24c64653f700be4fe810ed124ba4ab7c
2018-10-29 15:09:20 -07:00
James D. Forrester
36ec0c6984 Drop six authentication-related hooks, deprecated in 1.27
AbortAutoAccount, AbortNewAccount, AbortLogin, LoginUserMigrated,
UserCreateForm, and UserLoginForm are all unused in Wikimedia
production and rare in other extensions.

This also scraps the FakeAuthTemplate and LoginForm classes and
the occasional remainig references thereto.

Bug: T193755
Change-Id: I24d6fa963f402d4311fa00fc11536a37ee3bd31e
2018-10-29 15:02:06 -07:00
Brad Jorsch
afe9a0fa5b Remove use of old API doc methods
The following deprecated methods, intended for overriding by extensions,
are no longer called and are hard deprecated.

* ApiBase::getDescription() (deprecated in 1.25)
* ApiBase::getParamDescription() (deprecated in 1.25)
* ApiBase::getExamples() (deprecated in 1.25)
* ApiBase::getDescriptionMessage() (deprecated in 1.30)

Also, the 'APIGetDescription' and 'APIGetParamDescription' hooks have
been removed, as their only use was to allow extensions to override
values returned by getDescription() and getParamDescription(),
respectively.

Change-Id: I486c4ccab4eca6a85cb17c30dbb2439876123ba1
2018-10-29 14:58:19 -07:00
jenkins-bot
f03d31af05 Merge "resourceloader: ResourceLoaderGetConfigVars is passed skin" 2018-10-29 01:56:40 +00:00
Bartosz Dziewoński
d685694594 Pass $context to 'GetPreferences' hook
Users of the hook no longer have to rely on global context to display
localisation messages.

Change-Id: Ic4006c9d175031f45ee9e38eddc2879e3d1b79c2
2018-10-24 23:03:42 +02:00
jenkins-bot
954b695a85 Merge "Remove old "bulletin board style toolbar" from core" 2018-10-24 05:30:14 +00:00
jdlrobson
7356e66e28 resourceloader: ResourceLoaderGetConfigVars is passed skin
The startup module varies by skin, so it should be possible for
consumers of the ResourceLoaderGetConfigVars hook to know what
skin it being requested.

Bug: T186062
Change-Id: I97d6b4bc245bc64ff148c3665b46116b8a6be409
2018-10-22 18:55:44 +00:00
Max Semenik
0ae317bcc7 New hook ApiOptions
We need it to inform API clients they're changing globally overridden
preferences.

Bug: T198913
Change-Id: I692a1fb42b73d72814f31bfe9bd400c65f59d83c
2018-10-17 18:02:20 -07:00
James D. Forrester
cfa70ea6d0 Remove old "bulletin board style toolbar" from core
With this change, MediaWiki will no longer have a 'JavaScript-powered'
wikitext toolbar, and instead sysadmins will be required to choose one
(or more) of the several extensions available for this purpose if they
need the functionality. For over half a decade MediaWiki's tarball has
included the 2010-era replacement for this feature, WikiEditor. We are
now working on replacing even that, with the 2013-era visual editor, a
mode of which is the forthcoming 2017-era wikitext editor, and several
more specialised editors like CodeEditor.

Beyond this, the core editor toolbar is ancient, un-loved, and is used
only exceptionally rarely, mostly by accident. It is unhelpful to give
implicitly this as the primary editor for MediaWiki just because we've
not removed it from core when it is not a very good experience for any
kind of user, and has not received the attention that users deserve to
be worth retaining in core.

The old core preference, which was intended to govern whether this old
toolbar should be shown, has since mutated into whether the to run the
EditPageBeforeEditToolbar hook. The hook is used by several extensions
to provide toolbars in lieu of the core one. This preference has been,
in practice, a very confusing preference for MediaWiki users, who have
to interact with quite similar preferences to toggle their real editor
which sit next to this one on the preferences page. Consequently, this
preference is also removed.

The code could be made into an extension for those (very few) users of
MediaWiki who might want to keep on using it. However, the author will
offer their services but not their encouragement in said undertaking.

Bug: T30856
Bug: T32795
Change-Id: I2b05f0ca25873ad8e0b33a5e4938bef52c4e9347
2018-10-16 20:08:32 -07:00
James D. Forrester
976c50c21a Drop ParserLimitReport, deprecated in 1.22
Change-Id: I4898d92569bd823f09c12f68fa186e2e139790a7
2018-10-10 16:20:18 -07:00
James D. Forrester
162af29e77 Drop UnknownAction, deprecated in 1.19(!)
Change-Id: Ia75552e69c07f6dc5da2f1e04ea813c912b04aef
2018-10-10 16:17:28 -07:00
James D. Forrester
e888061ca9 Drop UserGetImplictGroups, deprecated since 1.25
Change-Id: Iffe29131fcc85d3477fe93508902d8ea982289f5
2018-10-10 15:30:00 -07:00
James D. Forrester
27112ed203 Drop DoEditSectionLink, deprecated since 1.25
Change-Id: I78b468da34467863047cd01623997dc67cc4fc76
2018-10-10 15:30:00 -07:00
James D. Forrester
24ca95aad9 Drop ChangesListSpecialPageFilters, deprecated in 1.29 and uncalled
Change-Id: I03a9bce0d1085dc30dbc5c3408b4cea154ade19a
2018-10-10 15:30:00 -07:00
James D. Forrester
144b643537 Drop 'SpecialRecentChangesQuery' & 'SpecialWatchlistQuery' hooks, deprecated in 1.23
Depends-On: I9822bb2bc1bcc13eec7924208bf3819d3512ad26
Change-Id: I67c06bb99d9c9582a638f061f523661c821bca8d
2018-10-01 18:15:38 -07:00
jenkins-bot
ef44b9075c Merge "Create UserGetRightsRemove hook" 2018-09-30 18:12:50 +00:00
MR70
9ea4764b2f Create UserGetRightsRemove hook
This hook is created specifically for I379e17c.

The purpose of this hook is to override UserGetRights hook and ensure
that the removed rights will not be reinserted by the other callbacks.

Change-Id: Id31b1f25f2eda012bd811f4b96aac525bc3251c4
2018-09-24 03:21:24 +00:00
Reedy
6aaaa070f3 Remove MimeMagic
Deprecated since 1.28

Change-Id: I793deb8669e353525464ccd840801e5015c545c8
2018-09-23 20:13:29 +00:00
jenkins-bot
b7625d63a6 Merge "Introduce ContentHandler::getSecondaryDataUpdates." 2018-09-17 14:06:19 +00:00
daniel
7960d5385f Introduce ContentHandler::getSecondaryDataUpdates.
This adds getSecondaryDataUpdates and getDeletionUpdates
to ContentHandler, and updates WikiPage and DerivedPageDataUpdates
to handle DataUpdates from all slots.

Bug: T194038
Bug: T194037
Change-Id: I75c96318f58a5cdda48484f7040ae41e6f42392a
2018-09-14 16:18:18 +02:00
James D. Forrester
b5ce7632c7 hooks: Drop Special{Watchlist|RecentChanges}Filters, deprecated in 1.23
Neither SpecialWatchlistFilters nor SpecialRecentChangesFilters are used in any
code known to Wikimedia code search. The related code to use these hooks was
only ever used within the MediaWiki repo.

Change-Id: Ib631d49d7b5835c665171dbad3e8a646b80827ef
2018-09-12 12:43:01 -07:00
daniel
4835a75ec5 Use RevisionRenderer for rendering ParserOutput
Bug: T174035
Bug: T174036
Change-Id: I1085b05d635dd954c143c8a398fae909632ba0a9
2018-09-11 15:25:39 +00:00
Agabi10
580041be56 Add a hook to allow changing the query of Special:AncientPages in extensions
Bug: T76287
Change-Id: I6aa4d8e6140d405476a6f480156f24f2c05019cb
2018-08-31 15:54:45 +00:00
Gergő Tisza
d31580eeb0
[MCR] Render multi-slot diffs
Move logic for rendering a diff between two content objects out of
DifferenceEngine, into a new SlotDiffRenderer class. Make
DifferenceEngine use multiple SlotDiffRenderers, one per slot.

This separates the class tree for changing high-level diff properties
such as the header or the revision selection method (same as before:
subclass DifferenceEngine and override ContentHandler::getDiffEngineClass
or implement GetDifferenceEngine) and the one for changing the actual
diff rendering for a given content type (subclass SlotDiffRenderer and
override ContentHandler::getSlotDiffRenderer or implement
GetSlotDiffRenderer). To keep B/C, when SlotDiffRenderer is not overridden
for a given content type but DifferenceEngine is, that DifferenceEngine
will be used instead.
The weak point of the scheme is overriding the DifferenceEngine methods
passing control to the SlotDiffRenderers (the ones calling
getDifferenceEngines), without calling the parent. These are:
showDiffStyle, getDiffBody, getDiffBodyCacheKeyParams. Extensions doing
that will probably break in unpredictable ways (most likely, only
showing the main slot diff). Nothing in gerrit does it, at least.

A new GetSlotDiffRenderer hook is added to modify rendering for content
models not owned by the extension, much like how GetDifferenceEngine
works.

Also deprecates public access to mNewRev/mOldRev and creates public
getters instead. DifferenceEngine never supported external changes to
those properties, this just acknowledges it.

Bug: T194731
Change-Id: I2f8a9dbebd2290b7feafb20e2bb2a2693e18ba11
Depends-On: I04e885a33bfce5bccc807b9bcfe1eaa577a9fd47
Depends-On: I203d8895bf436b7fee53fe4718dede8a3b1768bc
2018-08-20 15:39:12 +02:00
Gergő Tisza
47b5d95f12 Create DifferenceEngine before calling GetDifferenceEngine
This way the hook is able to consider what kind of DifferenceEngine
was created by default, or even wrap/decorate it.

Change-Id: Ibb6b1b087a2dda445be2b5e8c7518c7d169b5192
2018-08-20 13:32:49 +00:00
Bartosz Dziewoński
7b3da79f50 Pass $title to 'GetLinkColours' hook
I think it's reasonable for link "colours" to depend on the page on
which they are shown. It seems similar to how self-links are handled.
The $colours variable is not cached, so title-specific link colours
will not "leak" to other titles.

Used in ProofreadPage in Ic910c2c33a6f1f8a70d9a122fbd2128428f29bd5.

Bug: T199288
Change-Id: I7378102a3e06544e9e695b255982c9bb0cfbf3a2
2018-07-31 05:00:00 +02:00
tinajohnson.1234
1f88334983 HistoryAction: Implement HistoryPageToolLinks hook for adding more links
This allows AbuseFilter to add an extra link in the tool links section of
the subtitle on a history page

Co-authored-by: Matěj Suchánek
Bug: T28934
Change-Id: I2e0e9e92d3fc303135b0eb9acf06b5fd120178a5
2018-07-19 11:43:43 +02:00
jenkins-bot
867349438a Merge "LogEventsListGetExtraInputs: Keep $input and add $formDescriptor" 2018-07-17 18:52:18 +00:00
Prateek Saxena
52c62c65cd LogEventsListGetExtraInputs: Keep $input and add $formDescriptor
Follows-up on Iba3c6aa5ac40dcdee0792c2d045b238b02d76521.

Bug: T117737
Bug: T199495
Change-Id: I697e158887fcca1da88763a4c929a981d9211490
2018-07-17 20:35:55 +02:00
Jack Phoenix
0ed71cb0e0 New 'OutputPageAfterGetHeadLinksArray' hook, allowing extensions to modify the return value of OutputPage#getHeadLinksArray
Code from wikiHow codebase, where this hook is used by the following extensions:
* AlternateDomain -- used to remove certain links altogether and change the contents of other elements (e.g. <meta description="..." />)
* hooks (PageHooks) -- used to hide certain links for anons on noindexed pages to avoid leaking article info to Googlebot
* QADomain -- used to remove certain elements and correct <meta keywords="..." /> tags not to mention "wikiHow" if that string is present
* search (LSearch) -- used to remove canonical URL on Special:LSearch for SEO

Change-Id: I4a9ceb343bb5c0b4eb79e4589d36c3790938f8a9
2018-07-15 02:08:16 +03:00
Jack Phoenix
358b2d1d77 Pass $opts by reference to subscribers of 'SpecialSearchPowerBox' hook to allow them to modify it
wikiHow added a new hook called 'SpecialSearchPowerBoxOpts', which was passed only &$opts, so that the Finner extension can unset the $opts array. Enhancing the pre-existing hook is a better solution in this case.

Change-Id: I091cbdc78fc779144554d8420a95435b7048c407
2018-07-14 22:42:41 +00:00
jenkins-bot
0e2e1254df Merge "Add new 'ArticleShowPatrolFooter' hook to allow extensions to decide if the [mark as patrolled] link should not be shown" 2018-07-14 22:33:29 +00:00
Jack Phoenix
72f1866b92 Add new 'ArticleShowPatrolFooter' hook to allow extensions to decide if the [mark as patrolled] link should not be shown
Used on wikiHow to simply never show this particular link.

Change-Id: Id6b11135cc062798964a6b3e927ad665fd757616
2018-07-11 11:08:48 +03:00
Prateek Saxena
38756eae46 Special:Log: Convert to HTMLForm
* All Xml generation code has been removed.

* The LogEventsListGetExtraInputs hook now needs a form
  descriptor array and not plain HTML.
  See I37e0d3e81a46239750465b9299279fbbd7c7f87a.

* LogPager and LogEventList also take the $day parameter
  for 'From date (and earlier)' and pass it to getDateCond
  as well.

* Since FormOptions can't automatically extract the date
  from the request this is being done manually in the
  execute method of Special:Log using MWTimestamp.

Bug: T117737
Change-Id: Iba3c6aa5ac40dcdee0792c2d045b238b02d76521
2018-07-10 16:55:33 +05:30
daniel
731a113aac MCR: rename $baseRevId paramter to match actual semantics.
The $baseRevId in WikiPage::doEditContent is used only to indicate what
revision an edit reverted to. It is not used to indicate the actual base
revision of an edit in any sense. Specifically, EditPage never sets it.

So, this change renames the parameter to $originalRevId to match $undidRevId.
It also renames PageUpdater::setBaseRevisionId to setOriginalRevisionId.
Further, this introduces a paramter to PageUpdater::hasEditConflict():

Before this change, PageUpdater::hasEditConflict() was based on the
revision set via PageUpdater::setBaseRevisionId(), assuming the semantics
of "base revision" used by EditPage. However, this is NOT how the $baseRevId
parameter in WikiPage works.

Bug: T197685
Change-Id: Ib78257d4d6ee7c4ec093d5706904c599b02c73e0
2018-06-22 11:57:59 +00:00
jenkins-bot
e9ed100496 Merge "docs/hooks.txt: fix incorrect description of UploadForm:* hooks" 2018-06-18 18:07:33 +00:00
Edward Chernenko
54344ac962 docs/hooks.txt: fix incorrect description of UploadForm:* hooks
Hooks [UploadForm:BeforeProcessing] and [UploadForm:initial] get SpecialUpload
object as their parameter (NOT the UploadForm object).

Also replaced obsolete note "use UploadVerification and UploadVerifyFile"
with modern "use UploadVerifyUpload".

Change-Id: I09ac5b238c8619c94978bdc771653127d3a6264d
2018-06-18 00:33:26 +03:00
Timo Tijhof
7fa718072d hooks.txt: Use "array" in a sentence instead of []
Follows-up 49806d37, which accidentally replaced this "array()"
with "[]".

Change-Id: Ib61e377cc66523aae2df2d42f7b3af2e5bf6c841
2018-06-14 23:33:27 +01:00
jenkins-bot
c451267578 Merge "Pass $parser, &$query and &$widthOption to the 'ImageBeforeProduceHTML' hook" 2018-06-13 15:31:01 +00:00
James D. Forrester
49806d3748 hooks.txt: Clean-up whitespace and wrapping for consistency
This file is a disaster, but now at least we actually wrap at 80 chars
for all the hooks, not just the ones where the developer felt like it.

Change-Id: I10d3d51412af29b135fd7e9a0393ff0b57eb25aa
2018-06-12 13:22:58 -07:00
James D. Forrester
06ac71f9a6 hooks.txt: Label which hooks are deprecated when
Many of these are still soft-deprecated, so tracking down their age
and kicking off the full deprecation process is hard, let alone
actually removing them. Doing this makes that future work easier.

Change-Id: Ib096190accceabf9082f621ba96243f7dedb025d
2018-06-12 13:22:58 -07:00
Bartosz Dziewoński
8a7b7c3f11 Remove deprecated hook EditPageBeforeEditChecks
Change-Id: I525a3a81787214dae42d3ce641d8c62761d17797
2018-06-12 01:00:39 +02:00
Jack Phoenix
088c6db48b Pass $parser, &$query and &$widthOption to the 'ImageBeforeProduceHTML' hook
This allows extensions to essentially reimplement Linker#makeImageLink
completely. Before this wasn't 100% possible as these three are needed for
that.

Inspired by wikiHow's core hacks to /includes/Linker.php, which can now be
moved to an ImageBeforeProduceHTML hook subscriber. wikiHow uses those
changes together with the WikihowArticle extension to heavily modify the
article DOM for various extensions and the default skin.

Change-Id: I8b5ab42d9cf021d66b90d15be68a0239643c10e3
2018-06-10 18:31:56 +03:00
Amir Sarabadani
5a7e9ba954 Introduce ApiMaxLagInfo hook
This will be useful when an extension does something expensive and wants to
make sure users don't put too much pressure on the system.

Bug: T194950
Change-Id: I8a396d07c2d5764a680d0e5536cd1f99edbe141e
2018-06-05 19:46:09 +02:00
Bartosz Dziewoński
c513ec19ef Restore 'PreferencesForm' as alias for 'PreferencesFormLegacy'
In change 4633f4d46a it was changed
to an interface implemented by both PreferencesFormLegacy and
PreferencesFormOOUI so that existing typehints for some functions
parameter would accept them both. Replace those typehints to use
HTMLForm instead. There was really no guarantee in the past that
they would only be given PreferencesForm or its subclasses, either.

Because the typehint change affects some hooks, note it as a
deprecation in MW 1.31 and a breaking change in MW 1.32.

Also add @since tags and correct some typos in code comments.

Follow-up to 4633f4d46a.

Change-Id: I61749f1d864cf68afe90cd9e15ba2d7a74252501
2018-05-24 21:20:50 +00:00
Brian Wolff
70941efd35 Initial support for Content Security Policy, disabled by default
The primary goal here is a defense in depth measure to
stop an attacker who found a bug in the parser allowing
them to insert malicious attributes.

This wouldn't stop someone who could insert a full
script tag (since at current it can't distinguish between
malicious and legit user js). It also would not prevent
DOM-based or reflected XSS for anons, as the nonce value
is guessable for anons when receiving a response cached
by varnish. However, the limited protection of just stopping
stored XSS where the attacker only has control of attributes,
is still a big win in my opinion. (But it wouldn't prevent
someone who has that type of xss from abusing things like
data-ooui attribute).

This will likely break many gadgets. Its expected that any
sort of rollout on Wikimedia will be done very slowly, with
lots of testing and the report-only option to begin with.

This is behind feature flags that are off by default, so
merging this patch should not cause any change in default
behaviour.

This may break some extensions (The most obvious one
is charinsert (See fe648d41005), but will probably need
some testing in report-only mode to see if anything else breaks)

This uses the unsafe-eval option of CSP, in order to
support RL's local storage thingy. For better security,
we may want to remove some of the sillier uses of eval
(e.g. jquery.ui.datepicker.js).

For more info, see spec: https://www.w3.org/TR/CSP2/
Additionally see:
https://www.mediawiki.org/wiki/Requests_for_comment/Content-Security-Policy

Bug: T135963
Change-Id: I80f6f469ba4c0b608385483457df96ccb7429ae5
2018-05-13 21:01:11 -07:00
Brad Jorsch
3f1142045f Generalize ResourceLoader 'excludepage' functionality
There has long been a hack for previewing edits to user JS/CSS, where
OutputPage would pass an 'excludepage' parameter to
ResourceLoaderUserModule to tell it not to load one particular page and
would instead embed that page statically. That's nice, but there are
other places where we could use the same thing.

This patch generalizes it:
* DerivativeResourceLoaderContext may now contain a callback for mapping
  titles to replacement Content objects.
* ResourceLoaderWikiModule::getContent() uses the overrides, and
  requests embedding when they're used. All subclasses in Gerrit should
  pick it up automatically.
* OutputPage gains methods for callers to add to the override mapping,
  which it passes on to RL. It loses a bunch of the special casing it
  had for the 'user' and 'user.styles' modules.
* EditPage sets the overrides on OutputPage when doing the preview, as
  does ApiParse for prop=headhtml. TemplateSandbox does too in I83fa0856.
* OutputPage::userCanPreview() gets less specific to editing user CSS
  and JS, since RL now handles the embedding based on the actual
  modules' dependencies and EditPage only requests it on preview.

ApiParse also gets a new hook to support TemplateSandbox's API
integration (used in I83fa0856).

Bug: T112474
Change-Id: Ib9d2ce42931c1de8372e231314a1f672d7e2ac0e
2018-04-25 00:37:08 +00:00
Timo Tijhof
cec597e2b3 resourceloader: Remove deprecated ResourceLoaderGetLessVars hook
Deprecated since 1.30, only had one caller (MobileFrontend)
which has been fixed since.

Bug: T140804
Change-Id: I39b594e3082ebe321bae463780cfadbfb3de1d5c
2018-04-10 15:11:00 +01:00
Sam Wilson
6c9a0a2a68 Add DeleteUnknownPreferences hook
This makes it possible for extensions to add to the WHERE clause
with which unknown preferences are deleted.

Bug: T188966
Change-Id: Ifb22ca42207956f2b07333da026ff0b215a83930
2018-04-03 06:56:18 +00:00
jenkins-bot
3f59cb9f3a Merge "Pass change tags to NewRevisionFromEditComplete hook" 2018-02-19 22:55:54 +00:00
jenkins-bot
236488d398 Merge "Add a hook into LanguageConverter#getPreferredVariant() to allow extensions to pull the desired variant from cookies (or other such source)" 2018-01-23 23:01:34 +00:00
Thiemo Mättig
383e9013f6 Update UserSaveOptions/UserSaveSettings hook descriptions
I already updated
https://www.mediawiki.org/wiki/Manual:Hooks/UserSaveOptions
https://www.mediawiki.org/wiki/Manual:Hooks/UserSaveSettings
accordingly.

Change-Id: I492f83aa8acb6521f3e175fdbf507a7e44491ca2
2018-01-20 19:16:37 +00:00