Commit graph

52 commits

Author SHA1 Message Date
Umherirrender
b9e8cd219f Improve nullable documentation in Linker class about args
Change documentation to null or false where the type is allowed
Also use int on Linker::tocLine, because an int is passed most

Change-Id: I9591ac91586aa9a28f38f80e0ab576b66b303d8d
2021-11-02 11:43:56 +01: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
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
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
DannyS712
b45ddb2ab3 Use WikiPage::doUserEditContent() instead of ::doEditContent()
Results in passing a user where previously the fallback
to $wgUser was being used, mostly in tests.

Bug: T255507
Change-Id: Iabe24315b23c0ad1272353186425e71974528d23
2021-06-28 00:11:30 -07:00
jenkins-bot
04b14657be Merge "Adjust the description of EditFilterMergedContent hook" 2021-06-26 11:52:17 +00:00
DannyS712
47d70dbfba Post Revision-removal cleanup
Updates for the removal of the Revision class itself
and the various methods/hooks/variables removed in the
process, including:

- Update some documentation removing most references
to the Revision class and updating the MCR migration
notes to reflect the past tense for Revision methods.

- Change some capitalization from "Revision" to "revision"
to make it clear comments are about revisions in general,
not the Revision class in particular.

- Minor code tweaks including removing unused variables that
were around for the old hooks that were removed, and
removing the use of DeprecatablePropertyArray where no
longer needed for anything.

- Fix incorrect documentation for PageUpdater::getStatus(),
the status value changed a while ago to have revision-record
in addition to revision, and recently to only have the
revision-record, but ironically PageUpdater was never updated.

- Removed Parser::$mRevisionObject, used to be a Revision object
and was deprecated in 1.35, missed earlier because it was no
longer being set to Revision objects, always null.

- Add RevisionRecord typehints in DummyLinker to match those
in the corresponding Linker methods

This should be a no-op in terms of functionality.

Bug: T247143
Change-Id: I03bbb94fc29085855448780b1a5ad9063911ecc4
2021-06-24 00:32:39 +00:00
jenkins-bot
db7585635e Merge "ParserTestTablesHook: do not document as both stable and deprecated" 2021-06-02 19:28:44 +00:00
DannyS712
3a51bbe32a ParserTestTablesHook: do not document as both stable and deprecated
Remove `@stable to implement` now that it is deprecated,
and add the missing entry to DeprecatedHooks as a silent
deprecation (i.e. the equivalent of soft deprecation).

Follow-up: I5124789fac333a664b73b4b4a1e801ecc0a618ca
Change-Id: I8aece4b9811344b997a8c31f5376b4dd9784d4e2
2021-06-02 14:15:23 +00: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
Umherirrender
8831b494c1 Use @deprecated annotation on hook interfaces, not functions
Use only one place to document the deprecation of hook
interfaces/functions

Bug: T282903
Change-Id: Ie7d2d7a50afe2897e5c2369f473a33ecaa821637
2021-05-17 23:00:40 +02: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
Func
c8a95edee8 Adjust the description of EditFilterMergedContent hook
Bug: T273354
Change-Id: I16d1b5e34ba33c36d7db433e6e02360e32b06dc7
2021-04-18 02:48:19 +00:00
jenkins-bot
32efe549e5 Merge "Hard deprecate the onTitleArrayFromResult hook" 2021-03-30 22:13:18 +00:00
DannyS712
af047cfaaf EditPageBeforeEditToolbarHook no longer stable to implement
Has been deprecated

Bug: T278563
Follow-up: I3285d01715f32a028ea9d5710800c4fd30fe1c59
Change-Id: I5eef7fa6cc69410145529fe2fc05a8154712075e
2021-03-30 18:58:48 +00:00
DannyS712
508a4a9a00 Hard deprecate the onTitleArrayFromResult hook
The hook was added when the TitleArray class
was created, based on the UserArray class that
has a similar hook, onUserArrayFromResult.[1]

However, while the user array hook has extensions
that use it, there are no extensions that use the
title array hook, and it doesn't really make sense
to do so.

[1] See 38473966ea

Change-Id: Ic4253490af3eaaf5986e3665c230835b298ec4b6
2021-03-30 18:57:55 +00:00
mainframe98
0cd1ebdcb2 Deprecate the EditPageBeforeEditToolbar hook
This hook has become defunct after the classic edit toolbar was removed.
Its only uses are to disable it, which is pointless as the toolbar
doesn't display when the hook doesn't provide any content.

Bug: T278563
Change-Id: I3285d01715f32a028ea9d5710800c4fd30fe1c59
2021-03-29 13:37:26 -07:00
jenkins-bot
d09e9812fc Merge "Allow hooking into shell and eval maint scripts for convenience" 2021-03-18 04:03:31 +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
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
DannyS712
5e2d63b205 phpcs: remove some unneeded suppressions
Were not removed in doc review following creation
of hook interfaces. Fix line length where needed

Change-Id: I2eafffcf3a1c40d0f5613a893c53e0aa14eed6a2
2021-02-17 16:16:24 +00: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
jenkins-bot
a34e301357 Merge "ParserTestRunner: share more code w/ MediaWikiIntegrationTestCase" 2021-01-08 05:42:37 +00:00
C. Scott Ananian
665eae14ac ParserTestRunner: share more code w/ MediaWikiIntegrationTestCase
Refactor the database setup code to share more code between
ParserTestRunner and MediaWikiIntegrationTestCase.  Made
`::setupAllTestDBs` static so it can be reused from
ParserTestRunner.

Made ParserTestRunner::addArticle more like
MediaWikiIntegrationTestCase::addCoreDBData().  Some additional
refactoring work could be done here in the future to share more code.

After the refactoring the ParserTestTables hook is no longer necessary
and so has been (soft) deprecated.  MediaWikiIntegrationTestCase
clones all database tables, so ParserTestRunner no longer needs to ask
extensions for a list of specific tables it should clone.  Cleaning up
the handful of extensions which define this hook will be left to a
future patch set.

Change-Id: I5124789fac333a664b73b4b4a1e801ecc0a618ca
2021-01-07 23:31:12 -05:00
Daimona Eaytoy
4ed494ef18 Add type hints to several hook interfaces
AbuseFilter has been using type hints on these methods for a while, so
we can be pretty confident that the documented types reflect the real
types.

Change-Id: I7192be5843cbf26c22bae9dc4a838536469b90fd
2021-01-04 14:27:48 +01:00
Thiemo Kreuz
1fc8d79ac6 Remove documentation that literally repeats the code
For example, documenting the method getUser() with "get the User
object" does not add any information that's not already there.
But I have to read the text first to understand that it doesn't
document anything that's not already obvious from the code.

Some of this is from a time when we had a PHPCS sniff that was
complaining when a line like `@param User $user` doesn't end
with some descriptive text. Some users started adding text like
`@param User $user The User` back then. Let's please remove
this.

Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
2020-10-27 19:20:26 +00:00
daniel
2e57447c58 Document hook names in hook interfaces.
Bug: T258665
Change-Id: Ifddbf57f8aa2e3eb0d5845601376cbafa08ed407
2020-09-27 12:03:12 +02:00
jenkins-bot
d652917452 Merge "resourceloader: Use a local HookRunner" 2020-09-21 21:45:09 +00:00
Ammar Abdulhamid
c0c8dad053 Deprecate Skin::makeVariablesScript()
Bug: T257995
Change-Id: I9789bb1a209a8f07cb2bb07140f2cc4fd778436a
2020-09-21 20:02:13 +00:00
Timo Tijhof
d04f04097a resourceloader: Use a local HookRunner
Also move ResourceLoaderRegisterModulesHook under the same
namespace. I forgot this one in commit b7ac554304.

This is mainly motivated by making the collaboration graph
on doc.wikimedia.org not huge by pulling in the full range
of core hook interfaces.
<https://doc.wikimedia.org/mediawiki-core/master/php/classResourceLoader.html>

Depends-On: Ifa53d96dd3e4592208dbc991e2af9e6b7598e44d
Depends-On: Ib4571d80f55a4716e28b76ba1d007f95b0fb2540
Change-Id: I576305a5edb36a2ffb513e6d557bbf1d337cb17e
2020-09-17 01:53:18 +00:00
Ammar Abdulhamid
5de919cc83 Mark OutputPageBodyAttributes as non-abortable.
Aborting this hook will have consequence on other users of the hook.

Change-Id: Ifb572ff438cebbd1706b8b5f73ac896545f638ef
2020-07-29 21:05:23 +00:00
daniel
e6e0ad2472 Replace "@stable for implementation" with "@stable to implement"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: I17e5e92e24c708ffc846945a136347670a3a20c7
2020-07-13 11:05:49 +02:00
Lucas Werkmeister
2585f244c4 Fix param type in EditPage__showStandardInputs_optionsHook
In EditPage::showStandardInputs, where the hook is called, the $tabIndex
looks like it will always be an int, not a string.

Change-Id: If3bd9f628e29d078b524242f51f120a27f7ed35e
2020-07-03 18:31:05 +02:00
jenkins-bot
2352b927aa Merge "resourceloader: Change RL hooks to be non-abortable" 2020-07-02 11:05:40 +00:00
jenkins-bot
7701131a76 Merge "Add watchlist expiry to edit form" 2020-07-01 20:32:26 +00:00
Timo Tijhof
cc64098da6 resourceloader: Change RL hooks to be non-abortable
1. ResourceLoaderForeignApiModules
2. ResourceLoaderGetConfigVars
3. ResourceLoaderJqueryMsgModuleMagicWords
4. ResourceLoaderSiteModulePages
5. ResourceLoaderSiteStylesModulePages
6. ResourceLoaderTestModules
7. ResourceLoaderRegisterModules

Their return values were already ignored by hook triggers,
so returning false from these would not have prevented or aborted
anything, except blocking other extensions from using the same
hook.

Depends-On: I54381b7581f6518326048057b8d496b6a32e6e2f
Change-Id: I3ec9d4cc5b575f5fc80e5ad1e8c2cdf113ad564a
2020-06-30 22:17:42 +00:00
Tim Starling
c75eef91bf Introduce $wgForceHTTPS
Add $wgForceHTTPS. When set to true:

* It makes the HTTP to HTTPS redirect unconditional and suppresses the
  forceHTTPS cookie.
* It makes session cookies be secure.
* In the Action API, it triggers the existing deprecation warning and
  avoids more expensive user/session checks.
* In login and signup, it suppresses the old hidden form fields for
  protocol switching.
* It hides the prefershttps user preference.

Other changes:

* Factor out the HTTPS redirect in MediaWiki::main() into
  maybeDoHttpsRedirect() and shouldDoHttpRedirect(). Improve
  documentation.
* User::requiresHTTPS() reflects $wgForceHTTPS whereas the Session
  concept of "force HTTPS" does not. The documentation of
  User::requiresHTTPS() says that it includes configuration, and
  retaining this definition was beneficial for some callers. Whereas
  Session::shouldForceHTTPS() was used fairly narrowly as the value
  of the forceHTTPS cookie, and injecting configuration into it is not
  so easy or beneficial, so I left it as it was, except for clarifying
  the documentation.
* Deprecate the following hooks: BeforeHttpsRedirect, UserRequiresHTTPS,
  CanIPUseHTTPS. No known extension uses them, and they're not compatible
  with the long-term goal of ending support for mixed-protocol wikis.
  BeforeHttpsRedirect was documented as unstable from its inception.
  CanIPUseHTTPS was a WMF config hack now superseded by GFOC's SNI
  sniffing.
* For tests which failed with $wgForceHTTPS=true, I mostly split the
  tests, testing each configuration value separately.
* Add ArrayUtils::cartesianProduct() as a helper for generating
  combinations of boolean options in the session tests.

Bug: T256095

Change-Id: Iefb5ba55af35350dfc7c050f9fb8f4e8a79751cb
2020-06-30 15:38:11 +10:00
Sam Wilson
4fa7d4d7a7 Add watchlist expiry to edit form
This adds new functionality to allow non-checkbox widgets to be
used in the checkboxes row of the edit form, and adds a dropdown
widget for the watchlist-expiry field.

Bug: T248494
Change-Id: Ice5113a97b1ef97253bfa6874ea71d910a5cd8fd
2020-06-30 10:22:04 +08:00
jenkins-bot
0e3be14e45 Merge "Hook: Mark abortable=false hooks as void" 2020-06-25 06:49:24 +00:00
Timo Tijhof
01f3efe4ff Hook: Mark abortable=false hooks as void
* Remove the mention of 'return true' being legal.
  This is only allowed for compat with code from before MW 1.21,
  when I added hook aborting as well as tolerance for null to
  be the same as true.

  Since then, there is no reason to return null or return true.
  For early returns, an explicitly void 'return;' should be used
  instead. Returning anything else like null/true serves no purpose
  other than to confuse the reader.

* Mark the interfaces as natively 'void' with return type hints.

  This means in core code that runs the hook, static analysis
  like Phan and in IDEs, it will be known that these onFoo()s
  never return a value, thus allowing them to detect if its
  return value is assigned or used in a conditional for any
  reason, which can be an easy mistake.

  It also means that in the future when extensions start using
  these interfaces in 'implements' statement, they will be
  required to mark their hooks as void.

  That migration is opt-in and still up ahead. This is not
  a breaking change even for all existing extensions where
  a return true/null may exist in an abortable hook since this
  only applies to code directly typed against the interface.
  The internal run() method doesn't care.

Change-Id: Ib79289bd486ac97cec492e72f9a8dee70cf2f6c2
2020-06-22 19:07:35 +00:00
Roan Kattouw
c8b9d849fc Add PageMoveCompleting hook, to replace TitleMoveCompleting
We intially thought we wouldn't need this and would only need
PageMoveComplete, but it turns out Flow does need it.

Bug: T250023
Bug: T255608
Change-Id: I8e7308541d2fe6d02b9dad63e1c86c89f6e7cf53
2020-06-16 22:27:28 -07:00
Petr Pchelko
cd6b72ecd7 Move autopromote groups logic into UserGroupManager
Bug: T252621
Change-Id: Ic51119cd01771ab1b68294fa5dfacb8034e33b6b
2020-06-11 22:13:48 +00:00
jenkins-bot
766d9299fb Merge "Rename MagicWordwgVariableIDs hook to GetMagicVariableIDs" 2020-06-11 02:59:19 +00:00
DannyS712
1594282ad0 Replace TitleMoveCompleting and TitleMoveComplete hooks
Bug: T250023
Change-Id: Iceb0aebb51769c413bf560d1c5b70a7213cb8b91
2020-06-10 20:03:31 +00:00
C. Scott Ananian
2c9d496268 Rename MagicWordwgVariableIDs hook to GetMagicVariableIDs
This makes the hook name consistent with GetDoubleUnderscoreIDs, and
is part of a set of related documentation changes clarifying the difference
between "magic words" (a localization infrastructure) and the various
functions which use magic words for localization, such as parser functions,
double underscore variables, magic variables, etc.

See also I621c888e3790a145ca9978f6b30ff1a8f685b64c.

Change-Id: Ie2a6df4b179a360fb7cdfb219e915bedff501d1d
2020-06-10 12:28:20 -04:00
Tim Starling
550f5930f2 Hook interface type fixes, to fix Phan errors
Phan flagged a lot of incorrect type hints when run against the call
site migration patch.

Bug: T240307
Change-Id: I698de5536446c241b200430198b21b72763b0c69
2020-05-05 11:22:04 +10:00
Tim Starling
b2d848d603 Remove LocalisationChecksBlacklistHook and LocalisationIgnoredOptionalMessagesHook
The callers were removed in recent commits by Niklas. Not having a
caller means the hook migration scripts doesn't know what to do with
them.

Bug: T240307
Change-Id: Icc0b6e7f5a52601ea1d37d065eebaf5e7103b2ab
2020-05-05 11:22:04 +10:00
Tim Starling
0b7295a5cd Hook interface doc comment followup
Mostly just narrower array types. A handful of other errors fixed.

Change-Id: Ied79d9e389867911bf83696dbb47f43305f8be7b
2020-04-21 09:12:23 +10:00