Commit graph

18 commits

Author SHA1 Message Date
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
Amir Sarabadani
f4e68e055f Reorg: Move Status to MediaWiki\Status\
This class is used heavily basically everywhere, moving it to Utils
wouldn't make much sense. Also with this change, we can move
StatusValue to MediaWiki\Status as well.

Bug: T321882
Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3
Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
2023-08-25 15:44:17 +02:00
mainframe98
b6ded3b2c5 htmlform: Allow validation-callback to return Status instances
Convert this in HTMLFormField::validate to prevent callers from
receiving unexpected Status instances that will be identified as
an error result, even if the Status is good.

Bug: T338677
Change-Id: If2208cca92c5c496eef73f25363221bc490d9c88
2023-07-09 19:53:01 +02:00
Daimona Eaytoy
4d5cd3a84f Replace deprecated MWException
Bug: T328220
Change-Id: I66be7a6dd752d6b9c254beb65f4eb5ace3c89776
2023-06-09 17:21:12 +02:00
Marius Hoch
dc87b69568 Allow setting "notices" for OOUI form fields
We need this in Wikibase to nicely indicate why
a certain form field cannot be used.

Bug: T330193
Change-Id: Ic0a6f9561db41d4da218122477ce9318665929d5
2023-05-30 12:28:15 +02:00
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.

Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.

Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
2023-03-24 02:53:57 +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
Amir Sarabadani
bbe704b5c1 Reorg: Move some of request related classes to MediaWiki/Request
Redoing I5ea70120d74 but without moving WebRequest that caused issues
with phan-taint-plugin.

Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequestUpload

Bug: T321882
Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
2022-10-28 10:15:31 +00:00
Zabe
f6b9381d7f Revert "Reorg: Move some of request related classes to MediaWiki/Request"
This reverts commit 2bdc0b2b72.

Reason for revert: T166010#8349431

Bug: T166010
Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
2022-10-27 13:14:16 +00:00
Amir Sarabadani
2bdc0b2b72 Reorg: Move some of request related classes to MediaWiki/Request
Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequest
 - WebRequestUpload

Bug: T166010
Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
2022-10-26 16:49:10 +02:00
Umherirrender
89b2d11a0d tests: Use Title::makeTitle instead of Title::newFromText
Avoid parsing known titles in tests to improve performance

Change-Id: Ie240eb42479d19714e64cc4606e26073fadc2e13
2022-09-23 21:53:11 +02:00
Func
0e36de19dc HTMLFormField: Adjust isSubmitAttempt and add more comments
This is a follow-up of change Ic414e7bb7933c8c5c58a277ac1c5c3aaf8c36119.
I noticed that HTMLForm would add a hidden field of edit token for forms
that require to be posted...
And I also noticed that there is a crazy use case (9ca8394943/includes/specials/SpecialTags.php (320))
that would break with the loose check (I'm also going to fix it by I5050311c37030a64daaa25d05e2223485ed86108).
So that change should be undone, but keep the POST check here to avoid
arbitrary token in a GET form.
Add more comments since there are some preconditions in another file and
avoid future regression.
(And I hope this is the last time I fix this test...)

Change-Id: Ib02cd6b4a45e3820c4378fe5b0c7fc61fe1251e7
2022-02-11 11:46:21 +00:00
Func
294b75c559 HTMLFormFieldTest: Add more tests about field cloner
Change-Id: Ie8539ec2fdfc29b166737f9715ed05b7abf3316f
2022-02-08 09:39:41 +00:00
Func
aa57f20aa2 HTMLFormField: Make the behavior of cond-state consistent between client and server
Old codes relied on some assumptions, so:
  * When a "key in form descriptor" is provided, the 'name' param can't be set otherwise the js wouldn't be able to find it.
  * When a "name for submission" (with 'wp' prefix or same as the 'name' param) is provided, it works on the client-side but something might be broken on the server-side.

Since the documented usage is to use "key in form descriptor" and most use case is fine, the use of "name for submission" is explicitly disallowed here.
Use cases simply with the 'wp' prefix would still keep working on both sides though.

Depends-On: I27fd8fa9643d611b37e3f47e77b698245814d539
Change-Id: I9a42417a6161f42181badd8cdbec81ba85dc62f6
2022-02-07 09:56:25 +00:00
Func
0c707ca259 HTMLFormField: Bypass the inverting logic of HTMLCheckField for disable-if and hide-if
Values loaded from the default wouldn't be inverted, there is no need to copy the conditions to here, we can just simply bypass them.
Fortunately, nothing can be affected in a normal use case, since all value of fields would be set to server.

Thanks to the newly added tests, which helped me to realize this problem. 

Change-Id: I5589ba7383587afdd9307c79e88849dacee02706
2022-02-01 13:09:13 +00:00
Func
c574f49f34 HTMLFormFieldTest: Use mFieldData for check of values
Fields can have some filter to process the data, for example, HTMLCheckField would return true rather than raw string '1', we should also test this.

Note that the param indicating 'checked' state is matching the state on client-side, the value would be inverted by HTMLCheckField...

Change-Id: Ia9a7a8c46b0a55ecf2d5378a0d0b6cc00cdb54eb
2022-02-01 08:10:14 +00:00
Func
53d4b41be3 HTMLFormField: Split out the validation of cond-state params
Follow-up changes will use cond-state params in other functions, split this out to make sure it's validated.

Change-Id: Icf358794b11a8f986fbd02c8f1b15ea9d1ef4d15
2022-01-28 21:47:52 +00:00
Bartosz Dziewoński
751f050bf3 Add tests for HTMLFormField 'hide-if' / 'disable-if' functionality
(Test scaffolding code copied from HTMLRestrictionsFieldTest)

Change-Id: I9d221059813a6ac362e3e070984abcaae57906dc
2022-01-28 22:44:35 +01:00