Commit graph

36 commits

Author SHA1 Message Date
daniel
e239b02a5e Add convenience methods for asserting status.
This ensures that assertions work in a uniform way,
and provides meaningful messages in cause of failure.

Change-Id: Ic01715b9a55444d3df6b5d4097e78cb8ac082b3e
2022-03-16 22:44:25 +01:00
Gergő Tisza
0ff1138537
StatusValue: improve toString formatting
Don't just cut off the message key at 25 characters, it makes
debugging very annoying. But do cut off the parameter at some
reasonable length, it could be arbitrarily large.

Change-Id: I8a2665434d6370477eb36a6827eb634e230d280a
2021-11-25 21:53:21 -08:00
TChin
fa5d3dba51 Support fluent interface for StatusValue
Also refactored some calls to use it.

Bug: T287485
Change-Id: If9e96ce87dc3f3641e9b3ebe093f92d8fa49b9ee
2021-08-02 15:14:11 -04: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
Petr Pchelko
0061ed3bed Convert WikiPage to authority.
Change-Id: Iba5e36e5a13c304be51b82a952b2a3044e122c8c
2021-02-27 00:50:07 +00:00
Reedy
de8be2f820 StatusValue: Minor code clean up
* Call non static function non statically
* Replace += 1 with ++

Change-Id: Id44e08ad9a72068d6eae881a9b400640e6d540c5
2021-02-19 23:14:25 +00:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
Cindy Cicalese
546ae552a9 Status/StatusValue errors/warnings should be unique
Bug: T272100
Depends-On: I4a45d2db5de350384e7f57a728b2089f29dc1767
Change-Id: Idfc93029ef177b92830866de941394b383fcbb34
2021-02-06 10:26:29 -05:00
Ammarpad
b5ec7226a4 StatusValue: Reduce logic duplication
Make StatusValue::fatal() call StatusValue::error() method instead
of duplicating its logic.

Change-Id: If6274f59d35d85252afff8d0254eaebb2b1328aa
2021-01-17 07:33:44 +01:00
daniel
bd5c3d06a2 Annotate newable classes
This annotates classes that can safely be instantiated by
extensions, per the Stable Interface Policy.

Bug: T247862
Change-Id: Ia280f559874fc0750265ddeb7f831e65fd7d7d6a
2020-07-07 15:38:57 +02:00
Brad Jorsch
c7e451ce95 StatusValue: Fix __toString() to not choke on special parameters
e.g. nested messages, Message::plaintextParam(), and so on.

I'm not inclined to do too much here, since long term we should replace
Message with MessageValue and that will likely require reworking or
replacing StatusValue too.

Bug: T245155
Change-Id: Ie727de19162467574815853d2584c472a9171240
2020-02-14 16:51:31 -05:00
jenkins-bot
2796f33ff5 Merge "Make Status::wrap and StatusValue::splitByErrorType work together" 2019-10-08 12:03:08 +00:00
Gergő Tisza
773a732a8d
Make Status::wrap and StatusValue::splitByErrorType work together
Status::wrap creates a new status object with most of its fields
references to the wrapped StatusValue. (This seems like a bad idea
but fixing it would potentially introduce subtle behavior changes
in a lot of code, so it is not attempted at this time.) When
splitting such a Status object by error type, the cloning causes
the error arrays of the new Status objects to be references to the
old one so writing them will result in a mess.

Change-Id: I9801647c39578a76be66f6e8c3c06c352660ca1e
2019-10-07 13:36:15 +02:00
Daimona Eaytoy
2612175ef3 Use real variargs for variadic methods
These were all checked via codesearch to ensure that nothing is overriding
these methods.

Change-Id: Ie2d8c1fd01478f46f3d0d1259417182b0d955a12
2019-10-06 14:47:54 +00:00
Daimona Eaytoy
e7ee0bc0f5 Better docs to make phan happy
Change-Id: I8a9a6330cf1f889cbb77dfc28c93774204767323
2019-09-07 16:47:18 +00:00
Derick Alangi
2dca5bbbf5 Remove unnecessary semi-colons
Change-Id: I9eb65bdfbd3aa581effc14ead801b9e89b0359c3
2019-06-12 14:35:59 +01:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Max Semenik
6e956d55aa Replace call_user_func_array(), part 2
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

In one occurrence, a simple conditional instead of trickery was much more readable.

This patch finishes all the easy stuf in the core, the remainder is either unobvious
or would result in smaller readability gains. It will be carefully dealt with in
further commits.

Change-Id: I79a16c48bfb98b75e5b99f2f6f4fa07b3ae02c5b
2018-06-07 20:19:26 -07:00
Thiemo Mättig
ef470ebf7f Remove @param comments that literally repeat what the code says
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).

Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
2018-01-10 14:14:26 +01:00
Thiemo Mättig
c785efd25e Fix and make some types in PHPDoc and JSDoc tags more specific
Change-Id: I7c109067579f570ecccaabc75b0b4db7eac4e6c2
2017-08-05 18:46:44 +02:00
jenkins-bot
aa3319c4c0 Merge "Miscellaneous indentation tweaks" 2017-02-28 18:38:36 +00:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01:00
addshore
a28fa6b546 Fix StatusValue::setResult phpdoc typo
Change-Id: If727e357d4deb138ec4e391f231b074677ec2437
2017-02-27 09:18:03 +00:00
jenkins-bot
91267f914e Merge "Improve Status/StatusValue::splitByErrorType type hint" 2016-10-24 05:11:30 +00:00
Gergő Tisza
1bcff02923 Force boolean type for $ok in StatusValue::setResult
Change-Id: Ie9e933fba3445872e39d70ab3a8230f204106996
2016-10-24 04:07:53 +00:00
Gergő Tisza
223aa1e97e Improve Status/StatusValue::splitByErrorType type hint
Change-Id: I6deb76f8906aa86481b84ce1aaebaddf3a52e31d
2016-10-24 00:50:40 +00:00
Aaron Schulz
25a1651aad Make LockManager use StatusValue and move classes to /libs
Change-Id: Ifa41fc2939f3515d4a056746b0fcbff79786d25b
2016-09-19 04:34:28 +00:00
Aaron Schulz
c64c3ef9a8 Make Status extend StatusValue and start FileBackend update
* This avoids code duplication.
* Callers can safely start type-hinting StatusValue as well.
* Also moved the wrap() logic out of Status::__construct(), which
  only wrap() was (and should have been) using. Use "static" as
  well, so subclass behave properly.
* The docs and type-hints in /filebackend are updated as an example.
* A migration pattern is to inject a StatusValue wrapper
  into the backend and use it on all returned statuses, so MediaWiki
  will still get Status for message methods.

Change-Id: Iff9255f34870ea6b0c4b91f6ddc69eea95186aba
2016-09-17 15:45:40 -07:00
jenkins-bot
f0d760a077 Merge "Show warnings in HTMLForm and warnings as warnings on Login/Signup form" 2016-09-17 18:05:13 +00:00
Florian
3706dcb5c7 Show warnings in HTMLForm and warnings as warnings on Login/Signup form
This commit changes the way how HTMLForm handles a Status object
when executed from a request. It now handles, beside the errors,
also the warnings of a Status object and prints them out, wrapped
in a warning box.

The LoginSignupPage uses this feature to show informative warnings
actually as warnings and not as more disturbing error messages.
Error messages should be reserved for errors and only for erros. An
AuthenticationProvider, which returns an UI AuthenticationResponse
can choose, if the given message is an error or a warning message.

This commit also addds a new function to Status, which allows a
developer to split the object into two new Status objects, where one only
contains the errors and the other only the warnings of the origin
Status object (splitByErrorType). StatusValue also has a new function,
splitByErrorType(), to support this.

Bug: T139179
Change-Id: I9a27911613e62b5c4cb86bea40696cb37c4f49c2
2016-09-17 16:33:39 +02:00
Aaron Schulz
6674490e7f Fix type doc in StatusValue
Change-Id: Ib0a3282083b2fd08ea76022b74b21b55da9b8a46
2016-09-16 17:38:10 -07:00
Aaron Schulz
75752d58ee Improve getErrorsByType() docs
Change-Id: I235a82ee1036d59a0f4929fc2170f261280f9b4d
2016-04-18 09:08:26 -07:00
Gergő Tisza
949641e36e Fix StatusValue phpdoc
Change-Id: Ie30ebf9bd89c4e2594e806a1b52f5716a32e11ec
2016-04-01 15:44:10 +03:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
addshore
b796300aa6 Fix phpdoc of StatusValue::merge
Change-Id: I6fec36f9911d647fa7507c36b57f6b11ef04d63d
2015-12-04 21:50:22 +01:00
Aaron Schulz
c15caa6d53 Split StatusValue out of Status class and put it in /libs
* Deprecated useless FileRepoStatus class

Change-Id: I015635a9bf080ef6d98b2cff49b949c4378a859f
2015-02-10 00:39:05 +00:00