| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
| |
wfDeprecatedMsg was replaced with trigger_error for better alignment
with non-MediaWiki environments.
Change-Id: Icc5a58cb2eccf26def393a9715ab5089cf4b7951
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Applied return type hints to improve type safety in Message classes.
Adjusted constructors to specify parameter types for consistency.
Enhanced `newFromJsonArray` in `ScalarParam`, `DataMessageValue`,
and `MessageParam` to clarify deserialization logic.
Key updates:
- Added `: string` return types for `getLangCode`, `getKey`, `dump`.
- Added `: array` return type for `getParams`, `getData`, `toJsonArray`.
- Revised `ScalarParam` JSON parsing to ensure a consistent return.
These adjustments enhance type safety across the Message classes.
Depends-On: Id7cc576693f5f1830e1d261cb13c626c901fb40f
Depends-On: I260e3f526be10f7b11e5c77a1e300590c6fc5b2b
Depends-On: I3c318273856d15407c71cb9b4ab7c23a0debb314
Change-Id: I7e50be91c01b4b70e1d1380651f001e35bd60523
|
|
|
|
|
| |
Bug: T378876
Change-Id: Iecbf83dd060b2a1dc30bd33bfc4f2a42cfbd2a1f
|
|
|
|
| |
Change-Id: I8ed6498acb4657c69b58a24fc3cc45f585a31b7d
|
|
|
|
|
|
|
| |
Deprecated in I492edabb7ea1d75774b45eb9fd18261b39963f9f.
Bug: T278482
Change-Id: Ie9350ed0d7b2604fb4d2f440dee66964fe198c0e
|
|
|
|
|
|
|
|
|
| |
This can cause PHP to try to load the param value as a class, with
potentailly disastrous results (though it’s not quite clear if this can
actually cause attacker-supplied code execution or not).
Bug: T377912
Change-Id: I0239b3e65cf516c6fdf287882f05e47a01f963c1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix two problems that made it difficult to convert between Message
and MessageValue, or to write code that could accept both of them,
as exemplified by the StatusValue class:
* Implement a common interface
* Use the same internal format for message parameters
While these changes should be compatible with most of existing code,
where the authors were courteous enough to simply call methods such
as Message::numParam() and not look inside the values they return,
it is potentially a breaking change for anything that depended on
the formatted params being arrays or accessed their keys.
Example patches: https://gerrit.wikimedia.org/r/q/topic:message-param
Notable changes:
* Message and MessageValue now both implement MessageSpecifier
(only Message implemented it before).
* Message::numParam() and other static methods for encoding params
now return MessageParam objects, instead of special arrays.
Use these MessageParam objects internally in Message.
* Narrow down the return type of MessageSpecifier::getParams() (it
was just `array`, allowing any type in the array). Narrow down the
types for Message::params() and MessageValue::params() to match.
* Deprecate MediaWiki\Message\Converter. As a replacement add
MessageValue::newFromSpecifier(), which is analogous to
Message::newFromSpecifier(), but without weird legacy edge cases.
* Make StatusValue::getMessages() return MessageValues. Remove code
that converted between Message and MessageValue, no longer needed.
* Update many type declarations and comments to use MessageSpecifier
instead of MessageValue, as well as a couple of tests that depended
on implementation details.
Bug: T358779
Change-Id: I625a48a6ecd3fad5c2ed76b23343a0fef91e1b83
|
|
|
|
|
|
|
| |
They're protected in JsonDeserializableTrait,
and weren't meant to be made public.
Change-Id: Icda0c58d42730b1dd66a9eb69245bb1f9a15962b
|
|
|
|
|
|
|
|
|
| |
* Add getters for the lists of valid types
(named cases() like in PHP 8.1 enums)
* Validate that the provided type is in the list
* Replace funky use of reflection in Converter
Change-Id: I8da89edbb943fae8920c15b1bc6856ce97a4de7a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
get_debug_type() does the same thing but better (spelling type names
in the same way as in type declarations, and including names of
object classes and resource types). It was added in PHP 8, but the
symfony/polyfill-php80 package provides it while we still support 7.4.
Also remove uses of get_class() and get_resource_type() where the new
method already provides the same information.
For reference:
https://www.php.net/manual/en/function.get-debug-type.php
https://www.php.net/manual/en/function.gettype.php
To keep this safe and simple to review, I'm only changing cases where
the type is immediately used in an exception message.
Change-Id: I325efcddcb58be63b1592b9c20ac0845393c15e2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Follow-up to f18362cccec27335084d35e1c2dfc1e9ddd1893c.
While working on I625a48a6ecd3fad5c2ed76b23343a0fef91e1b83,
I learned that Stringable objects are sometimes also used
as normal params, intended to be stringified when rendering.
For example, see `this->target` in the UnblockUser class.
That code uses Message objects, so it's not causing trouble,
but converting them to MessageValue would emit warnings.
I didn't actually intend to deprecate that, and it won't
cause issues with JSON-serializability (assuming we stringify
the objects in time), so tweak how the warnings are emitted.
Change-Id: I26dfd4f1ac8ed08a422692de4e39d072242c08df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
MessageValue and friends are pure value objects and newable, so
it makes sense for them to be (de)serializable too. There are some
places where we want to serialize messages, such as in ParserOutput.
The structure of the resulting JSON is inspired by the way we
represent Message objects as plain values elsewhere in MediaWiki,
e.g. StatusValue::getStatusArray().
Co-Authored-By: C. Scott Ananian <cscott@cscott.net>
Depends-On: Ia32f95a6bdf342262b4ef044140527f0676402b9
Depends-On: I7bafe80cd36c2558517f474871148286350a4e76
Change-Id: Id47d58b5e26707fa0e0dbdd37418c0d54c8dd503
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This functionality was introduced in 2021 (commit 349819dc5a)
to support the addition of UserGroupMembershipParam, which was
never used, and no other use case appeared.
Its existence is now preventing us from allowing serializing
of MessageValue objects as JSON (since the parameters can't be
guaranteed to be serializable).
Deprecate:
* method: MessageValue::objectParams()
* method: Message::objectParams()
* method: Message::objectParam()
* class: UserGroupMembershipParam
* constant: ParamType::OBJECT
* Passing Stringable objects to ScalarParam
Change-Id: I492edabb7ea1d75774b45eb9fd18261b39963f9f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It was asked in a patch review to apply fully import
InvalidArgumentException where possible. I was guessing some
of my other already merged patches have but turned out such
thing exists other places style so for the sake of consistency
I've turned rest of inline import of the specific exception at
top of the file.
There are instances of source files that aren't in any namespace but
have fully qualified import which this patch doesn't touch.
Change-Id: I4071fc698b65746d9594cf4d5f45bae82843d436
|
|
|
|
|
|
|
| |
* Added ParamType::OBJECT, which allows Stringable objects to be passed into MessageValue
Bug: T278482
Change-Id: Ib4990f87d4ad70b7525d7aa05c8b97e90c121674
|
|
|
|
|
|
|
|
|
|
|
| |
For compliance with the new version of the table interface policy
(T255803).
This patch was created by an automated search & replace operation
on the includes/ directory.
Bug: T257789
Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
|
|
|
|
|
|
|
|
| |
This annotates classes that can safely be instantiated by
extensions, per the Stable Interface Policy.
Bug: T247862
Change-Id: Ia280f559874fc0750265ddeb7f831e65fd7d7d6a
|
|
|
|
|
|
|
| |
Validate that all parameters are of expected types, not just list
parameter values.
Change-Id: Id47c6f9ad1cf3a3dfc1f6d0c3766ba607c4ef633
|
|
Among other things, this removed mention of MediaWiki classes from the
library and adds a README.md that attempts to define constraints for
interoperability between libraries producing MessageValues and formatter
implementations that are expected to handle them.
This also renames "TextParam" to "ScalarParam", as that seems a more
accurate name for the class.
Change-Id: I264dd4de394d734a87929cf4740779e7b7d0e04a
|