Commit graph

103 commits

Author SHA1 Message Date
Tim Starling
99971a256e Undeprecate Status::getErrorsArray and ::getWarningsArray()
These were soft-deprecated in 1.25 with no rationale given, and without
a reasonable alternative. They remain widely used. They seem pretty
harmless to me.

Change-Id: I23242c2ee48488c8a5330e6607b939c3af722eeb
2023-05-22 10:32:40 +10:00
Gergő Tisza
34374aaa3e Status::getPsr3MessageAndContext: Special-case rawmessage
Do not try to parametrize rawmessage, which is intended to be
used like RawMessage (but avoids the latter's unexpected behavior
when e.g. copying to another message).

Bug: T334012
Change-Id: I6e6bf09bb7b7a599a52311965a5542be92e67fac
2023-04-05 18:49:54 +00:00
Gergő Tisza
452033493f
Status: Add method for PSR-3 formatting of status objects
Change-Id: Id76f55460ff10de9801f484d51fd8d504eaf9040
2023-02-17 20:00:02 -08:00
Umherirrender
1af3e211eb docs: Add missing StubUserLang type to some @param/@return
Change-Id: Ic1f192c7a21e529113fd7d537a79b2e4f8983b9c
2023-01-12 19:04:20 +01:00
Amir Sarabadani
523ab7cff8 Reorg: Move RawMessage to under language/
To follow Message. This is approved as part of RFC T166010.

Also namespace it but doing it properly with PSR-4 would require
namespacing every class under language/ and that will take some time.

Bug: T321882
Change-Id: I195cf4c67bd51410556c2dd1e33cc9c1033d5d18
2022-12-16 11:30:19 +01:00
Umherirrender
ea5ea60b31 Various doc fixes about false on method arguments/return types
Doc-only changes

Change-Id: I5177f582ae7ee70c357e9389fed14819faf79463
2022-11-10 19:23:46 +00:00
Amir Sarabadani
0fff5089ba Reorg: Move StubObject classes in includes to its own directory
Bug: T166010
Change-Id: Idcf0e9dc6e0841e4f132207bce0f96774dad898c
2022-10-25 16:04:48 -04:00
Tim Starling
0077c5da15 Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

I used regex replacement.

Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
2022-10-21 15:33:37 +11:00
Daimona Eaytoy
350e9b88c1 Fixes for the phan upgrade, part 1
Mainly, document some parameters as non-empty-array so that phan knows
the list of arguments won't be empty when unpacking.

In EditPage, account for hooks potentially unsetting the copyright
notice.

Also rewrite some code in LogPager, so it's hopefully easier for phan to
understand what's going on.

Change-Id: Ic0638571554424098d0743db32dd46723a08e103
2022-10-08 13:08:47 +00:00
Tim Starling
3e2653f83b ResourceLoader namespace (attempt 2)
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader itself.

Move the tests by analogy.

I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".

I did not address DependencyStore which continues to have a non-standard
location and namespace.

Revert of a241d83e0a.

Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
2022-05-24 15:41:46 +00:00
Bartosz Dziewoński
599223ce30 Status: Ensure MessageLocalizer is used if provided
Change-Id: I1eff51af271f7d6e4685a23360cd23c397593c53
2022-03-08 01:50:37 +00: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
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
Umherirrender
d790580fda Fix typos related to repeated words
Change-Id: Ibc187d95b003017255bc87adf56afae7a59bd3db
2020-09-27 10:25:36 +00: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
Umherirrender
3d27353cd2 Fix param type for Status::msgInLang
Message params could be an array or another Message object
Message class itself documented with mixed

Change-Id: Ia675ba2d2f5faa73904f90cc26e4f0e2d1317da5
2020-05-25 07:51:40 +00:00
Umherirrender
3161311c5a Use MediaWikiServices::getMessageCache
Change-Id: I07fcc9529991adc634c10e5ed8498ac138a1c2b7
2020-03-14 14:25:03 +01:00
Umherirrender
925e3eb30b Set method visibility in some classes
Change-Id: I3c3d59d4b3edf2459efeac890721a43475e27198
2019-12-05 17:42:55 +00:00
Umherirrender
c4d4d81ae4 Do not run wfEscapeWikiText on array in Status class
Message params could be more complex than a string
For example by use of Message::numParam()

Bug: T237559
Change-Id: I1be2ad3f73f189f69f955d1c4e1da75652e5e8ff
2019-12-02 13:51:11 +01:00
Umherirrender
34d5d3b087 Adjust doc of Status::getStatusArray
Change-Id: I28e248e02426a6414a7c9fbb895e7576b4b1f062
2019-11-07 21:34:49 +01:00
Gergő Tisza
c02ae7bbc2
Status: improve typehints
Follow-up to I82a2e4a83743.

Change-Id: I707a742d6446e0b4fd03b0375e93e106c7af214d
2019-10-31 14:23:34 -07:00
Gergő Tisza
dd01c6dd64
Allow injecting a message localizer into Status
The coupling of Status with the global request context for
Message object creation is a common pain point in unit tests and
in no-session code. As a short term solution (until Status is
properly deprecated) allow injecting a different localizer.

Also refactor the code a bit to get rid if the explicit need for
the context language (which is already implicit in the localizer).

Change-Id: I82a2e4a83743546a934fb938b94e877a2471a3d2
2019-10-30 17:10:22 -07:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Daimona Eaytoy
3439c00073 Suppress PhanUndeclaredProperty for custom properties and phan bugs
And remove the issue from the exclusions list.

Bug: T231636
Change-Id: Iee73ddb554e354abe52d13dcfc453f9a15bb8877
2019-09-14 13:22:54 +00:00
Derick Alangi
aea6cbdc42 Status: Make various improvements to the Status class
These improvements touches areas such as;
- strict comparison as count() returns in int.
- use of single quotes for string literals.
- use of RequestContext to get the user's Language object.
- fix minor typo.

The todo for using RequestContext was added in 7c543bb6c2.
It used `$wgLang` at the time for consistency with Message.php,
which was changed in 2016 with 0beb5ca992. Hence, it's now
fine here as well.

Change-Id: I943dfd761a8fca7e8b6658e3c9510ddc6694f042
2019-03-04 00:44:34 +00:00
Derick Alangi
f25ff9ff9a Add missing @return PHPDoc to __sleep() function
Change-Id: I97547938041264440af621694f08a067f1d0791f
2019-01-24 21:17:47 +01:00
Reedy
a075271157 Update composer/spdx-licenses to 1.4.0 and mediawiki/mediawiki-codesniffer to 21.0.0
https://github.com/composer/spdx-licenses/compare/1.3.0...1.4.0

Change-Id: I39f7a1310455159866bfed5224536e800befec0d
2018-07-26 17:44:28 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Brad Jorsch
e74ba29aa6 Use ParserOutput stateless transforms
We still set the state in many cases for benefit of extensions, but all
calls within core should no longer be using non-default state.

Change-Id: I78b62ec33fcb8273acb9b3b4e9012215442be94c
Depends-On: I140ff32373430b61b92226689ef9b58cca317450
2017-11-30 14:27:49 -05:00
Addshore
c02d643d86 Revert "Stop stubbing StubUserLang"
This reverts commit 7ab57ba290.

Bug: T177478
Change-Id: I28ac95ebcb64231a12c178165a0cb174e70f4e18
2017-10-05 16:52:49 +00:00
Chad Horohoe
7ab57ba290 Stop stubbing StubUserLang
Stub objects are confusing as heck and are a performance optimization
that really aren't fit for the modern era. They were designed to avoid
loading the actual code from the disk back in the days when bytecode
caching wasn't always gonna be there.

It's 2017. If you're using HHVM, you've got a bytecode cache. If you're
using any reasonably recent version of PHP then you've got the opcode
caching enabled by default in basically every distro-related build.

Nothing actually relies on this object being a stub (that'd be silly),
so only references are basically things force unstubbing (also kind of
silly) the object. Once remaining code referencing this in extensions
are all cleaned up then we can remove the class itself.

Change-Id: I15df24aeeb729e8e764792daa933377f35042fab
2017-10-03 21:54:34 +00:00
Gergő Tisza
223aa1e97e Improve Status/StatusValue::splitByErrorType type hint
Change-Id: I6deb76f8906aa86481b84ce1aaebaddf3a52e31d
2016-10-24 00:50:40 +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
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
Bartosz Dziewoński
a49b3216fc Canonicalise '@deprecated since' doc comments
Change-Id: I440041512feb47a998efb45e76e3fd00e0655752
2016-08-02 22:21:57 +00:00
Gergő Tisza
4d294bceab Fix Status::getMessage for the multiple errors, $shortContext only case
Remove $msgCount++ which does not seem to have any non-harmful purpose.

Also try to explain what the hell the method does.

Change-Id: Ibdf40ff13a4a9d294a6bc6f778a14fb2633c2f70
2016-06-07 20:39:01 +00:00
Gergő Tisza
9d4abcb025 Add some missing MW version documentation
* deprecate $wgAuth
* add @since for Status::getStatusValue

Change-Id: Ia11ef1e4788297ffea0a2beb4da731c7e771958c
2016-05-23 19:46:35 +02:00
Gergő Tisza
8a3819be84 Add Status::getStatusValue()
Change-Id: Id8c87373b560a462dcbffe74c9e7c4780c3147f3
2016-05-16 09:57:53 +00:00
Aaron Schulz
75752d58ee Improve getErrorsByType() docs
Change-Id: I235a82ee1036d59a0f4929fc2170f261280f9b4d
2016-04-18 09:08:26 -07:00
Brad Jorsch
7c543bb6c2 Allow passing a language into Status::getWikiText() etc.
This also corrects a bug in MessageCache::parse() where it takes a
language code string but the Parser expects a Language object in
ParserOptions.

Bug: T128809
Change-Id: I3508c9e515e505890b3c62bc4a0982aa2a313782
2016-03-09 22:35:19 +00:00
Brad Jorsch
ca4bba6a98 Fix use of RawMessage in Status::getMessage()
RawMessage::__construct() takes a single array of params, it's not
varargs-style like wfMessage().

Change-Id: I63950ee16e359aa2627228350e27d9e94bb6e8ce
2016-03-02 12:36:22 -05: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
Aaron Schulz
b4ff14f730 Cleanups to MigrateFileRepoLayout
* Use "bypassReadOnly" as other file backend maintenance
  scripts do.  One may want to run this while site traffic
  is off via $wgReadOnly.
* Fixed handling for when img_sha1 is not set.
* Fixed some IDEA errors.

Change-Id: I95c426c5f2082576fc9ea40282d2869750a9f3d8
2015-10-04 21:45:25 -07:00
Bartosz Dziewoński
63b96dcdd9 Status: Correct documentation
Most of the docs for this class look misleading or downright incorrect...

Change-Id: I4c7397a5dfeca7447cb98611c4f3befaefaefaba
2015-08-06 13:50:47 +02:00
Aaron Schulz
a2ea6116af Fixed some <code> tags for doxygen
Change-Id: I550b8760556e4916ee9b63ee244bbbcb4d926142
2015-04-29 06:01:59 +01:00
Mark Holmquist
7a84402108 Fix magic getter for $status->ok
__get called a non-existant function which caused errors
in file deletion.

Also adds tests for $status->ok and $status->errors

Change-Id: I8f5a21eb8d795e5e3f5a58f2384ad0dcbad749a2
2015-02-14 00:05:41 +00: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
umherirrender
489d793882 Fixed spacing
- Added/removed spaces around parenthesis
- Added newline in empty blocks
- Added space after switch/foreach/function
- Use tabs at begin of line
- Add newline at end of file

Change-Id: I244cdb2c333489e1020931bf4ac5266a87439f0d
2014-12-05 22:28:07 +01:00
saper
110d5ccea0 Provide Status::__toString()
maintenance/eval.php is much easier to use now,
you can just print $statusInstance;

Change-Id: I068b0f54b16d618a1f6115133632885e8e45e897
2014-11-11 23:16:34 +01:00