Commit graph

157 commits

Author SHA1 Message Date
Huei Tan
ba14f43365 WhatLinksHere: Allow extensible filters
Add SpecialWhatLinksHereQueryHook hook that allow extensions
to modify the query builder to add more conditions based on
the filters added in the SpecialPageBeforeFormDisplay hook.

Bug: T216368
Change-Id: I221d4e0ad671feab6937719d4a2f894ad6154bb1
2024-10-21 14:27:53 +05:30
Umherirrender
e662614f95 Use explicit nullable type on parameter arguments
Implicitly marking parameter $... as nullable is deprecated in php8.4,
the explicit nullable type must be used instead

Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a

Break one long line in SpecialPage.php

Bug: T376276
Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
2024-10-16 20:58:33 +02:00
Sergio Gimeno
37985a198d ConditionalDefaultsLookup: allow to dynamically add conditions for evaluation
Why:
To facilitate the evaluation of conditions not directly
"known" by the lookup, eg: owned by extensions

What:
- Add ConditionalDefaultOptionsAddCondition hook which
runs before instantiating ConditionalDefaultsLookup allowing
to add conditions for evaluation in the $extraConditions
array.
- Evaluate the configured conditional default against the
 extra added conditions after evaluation of "known"
conditions.

Bug: T376918
Change-Id: Ife6f96397eafd61fdb40528aac315ddde1ef2774
2024-10-16 17:39:12 +02:00
James D. Forrester
a5387c7c20 Namespace all remaining classes in includes/parser
Bug: T353458
Change-Id: If02cc9b1ff78e26c1cf8c91ee4695845eb133829
2024-10-15 23:54:32 +01:00
James D. Forrester
91a37f53b4 Switch over a bunch of class_alias uses to actuals
Change-Id: Id175a83e71cc910eaee5d5890a9106872a3ca3b8
2024-10-03 17:09:36 +00:00
Bartosz Dziewoński
943d089008 Replace raw HTML copyright footer message with wikitext one
Replaces 'copyright' with 'copyright-footer' and 'history_copyright'
with 'copyright-footer-history' (the original still takes precedence
if set). Adds SkinCopyrightFooterMessage hook which works the same
way as SkinCopyrightFooter for the new messages. Allows disabling
the old messages by setting $wgAllowRawHtmlCopyrightMessages = false.

Co-Authored-By: Gergő Tisza <tgr.huwiki@gmail.com>
Bug: T45646
Change-Id: I5fd5607f8d43b6e934c8d4d35097cec430c56043
2024-09-26 16:18:52 +02:00
Dreamy Jazz
6547b639d8 Add SpreadAnyEditBlock hook
Why:
* A hook is needed which is called when User::spreadAnyEditBlock
  is called, so that extensions which provide alternative blocking
  mechanisims (such as the GlobalBlocking extension) can spread
  their blocks when local blocks are spread.

What:
* Add SpreadAnyEditBlockHook which is called from User
  ::spreadAnyEditBlock when it is called except when the user is
  not registered.
** The hook is called even if the user is not locally blocked
* The return value of User::spreadAnyEditBlock is modified to
  return true if either a local block or alternative blocking
  mechanism spread blocks.
* Update UserTest to test this new behaviour.

Bug: T374857
Change-Id: Id302a6362d6177c89da9cdf4e677b3822ecb85f1
2024-09-24 12:04:20 +01:00
Fomafix
b43860cc09 Add new hook OutputPageRenderCategoryLink
This allows to change the category link rendering by extension
CategoryTree without missing update of mCategoryData and mCategories
which leads to wgCategories = [] (T372155).

The new hook will be used in extension CategoryTree by
Ic86f210474cbc0e2dcebf664cf2309a4a4408f60.

Bug: T372155
Change-Id: Id82a77a57d1f12233d974ea4c1b093f50c5ab74f
2024-09-05 15:53:43 +00:00
Gergő Tisza
e3cea8e11f auth: Add AuthManagerVerifyAuthentication hook
Add a new hook that can be used to prevent authentication just
before AuthManager takes the main action (writing the session
for login, creating the local user account for account creation).

The driving use case is a wiki which supports both a local and
a central (wiki-farm-level) login or signup flow - various
security options (such as 2FA) are needed during local login
but unnecessary during central login (which will have those
security features centrally), so we need to skip much of the
security when the user is taking the central route, and a bug
in how that's done could result in circumvention of security
features during local login. The hook makes it easy to inspect
and potentially interrupt login near the end, when we know for
sure what route it took. (Specifically, we know which primary
provider was used. The hook doesn't expose other details,
such as the list of preauth or secondary provders that were
invoked, because they were not needed for the immediate use
case, but they are easy to add in the future.)

The hook is called after the secondary providers for login
and before them for account creation, since secondaries can
interrupt login but cannot interrupt account creation.

A shortcoming is that since the hook is called after a primary
provider succeeded, it cannot prevent the primary provider from
doing work, ie. it cannot prevent creation of the remote account
during account creation (although it will prevent the creation
of the local account). This is not great but acceptable, since
creating a new account isn't very security-sensitive.
This also means the hook would not be useful during account
linking, as AuthManager does not do anything there, all the work
happens in the primary provider. This is even less great but
few authentication extensions implement account linking.

The hook is not called for authentication happening via
CreatedAccountAuthenticationRequest, which is a weird internal
hack hook handlers should not have to know about.

Also rename a confusingly named variable.

Change-Id: I835b2fe2f43e6e81f23348165cbb9c93832e6583
2024-08-26 23:57:31 +00:00
Gergő Tisza
cde00b5585 auth: Add AuthManagerFilterProviders hook
Allow disabling authentication providers. This allows for
extensions to replace core providers with their own.

This is using the $wgAuthManagerAutoConfig keys instead of
AuthenticationProvider::getUniqueId() as the keys to filter.
This makes it more useful for site administrators, and also
it's probably the better known of the two identifiers so
more intuitive.

No effort is made to prevent the hook from filtering
differently in different steps of the same authentication
process.

Bug: T369180
Change-Id: If5435b54a4fc08f685c04fc10eb44c6d72cd78fa
2024-08-26 23:56:49 +00:00
Derick Alangi
493ffea9e9
Introduce hook to preserve query params after authentication
This hook enables extensions such as CentralAuth to preserve and
use query parameters needed for an authentication flow. Since there
is a provider that handles logins in a different wiki (central login
wiki), and movement to a different URL, this hook preserves query
parameters that can be used between these requests.

Bug: T363483
Bug: T362713
Change-Id: I86e629b07e6e4a0f1d1a4c78a6c77d41b4d68e18
2024-07-08 13:37:54 +02:00
Ebrahim Byagowi
848a9f279f Add namespace and deprecation alias to JsonContent
This patch introduces a namespace declaration for the
MediaWiki\Content to JsonContent and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I44abb1ab5bd1fabf9886dc1457e241d7cae068bc
2024-05-20 18:57:07 +03:30
Reedy
24260fe527 SpecialPrefixIndex: Allow extensible filters
Add SpecialPrefixIndexGetFormFiltersHook hook that allow extensions
to add custom filters on Special:PrefixIndex and another hook
SpecialPrefixIndexQuery that allows you to modify the query builder
to add more conditions based on the filters selected.

Bug: T299308
Change-Id: Iabc672086547d0b19f01cc95892633c2668821ef
2024-02-18 16:43:43 +05:30
Subramanya Sastry
e55cc517da Move Parser to Mediawiki\Parser namespace
Bug: T166010
Co-Authored-By: Daimona Eaytoy <daimona.wiki@gmail.com>
Co-Authored-By: James Forrester <jforrester@wikimedia.org>
Co-Authored-By: Subramanya Sastry <ssastry@wikimedia.org>
Change-Id: I79b4e732c45095eedbaa80afa5eb7479b387ed8a
2024-02-16 09:18:38 -05:00
C. Scott Ananian
4c302bd47c Move hooks used by OutputPage into includes/Output/Hook
Bug: T166010
Change-Id: Ifdb9e6b59f126b47e4143c875c34a207643b7034
2024-02-09 11:08:43 -05:00
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
James D. Forrester
9bfb75ff90 Namespace ParserOutput
Most used non-namespaced class!

Bug: T353458
Change-Id: I4c2cbb0a808b3881a4d6ca489eee5d8c8ebf26cf
2023-12-14 14:57:34 -05:00
Umherirrender
42152f5fb4 Remove deprecated interface ParserTestTablesHook
The hook is no longer called, so the deprecation warning of the
HookContainer (as mention in DeprecatedHooks) cannot work as expected.

Change-Id: Idb586e9c2d8ba87411acc137537db6d6c75485a7
2023-10-03 19:52:49 +02:00
Umherirrender
d869edb4ba doc: Fix variable name in ContentHandlerForModelIDHook
Change-Id: I62075b95d8b6108f1ad6cea26794ac39ac213c9a
2023-09-30 13:12:02 +02:00
James D. Forrester
d1ab762c04 Drop the PersonalUrls hook, deprecated in 1.39
Bug: T319087
Change-Id: I398de94099cf17d071bc539a87a140a76fd301bd
2023-09-21 19:44:12 +01:00
James D. Forrester
459cbb0494 Namespace remaining 'specialpage' files under \MediaWiki\SpecialPage
SpecialPageFactory is already here, but none of the others were yet.

Bug: T166010
Change-Id: I9689bf0a1ab329625e23669b99f019b96295fffd
2023-09-18 18:23:13 +01:00
Gergő Tisza
7a21b9a032 Add UserGroupManager::getUserPrivilegedGroups()
This moves the core part of wfGetPrivilegedGroups() out of Wikimedia
config and makes it possible to move functionality built on it into
core.

Bug: T208477
Change-Id: I6536ef2909caeed047447e8b6a25831d6f00d827
2023-09-02 11:59:25 +00:00
Umherirrender
4cf69a6246 content: Rename $output in ContentGetParserOutputHook
This is a ParserOutput, $output is often used for OutputPage

Change-Id: I98c62140db863243e0342b9747032dc425fccc83
2023-08-14 20:23:53 +02:00
Ammarpad
b6becee5eb Remove deprecated SkinTemplateNavigation hooks
- SkinTemplateNavigation hook
 - SkinTemplateNavigation::SpecialPage hook

Bug: T339969
Change-Id: I0aa4a593ae5c795ca2f75234f379e5ad0efa48aa
2023-06-21 23:20:01 +01:00
Daimona Eaytoy
c7eb0db5d1 mail: Round 6 of EmailUser refactoring
- Rename methods to follow the more standard convention used for
  commands.
- Update doc comments.
- Add new hooks with final method names and parameter types, to replace
  the old messy hooks.
- Deprecate the remaining old hooks.

Bug: T265541
Change-Id: I609709a70fb58ce00b9f179ee4de2f6ac5e0a1cf
2023-06-20 11:00:07 +00:00
Sam Wilson
1eb586013c diff: Add legend and tooltips to inline diff display
Add a legend at the top of the inline diff display, showing the
meanings of the colours of the inserted and deleted highlighting.
Also add the same text as tooltips on the highlighted elements.

The legend is added as part of a new area above the diff table
that can be modified via a new TextSlotDiffRendererTablePrefix
hook, so that extensions can add other buttons etc. there as
required.

This is a follow-up to the previous attempt, which added the
legend in DifferenceEngine::showDiff() and was called from
too many places. This patch moves it to be called in
DifferenceEngine::showDiffPage().

Bug: T324759
Change-Id: I2a3c67bcfa47313dee597e602a62073e4e298cd2
Follow-up: I6de30bf79eb5ac262285951792782b870d075e00
2023-05-31 15:43:28 +10:00
Samtar
2ba3afbd47
Revert "diff: Add legend and tooltips to inline diff display"
This reverts commit 19eb61de66.

Reason for revert: Reworking

Change-Id: I2bc524254d10d6612c5b0a7db95dd6af5f60ccaa
Depends-On: I5c3d7df530eb6fc09ba380d42a81b17511861308
Depends-On: I60784afa0d47e22acd9e8a981092784c84b250eb
2023-05-18 15:50:59 +01:00
Umherirrender
d85f9bd2b0 Move some hooks to ResourceLoader\HookRunner
- ResourceLoaderGetConfigVarsHook
- ResourceLoaderJqueryMsgModuleMagicWordsHook

Change-Id: Ifd8fa776655b347cb539ac824426afb12463148a
2023-05-11 20:51:19 +02:00
Sam Wilson
19eb61de66 diff: Add legend and tooltips to inline diff display
Add a legend at the top of the inline diff display, showing the
meanings of the colours of the inserted and deleted highlighting.
Also add the same text as tooltips on the highlighted elements.

The legend is added as part of a new area above the diff table
that can be modified via a new DifferenceEngineBeforeDiffTable
hook, so that extensions can add other buttons etc. there as
required.

Bug: T324759
Change-Id: I6de30bf79eb5ac262285951792782b870d075e00
2023-04-28 11:27:10 +08:00
jenkins-bot
78a7e31dc0 Merge "Add Hook suffix to ParserModifyImageHTMLHook" 2023-04-17 15:37:22 +00:00
Umherirrender
95814d8d6f Add Hook suffix to ParserModifyImageHTMLHook
Common naming convention for hook runner interfaces

Bug: T334689
Change-Id: I3043454a502289e5ee2492f7bf2ab01e155c30ba
2023-04-16 19:32:48 +02:00
Umherirrender
033e75cb26 Add Hook suffix to GetBlockErrorMessageKeyHook
Common naming convention for hook runner interfaces

The hook is new in 1.40 and the rename should be backported,
but the old name needs alias as it is already used in extensions.

Bug: T334689
Change-Id: I3f9e6d33f1bf29e937c82860fcebd088dde647da
2023-04-16 17:28:13 +00:00
mainframe98
ded922c21d MessageCache: Add a new hook for more performant override fetching
This new hook is called only once, for all overrides, instead of
every time a message is fetched.
Overrides can be specified as string or a callable, to allow for
dynamically computing the override on-demand. These callables are
passed the message key, MessageCache instance, the language and a
boolean indicating if the message should be fetched from the
database.

The parameter choices are based upon current usages of the
MessageCache::get hook.

Bug: T328183
Change-Id: I89e1a9b901aff6ff1bde729df8958ba42a45f3d5
2023-03-14 21:11:35 +01:00
jenkins-bot
26781aa9c7 Merge "Hooks: Remove deprecated SpecialMuteSubmit hook" 2023-03-06 23:47:59 +00:00
jenkins-bot
1a4d21bcc4 Merge "Add PageUndeleteCompleteHook" 2023-03-06 10:27:39 +00:00
Owen
1b01974363 Add PageUndeleteCompleteHook
This adds a hook similar to the PageDeleteCompleteHook, passing a similar level of detail through to extensions about a page's undeletion.

This further deprecates the ArticleUndelete hook as this new hook replaces its functionality.

Bug: T321412
Change-Id: Id77d945dfe14f196c34652b4f3d2f3ec843cbe7c
2023-03-04 10:50:44 +00:00
Tim Starling
7efc7f7518 Copy the Renameuser extension into core
Copy the Renameuser extension into core, with minimal code changes. The
hook handlers are inlined into Article, SpecialLog and
SpecialContributions.

Bug: T27482
Change-Id: I314021f4138773df6aaf2753b33ab8283cd16974
2023-03-03 09:39:39 -05:00
Sam Smith
6a69882d8c Hooks: Remove deprecated SpecialMuteSubmit hook
The hook was deprecated in 1.35.

Further, the hook was only introduced to power the SpecialMuteSubmit
instrument for the User Mute Features Community Health Initiative
project [0].

[0] https://meta.wikimedia.org/wiki/Community_health_initiative/User_Mute_features

Bug: T329718
Depends-On: I2b014dbae0df278f3e051955c1b086a8c7b78fdf
Change-Id: I0c100eb6f3008003ce9678c3dd8346862ae8a914
2023-03-03 09:17:05 +00:00
James D. Forrester
ad06527fb4 Reorg: Namespace the Title class
This is moderately messy.

Process was principally:

* xargs rg --files-with-matches '^use Title;' | grep 'php$' | \
  xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1'
* rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \
  xargs rg --files-with-matches 'Title\b' | \
  xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1'
* composer fix

Then manual fix-ups for a few files that don't have any use statements.

Bug: T166010
Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a
Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
2023-03-02 08:46:53 -05:00
Gergő Tisza
4d7f46af95
Add SpecialCreateAccountsBenefits hook
Add a new hook for modifying the hero message on the signup page.

Bug: T325655
Change-Id: Ifea5cd0674f71e267a931a64a48c8ea5d052b334
2023-01-29 17:50:15 -08:00
Amir Sarabadani
02e5a33057 Drop more unused hard deprecated hooks
None are used in WMF-deployed extensions and have been hard deprecated
for multiple releases as well.

Change-Id: I62cfa22291f81295b4908192de8657a750c6716d
2022-12-01 03:36:48 +01:00
Amir Sarabadani
20c5632c4e Drop unused deprecated hooks
Part one, none of these hooks are used in extensions deployed in
production. I skipped any hook that has silenced its deprecation
warnings.

Change-Id: Idf1fd12cc61ca30867dc9f8aeb1701fe035fc5ff
2022-11-28 13:15:19 +00:00
suecarmol
0b2dca01b9 HookRunner - Change PreferencesGetLayoutHook params
Changed the PreferencesGetLayoutHook parameters so that it no longer passes a Skin variable. Now, the hook will pass an additional string variable with the skin name and an associative array with extra skin properties the hook might need.

Bug: T322781

Change-Id: I0c4e76b528d0196ae6929fd8ed71abc6c860dfc4
Depends-On: I200aec586dbe8613e9a9c762db8d9bcbdc69a35b
2022-11-21 18:51:46 -06:00
David Causse
9fbd8f500f Make the doc building for search aware of the revision
Added an optional RevisionRecord param to:
- ContentHandler::getParserOutputForIndexing
- ContentHandler::getDataForSearchIndex
- the SearchDataForIndex hook

So that they have a chance to build the content related to a specific
revision.

Ultimately we'd like to make this parameter mandatory.

Bug: T317309
Depends-On: I8b220cd6c4aeeca1d924bdd527409b8602318944
Depends-On: I8616b611caab3f5fa97ff0e655b19c3034304597
Change-Id: I3298ce7591069eb32f624b2c9fbb6de58ae04a29
2022-10-25 18:45:23 +02:00
jenkins-bot
a6778bfa62 Merge "Create Hook to check block's error messages from extensions" 2022-10-17 16:16:49 +00:00
AnaïsGueyte
cc55e848e4 Create Hook to check block's error messages from extensions
Bug: T317201
Change-Id: I1c20e7e62e0f2b453735689e3dc543164b5fd067
2022-10-14 11:43:21 -04:00
suecarmol
eda3ac47c3 Add icons to Special:Preferences mobile layout
Added icons to Special:Preferences' mobile layout sections. Also added a hook so extensions can add their own icons.

Bug: T317419
Change-Id: I6d5730d47e7595b1705787995fe5db2fe734d7f5
2022-10-13 17:46:14 -05:00
suecarmol
0ffdf80425 Redesign Special:Preferences for mobile
- Added a hook that checks if the preferences should have a mobile or desktop layout
- Added descriptions to preference tabs, which now display as a stack layout in mobile
- Added a new mobile JS file to control Special:Preferences when in mobile view
- Built the mobile interface in the preferences form

Bug: T311717
Change-Id: I468481b66bf96880d1779cd11a46e18745e2c894
2022-10-05 16:28:53 +00:00
Moh'd Khier Abualruz
efb72f2c67 SpecialContribute Follow up
Follow up to I7f064a954a77373dfec86efae7e378402f500198

From: I28aa164119bc0dbc00f5fcf20bc53dc4851ca0b5
* Fix typo in contribute.css
* Removes selector specificity (scoped to body class to prevent
these styles loading on other special pages)
* Removes non-existent mediawiki.special.contribute module
* Fixes font-sizes to match specification (existing values were invalid).

From: Icfd8a7965d83f2429637139ca0de9ed1520b4169
This module contains all the possible icons this page could make use
of. Seems better to load this one than create an additional ResourceLoader
module to fragment things further.

Changes:
* Use Context for messages instead of wfMessage
* Use generated URLs rather than static ones for the default card
* ContributeCardsHook::onContributeCards is void ( no prevention mode )
* SpecialContribute fixed typo
* Fixed capitalization in messages jsons
* Load Classes with PSR-4
* Redirected always to user's page of the Special:Contribute page ( fixes default selection of tab)

Bug: T286466
includes: I28aa164119bc0dbc00f5fcf20bc53dc4851ca0b5
includes: Icfd8a7965d83f2429637139ca0de9ed1520b4169
Change-Id: Iac34777a89e3e6732a0916dbf0a22677cbc6d121
2022-09-30 19:19:43 +00:00
jenkins-bot
4018457753 Merge "RecentChanges: Mark onRecentChangesPurgeRows() as void" 2022-09-29 18:17:23 +00:00