Callers should not catch an unchecked exception, so it doesn't belong
in a function signature. Unchecked exceptions indicate a coding error,
which by definition the code will not be able to handle correctly.
If any of these exceptions were supposed to be in response to an edge
case, user input, or initial conditions, then they should be changed
to a runtime error. If the exception class cannot be changed, then
the annotation should include a comment explaining its purpose and
prognosis.
Bug: T240672
Change-Id: I2e640b9737cb68090a8e1cb70067d1b74037d647
When there are conflicts between namespace prefixes and interwiki prefixes,
ApiParse was inadvertently converting from an interwiki link to a local link
by reparsing the title. Use a TitleValue as an intermediary to ensure
the interwiki link stays an interwiki link.
Bug: T204792
Bug: T363538
Change-Id: I6a94350b781539de2390070e4bcbad4b19eba78f
Provided arguments already have type declaration on the construtor
and it is safe to use the same type on the class property
Change-Id: Ia8bbdc4dee59dfb487582dd514486ec8542951be
Why:
* The 'logout' API allows users to logout of their account
* This calls the "UserLogoutComplete" hook which users assume
is only called when a logout is successful.
* However, the hook is called by the API even if the user making
the request was not logged in
* The Special:UserLogout page does not call the hook if the user
performing the request is already logged out.
What:
* Return early in ApiLogout::execute if the user is not logged
in, and also add a warning to the response to indicate this.
Bug: T374353
Change-Id: I72e73c2391a475cec2e5cb24250f9aa2b792e5de
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.
Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.
Change-Id: I8b33b5f4d91c1935228e7010327dbc6ce138fc00
This is the fourth patch of a series of patches to remove
ParserOutput::getText() calls from core. This series of patches should
be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e.
Here we replace calls to getText where a ContentRenderer is available
close by by temporary ParserOutput::runOutputPipeline that will
eventually be replaced by a call to (probably) ContentRenderer
(T371004). Doing this work in stages allows us to separate the work of
"bring ParserOptions to the call site" from the work of "bringing
ContentRenderer(ish) to the call site", since both need to be done for
to make ParserOutput a value object (T293512).
Change-Id: Ib4f9357293dc230df6e0ca2379a1e2a4cc1b91b7
Bug: T293512
This allows to change the category link rendering by extension
CategoryTree without missing update of mCategoryData and mCategories
which leads to wgCategories = [] (T372155).
The new hook will be used in extension CategoryTree by
Ic86f210474cbc0e2dcebf664cf2309a4a4408f60.
Bug: T372155
Change-Id: Id82a77a57d1f12233d974ea4c1b093f50c5ab74f
This avoids data bloat in feature usage logging and tracking,
reducing the chance of truncation, and makes it easier to search
these records.
Note that all uses of this method are tied to deprecated API
feature use reporting.
Bug: T313731
Change-Id: Ie097ad21959fbcedc33da407145a7aad573a361e
Extensions can use the ArticleParserOptions hook to customize the
parser options used for article read views, and Visual Editor uses
ApiParse to regenerate the article read view HTML after edit. In
order for VE to remain consistent with the original parse options,
provide a `usearticle` option to the parse API to allow it to invoke
the ArticleParserOptions hook.
Bug: T373212
Change-Id: I906affc8d2335b7bb48dff3a4b061fcf86b71cee
Make the description of Action::requiresWrite() better align with
Action::doneWrites(). These methods should be combined at some point.
Further discourage system state dependencies in ApiBase::isWriteMode().
Change-Id: I5ee18c8c15f6f360d01d63ee6e7299babb5bdea7
This touches various production classes and maintenance scripts.
The code should do the exact same as before. The main benefit is that
the syntax avoids any repetition.
Change-Id: I5c552125469f4d7fb5b0fe494d198951b05eb35f
* Define "RecentChanges" doc group and add all classes in changes/
and rcfeed/ to the group, as well as a few obvious classes
that we (currently) maintain in vertical buckets: maintenance,
api, specials.
* Doc group "Change tagging" was invalid because a group identifier
must be a single word, and this was thus passing an unexpected
second argument to the `ingroup` Doxygen command.
As such, it was missing on
https://doc.wikimedia.org/mediawiki-core/master/php/
Define "ChangeTags" properly and fix/add classes in this component.
* Add missing `ingroup` to class blocks (and remove from any file blocks)
as otherwise the file is indexed twice (e.g. in Doxygen) which makes
navigation on doc.wikimedia.org rather messy.
Remove duplicate descriptions from file blocks in favour of class
doc blocks. This reduces needless duplication and was often
incorrect or outdated, and helps make file headers more consistently
(visually) ignorable.
Ref https://gerrit.wikimedia.org/r/q/message:ingroup+is:merged
* Minor improvements to class descriptions here and there.
Test plan:
* `php maintenance/mwdocgen.php --file includes/changes,includes/changetags,includes/rcfeed`
(This will emits harmless warnings about undefined "Hooks" group,
because it's referenced but not included in this fast subset.)
* open docs/html/index.html
Bug: T364652
Change-Id: Ifac20da51f7e809f1a9ccbfac3bf50e739a083ea
Follow-up to 12a4c08ad8.
I didn't review it carefully enough to notice that when these
functions return arrays, they contain a message key and parameters,
not a key and fallback keys (while other API documentation message
code uses fallback keys).
Instead of `$this->msg( $msg )`, this code must be written as
`is_array( $msg ) ? $this->msg( ...$msg ) : $this->msg( $msg )`
or `$this->msg( Message::newFromSpecifier( $msg ) )`, both of which
are ugly, but the latter looks a bit better to me.
Bonus changes:
* Add documentation to prevent a repeat of this mistake in the future
* Remove some unreachable dieDebug() calls (the Message class already
throws for bad inputs)
It seems that we don't have any definitions using such arrays
in the core API classes. There are only a few uses in extensions,
e.g. AbuseFilter's 'apihelp-query+abuselog-param-filter' message,
which is passed the wrong parameter without this change.
Bug: T372988
Change-Id: I44c1c3c7d0c069e500c85a58c27e9b675b0b68ee
Replace usages of ApiBase::makeMessage
with ApiBase::msg and deprecate the former
method
Bug: T370240
Change-Id: I9e6e775dad7f3e3cfd78351f87f4732677d90971
Improve docs for Handler::needsWriteAccess and ApiBase::isWriteMode()
by explaining the contract in terms of what is observable from the
client. Essentially, no write access is needed if the request is "safe"
in the sense defined by RFC 7231 section 4.2.1.
Change-Id: Ifab56a8d6bea3ad4c5282f30bb4eb8d8f5a719b9