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
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
* 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
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
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
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
RawMessage::__construct() takes a single array of params, it's not
varargs-style like wfMessage().
Change-Id: I63950ee16e359aa2627228350e27d9e94bb6e8ce
* 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
__get called a non-existant function which caused errors
in file deletion.
Also adds tests for $status->ok and $status->errors
Change-Id: I8f5a21eb8d795e5e3f5a58f2384ad0dcbad749a2
- 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
We already have Status objects throw away the cleanupCallback in
__wakeup. Why not also implement __sleep to not save it in the first
place?
The immediate motivation here is that cleanupCallback could be a
Closure, which causes an exception when serialization is attempted (e.g.
when trying to save the Status if an AssembleUploadChunks job fails
verification).
Note this leaves __wakeup intact, in case of old objects where
cleanupCallback is still present in the serialized representation.
Change-Id: I3aa756cd4eb5553ce0b95e7088b929b2f529abfe
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling
Change-Id: I783e4dbfe5f6f98b32b9a03ccf6439e13e132bcc
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.
Change-Id: I0056b4a8df243cfc0c5f25378de48f7a35170aca
Also swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Change-Id: Ic36c8c7820a6c2d603f1138130670c6bf6a1ca59
This mistake was introduced in commit
92e284d3fa and the reason for the two
disabled tests. I did not enabled the second test because of an
unrelated problem. The first enabled test already covers the fix.
The method should return Message objects only but did return a
string in that special case (multiple warnings set but no context
message key).
Unfortunatelly Status::getMessage does have many, many more
problems but I understand it's not a good idea to address them all
in a single confusing patch.
Change-Id: I0dc37e248f407019d5921aaaca3eabba338b0fd3
Currently it only returns wikitext with templates expanded (like
Message's text() method).
Bug: 45844
Change-Id: I24b5b098f15d0a4194817f31f63e37be1179aae6
Account creation messages don't need to be parsed. This is
a temporary fix to follow up when double-parsing was accidentally
added in 69ea440003 (I402c6bebcfe).
Bug: 44718
Bug: 52191
Change-Id: I333d5468820994625348316ebf6c57d4df025284
Tim posted a nice explanation of the recommended pattern for using the
Status object to wikitech-l. This change copies that explanation into
the phpdoc comment block of the Status class in an attempt to propagate
the meme.
Change-Id: Ia98543caaa829cad443abf0f0f5038b3de943ef8
Also fixes Message::getKey() to always return a string.
Rationale:
Some code, like RollbackAction, assumes that Status::getErrorArray will
return an array of the form ( messagekey, param... ), but this was not
the case when a Message object was passed to the Status.
This change makes sure Status::getErrorArray will always return arrays
of the expected form. This is especially important since the messages in
the Status object may be provided by extensions.
In order to convert Message objects to arrays of message keys and parameters,
Message::getKey() needed to be fixed to return a single key always.
Bug: 49338
Change-Id: I0deaa9888e9d86726a8e41ca606c571f56190c91
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !
Fixed windows newline style
Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.
Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
Being able to get the message key and parameters from a Message object
is needed to be able to report errors from the API in an abstract,
language neutral way.
Change-Id: I8ee9da4005db7cb0a487457127f1e24fb11dbd66
Adjusted internal Status functions so that a Message
object can be passed as an error message instead of just
a string. Also removed deprecated message functions in
the process.
Change-Id: Icb4b5edeb25190f0aba4f3096a9ea94f22c27bda
Signed-off-by: Tyler Romeo <tylerromeo@gmail.com>
Fix the DB error which comes from User::addToDatabase() if it is called
when the user already exists. This is the most common DB error we log at
WMF in normal operation, perhaps because of double clicks on the "create
account" button, or perhaps due to CentralAuth autocreation when
multiple pages on another wiki are opened in the browser simultaneously,
as the bug reporter suggests.
See the doc comment for the interface rationale. Patched
Special:Userlogin to be aware of the new return value. Most extension
callers will continue to work, I will patch a couple that need it in
subsequent commits.
Change-Id: I1f6ef5e6319bfe692fb82a3fa50dc66c9fde8f15
Removed Status::getXML and its single usage in one of the
phpunit maintenance scripts. It is not used anywhere
in any known extension.
Change-Id: I676446647681059449c46c2ff109570a060e0e20
Signed-off-by: Tyler Anthony Romeo <tylerromeo@gmail.com>
Also made file/class documentation more consistent and removed a duplicate comment from SpecialPageFactory.php in SpecialPage.php.
Change-Id: I99dd2de7fe461f2fad4e0bd315ebc2899958a90f