Commit graph

1152 commits

Author SHA1 Message Date
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