Commit graph

204 commits

Author SHA1 Message Date
C. Scott Ananian
df3cc40fac Rename ParserOutput::{allow,prevent}Clickjacking() -> ::{get,set}PreventClickjacking()
This name is consist with the rest of the setter and getter methods
in ParserOutput.  Renamed the methods in OutputPage, ImageHistoryList,
ImageHistoryPseudoPager, and ContribsPager as well for consistency;
it also makes chasing down lingering references in codesearch easier.

Soft-deprecated the old name for 1.38.  Hard-deprecation will follow,
but there are a number of users in production that should be chased
down first.

Code search:

https://codesearch.https://codesearch.wmcloud.org/deployed/?q=(allow%7Cprevent)Clickjacking&i=nope&files=&excludeFiles=&repos=

Bug: T287216
Change-Id: I9822c60c180d204bd30cb4447a1120155d456da4
2021-10-01 14:13:47 -04:00
Umherirrender
244ea7c0b5 Simplify else-branches after continue/break
When the if branch continues the loop,
than the next branch does not need to be an else branch

Change-Id: Ia158709b7fd2ea811f1049cf8f53ed12c89719e3
2021-08-17 22:51:43 +02:00
Kunal Mehta
a85f569dd1 Revert "Use CsrfTokenSet as CSRF token source"
This reverts commit 0d75fdb4f7.

Bug: T287542
Change-Id: Iedd3461869f973f8d621a39e6ad4674cbb577551
2021-08-05 15:48:26 -07:00
Petr Pchelko
0d75fdb4f7 Use CsrfTokenSet as CSRF token source
Change-Id: I079d2c802d9b48d6abf7f37fa9ef7dafac631345
2021-07-12 14:19:15 -07:00
Umherirrender
1121757ed7 Allow html form field option 'options-messages' to get parsed
The message keys by 'options-messages' are evaluated with
Message::plain(), but some situation needs Message::parse() to support
templates and HTML formatting in this values.

Bug: T58633
Change-Id: I8f52f21ae2641ddcad1aa85ce6bf14de1a09ab4b
2021-05-28 21:55:09 +02:00
daniel
39a6e11310 HTMLForm: accept PageReference instead of Title.
Note that this changes the effective type of the protected mCancelTarget
field. This fields has no declared type, and does not seem to be used in
any subclass. The type of mTitle is not changed at this time, but
nothing seems to rely on that either.

Bug: T278459
Change-Id: I4bf0d46c74b53ffc9cb3e6e497c789ef6b3bab6a
2021-05-07 23:36:49 +02:00
Umherirrender
78cc6d77ff build: Swap deprecated @codingStandardsIgnore to phpcs:ignore
Bug: T278594
Change-Id: I09a6175917090593e6e0055203a890c32bea03a5
2021-04-04 21:18:22 +02:00
STran
ee93d068d2 Add HTMLTagMultiselectField
Implements HTMLTagMultiselectField, a form field that instantiates
TagMultiselectWidget, the PHP representation of the OOUI's js-based
widget of the same name with the implemented parameters:
* allowArbitrary
* allowedValues

Bug: T278317
Change-Id: I3a6a30506d493be4185f917c577b3837fffd8ae1
2021-03-26 08:15:38 -07:00
Thalia
420001adce HTMLForm: Fix documentation for tryAuthorizedSubmit
This can return any value returned by trySubmit.

Change-Id: Iaf6a69e44984585337c76f329ac491b2e69fe744
2021-01-22 21:41:22 +00:00
jenkins-bot
524a992458 Merge "Create HtmlFileField" 2021-01-21 23:52:27 +00:00
Ed Sanders
b28809cb16 Create HtmlFileField
Bug: T243476
Change-Id: I21d17de56f753c4f62c17c0baf988e1ca890bfda
2021-01-21 22:55:00 +00:00
Thalia
10e043b9c7 HTMLForm: Add documentation for sections and subsections
Change-Id: I6cc496476e980f0ee0dfd5d6c15e59ef9eb14aa0
2021-01-04 18:15:32 +00:00
James D. Forrester
abdc94a3da Swap out uses of User->isLoggedIn() with ->isRegistered()
Bug: T270450
Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
2020-12-22 03:13:37 +00:00
Umherirrender
cf8c94b163 Do not assume string is message key in OOUIHtmlForm::getErrorsOrWarnings
single string is raw html,
not a message key as documented on HTMLForm::trySubmit

Also remove is_string, any truthy value would be implicit string casted
in HtmlForm::getErrorsOrWarnings

Reorder the if in HtmlForm to look similar to OOUI

Change-Id: I5b78b0df2cca695f8f5c6b08aa4d6c015d1fa1fe
2020-11-20 14:26:15 +00:00
Thiemo Kreuz
20b2c5000d Make use of array deconstruction directly in foreach, if possible
Deconstructing non-sparse, numerically indexed arrays directly in
foreach (a.k.a. using the list() syntax in foreach) is possible since
PHP 5.5.

The possibility to use string array keys as well as non-sequential
numeric keys in array deconstruction was added in PHP 7.1.

Change-Id: I56a48552a45f61cedc291b306cad8548fc70d485
2020-11-12 18:38:06 +00:00
Umherirrender
c85a43561e Improve class property documentation
Reformat existing documentation to match the format

Change-Id: I190b54b5e962f17bab6502dd1b3c02f11dc926d2
2020-10-30 10:38:58 +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
Bartosz Dziewoński
d8c93b163a mediawiki.htmlform: Ensure collapsible forms are enabled
The code that enables collapsible elements in 'mediawiki.page.ready'
may not run on special pages.

Bug: T260642
Change-Id: I4c5250f5b2575ec6699b99bf979c02e5ac16722d
2020-10-13 22:37:15 +02:00
jdlrobson
741f0800ca Collapsible HTMLForms need to add JS module
Not working on Special:AbuseFilter for example
Skins can disable this module so special pages must
add it explicitly.

Bug: T260642
Change-Id: I51deedf9c60279b0917ab085fd7498edf55e93da
2020-09-15 17:01:46 +00:00
Thiemo Kreuz
d206da0e1e CSS 'class' names can be an array in Html::…element
Change-Id: I301d23066b19051b9e1cb9363639f6189a8b173c
2020-09-08 19:11:19 +00:00
Nikki Nikkhoui
6b0e9eafe1 HTML Classes stability annotations
Add stability annotations for HTML classes.

Bug: T247862
Change-Id: I4dad7b98213ceceb8c04b24e5d52e6fecadb3538
2020-07-13 14:54:28 +02:00
Tim Starling
68c433bd23 Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.

General principles:
* Use DI if it is already used. We're not changing the way state is
  managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
  is a service, it's a more generic interface, it is the only
  thing that provides isRegistered() which is needed in some cases,
  and a HookRunner can be efficiently constructed from it
  (confirmed by benchmark). Because HookContainer is needed
  for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
  SpecialPage and ApiBase have getHookContainer() and getHookRunner()
  methods in the base class, and classes that extend that base class
  are not expected to know or care where the base class gets its
  HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
  getHookRunner() methods, getting them from the global service
  container. The point of this is to ease migration to DI by ensuring
  that call sites ask their local friendly base class rather than
  getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
  methods did not seem warranted, there is a private HookRunner property
  which is accessed directly. Very rarely (two cases), there is a
  protected property, for consistency with code that conventionally
  assumes protected=private, but in cases where the class might actually
  be overridden, a protected accessor is preferred over a protected
  property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
  global code. In a few cases it was used for objects with broken
  construction schemes, out of horror or laziness.

Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore

Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router

setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine

Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-05-30 14:23:28 +00:00
DannyS712
b31cec3cec Remove more IE6 and IE7 compatibility and notes
Neither is supported

Bug: T232563
Change-Id: Ia7902f0b1df6148d819621dd5e57d2fe91a50973
2020-05-19 00:31:46 +00:00
BrandonXLF
f63ec91b3a Don't add dash to legend title if prefix is empty
Don't add a dash before $key when $this->mMessagePrefix is not set or is empty.

Bug: T248063
Change-Id: Ide3021a5550462ad2d51e5ac2e61f2807f61a8dd
2020-03-19 08:47:11 +00:00
Florian
c13605dba4 HTMLForm: Allow status object to have raw parameters
The status object, which can be returned after validating an HTMLForm,
can contain message objects. These message objects can be constructed
with the full feature set provided by Message, e.g. raw parameters.

The handling of these status objects in HTMLForm basically prevented
some features of the Message object in the status, as it parsed the
messages through the Parser, which does not recognize these raw
parameters as such and escapes them wrongly.

This behaviour is fixed with this change.

Bug: T240774
Change-Id: I152ec51f317799572bf6791e110cd72c42da82a0
2020-02-09 18:06:12 +01:00
Timo Tijhof
326325b6de htmlform: Remove IE6-7 hack for <button> submit handler
This was a server-side check that made certain <button> elements
render as <input> for IE6 and IE7. MediaWiki no longer offers
basic support for these browsers per RFC T232563.

Change-Id: Ibd27b6fda3929bf94a5362a0369b3744e42de121
2020-01-05 23:16:58 +00:00
DannyS712
b92132e84f HTMLForm: Fix grammar of class description
"Other methods call done after that" should be "Other method calls
done after that" (though "Other methods called after that" would
work too.

Change-Id: I9fe8194647c134e6d2aea7b88c3fd4140ffb9883
2019-12-28 09:27:33 +00:00
Daimona Eaytoy
ce0856b12f Fix more scalar types in docblocks
Change-Id: I574d4e261ab986e028c3ce26c4f0ec648b88a2ac
2019-12-08 17:59:08 +00:00
Daimona Eaytoy
95dc119527 Fix new phan errors, part 2
Still mostly doc-only.

Bug: T231636
Change-Id: I65cec6c716ce6859e14da00a12ef71e03603e59a
2019-10-12 10:35:09 +00:00
jenkins-bot
49fdec9c51 Merge "Use splat operator in signature, not func_get_args" 2019-10-03 18:56:50 +00:00
Gergő Tisza
f301dd5ce9
Fix HTMLForm::addButton label-message type annotation
Change-Id: I5dad560df0705976e104eec4d4159993e5bd0b66
2019-10-02 19:53:57 +02:00
Michael Große
a89f0997a3 Use splat operator in signature, not func_get_args
Most of the original scope of this patch was implemented in 8665536045

What remains is to use the splat operator in the method signature as
well which is more readable than using func_get_args and doesn't annoy
phan. This is now possible, because we are no longer testing on HHVM and
these mocking in HHVM tests was the only place where this was broken.

Change-Id: I52912d1810b955b05cd17fab424f80c201883411
2019-09-28 18:02:21 +00:00
Volker E
441e12f2d9 Messages collected above the form are meant to live as boxed messages
Also removing HTMLForm/VForm `.error` and `.warning` classes from
'forms.less'.

Bug: T233362
Change-Id: I4f8d8f228ab07253a7df24470791c26e39bc311a
2019-09-19 15:10:45 -07:00
Daimona Eaytoy
e2e543f7c2 Unsuppress more phan issues (part 5)
Bug: T231636
Depends-On: I6e5fba7bd273219b1206559420b5bdb78734aa84
Change-Id: I50377746f01749b058c39fd8229f9d566224cc43
2019-09-01 09:48:31 +00:00
Daimona Eaytoy
5eac6d131c Unsuppress more phan issues (part 3)
Bug: T231636
Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
Change-Id: I58e67c2b38389df874438deada4239510d21654f
2019-08-31 16:38:55 +00:00
Thalia
ce965f9826 Fix punctuation in HTMLForm documentation
Change-Id: I22c4ed248fddc93afd486b9bee5a80bdbba1c685
2019-07-30 14:43:39 +01:00
jenkins-bot
5b202d729d Merge "Adjust type hints in htmlform related classes" 2019-07-05 21:32:55 +00:00
Umherirrender
11c9075767 Adjust type hints in htmlform related classes
The return type of HTMLFormField::loadDataFromRequest to mixed
Some sub classes returning arrays or bools, not everytime strings

HTMLCheckField is working with arrays, so also allow array on getTableRow

Change-Id: I076feea76d8e296f27c8a9fb4cbd9368584ba187
2019-07-05 18:11:53 +00:00
Dayllan Maza
f74b19134d Add new public method addFields() to HTMLForm
Once you instantiate an HTMLForm there was no clear way of adding
new fields except for hidden fields. This is particularly problematic
when the form is passed by reference in Hooks.

NOTE: this is just moving what was previously part of the constructor
into its own method + very small tweaks

Change-Id: I23f983417510841ce76cdefcb076e5ab97b43f10
2019-06-26 16:29:41 -04:00
Kunal Mehta
8665536045 HTMLForm: Use PHP 5.6 splat operator directly instead of ObjectFactory
Change-Id: I3fddf30f1b0fc2cce79f652cb71efba119439a9f
2019-06-04 23:49:20 -04:00
Derick Alangi
e849ffb430 HTMLForm: Remove deprecated unused getErrors() method
Was deprecated in 1.28 and no longer used, see usage below;

Usage
=====

https://codesearch.wmflabs.org/search/?q=%5CbgetErrors%5C(%20(.*%3F)%20%5C)&i=nope&files=&repos=

Bug: T220656
Change-Id: I542df4f1f7f4180d42282eaf2e069ab0bc9e8614
2019-06-03 15:20:54 +01:00
Timo Tijhof
012aa045e9 HTMLForm: Improve method documentation for setCollapsibleOptions()
Follows-up 36d33daa03.

Previously the method was described as "Set whether the form can be collapsed"
taking a single boolean.

Yet, the boolean did not influence whether the form can be collapsed, as one
might expect.

Rather, this method always enable collapsible mode. The thing that is set
based on the passed value is the default state of that (unconditionally)
enabled collapsible mode.

Change-Id: I2e73d5481c44ed43769553b2bc25543a702c19b8
2019-05-22 23:40:52 +01:00
Derick Alangi
fefedf568b HTMLForm: Add known MediaWiki version to wfDeprecated() call
In 3706dcb, this method was soft deprecated and hard deprecated at
the same time (1.28) but during the call to wfDeprecated for hard
deprecation, the version number was missed, though this will default
to false, it's good to use the version number which is known in this
case (1.28).

Change-Id: I535ad07e79d14bac8ec42beaeb4b3762a494b28b
2019-05-18 09:15:33 +00:00
Derick Alangi
1981823755 Remove several methods, deprecated in 1.32
I've checked and doubled checked that these methods are no longer used
anywhere in core or extensions, hence removed them. They were hard deprecated
in MediaWiki 1.32.

* OutputPage:
  ** `::showFileCopyError()`
  ** `::showFileRenameError()`
  ** `::showFileDeleteError()`
  ** `::showFileNotFoundError()`

* ApiBase:
  ** `::truncateArray()`

* IcuCollation:
  ** `::getICUVersion()`

* HTMLForm:
  ** `::setSubmitProgressive()`

* ResourceLoaderStartUpModules:
  ** `::getStartupModules()`
  ** `::getLegacyModules()`

* BaseTemplate:
  ** `::msgHtml()`

* QuickTemplate:
  ** `::msgHtml()`

* WatchAction:
  ** `::getUnwatchToken()`

Bug: T220656
Change-Id: Ic1a723a991f4ff63fcb5f045ddcda18d1f8c3c68
2019-05-09 11:36:44 -07:00
Bartosz Dziewoński
36d33daa03 HTMLForm: Improve method interface for collapsible forms
Also minor tweaks:
* Fix @since tags, this did not make it into 1.33
* Fix usage of FieldsetLayout 'group' in OOUIHTMLForm
* Documentation changes

Follow-up to 2896e87a10,
per my post-merge review on that commit.

Change-Id: Ib93375cde19730a46e4929878d6e472d3ac8f631
2019-05-02 14:33:20 -07:00
jdlrobson
2896e87a10 History form can be collapsed
A generic way for collapsing forms is added and used
on history.

Bug: T220555
Change-Id: I3073359210bcc25625c9ec07629100130effaed1
2019-04-09 22:57:39 +00:00
Max Semenik
e6818e6c64 Fix unused vars/pointless assignments
Change-Id: If475c738b4af7208024c866594d4c0048af053dd
2019-03-29 16:52:48 -07:00
jdlrobson
dc180ca64f Restore #mw-history-search id on history action fieldset
Change-Id: I3551667b1f64a3cd9227b07df2a215ccb701ea5d
2019-03-29 15:28:36 +00:00
Lucas Werkmeister
5d46ab1453 Fix invalid HTMLForm::setValidationErrorMessage doc
The method has not actually supported scalar or single-level array
arguments for a while now; according to Michael Große, this ability was
lost in Ibb17bb61ac. No one seems to have noticed (indeed, MediaWiki
code search finds no callers at all [1]), so instead of trying to fix
it, let’s just update the documentation.

We can also remove a cast to array in trySubmit(), because if the value
wasn’t already an array, then converting it to a single-element array
and then trying to spread its only element into $hoistedErrors->fatal()
arguments still fails (“only arrays and Traversables can be unpacked”).

[1]: https://codesearch.wmflabs.org/search/?q=setValidationErrorMessage

Change-Id: I8c292ec62ef4aec89217e86a75d7f2e88111f43f
2019-03-19 15:19:30 +01:00
Thalia
ccbe9f3590 Introduce multiselect widgets for namespaces
Bug: T204986
Change-Id: Ie3916e2322d8b1a7effe9ba4604b596b568004e6
2019-01-22 12:48:42 +00:00