Commit graph

8805 commits

Author SHA1 Message Date
Bartosz Dziewoński
7b212efcac Replace some manual checks and exceptions with type hints
Noticed while reviewing I2e640b9737cb68090a8e1cb70067d1b74037d647.

Change-Id: I9b95b56ffd64cc438d5071046a9f038e4d3dc799
2024-09-17 21:33:08 +00:00
Adam Wight
188d2cbbb0 Remove unchecked exception annotations
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
2024-09-17 22:20:58 +02:00
jenkins-bot
78a48b9a45 Merge "ApiParse: don't reparse language link titles" 2024-09-17 03:31:40 +00:00
C. Scott Ananian
01876b0121 ApiParse: don't reparse language link titles
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
2024-09-16 19:34:02 -04:00
jenkins-bot
a27ade70ee Merge "Use const keyword for constant list of strings or ints" 2024-09-13 18:08:57 +00:00
jenkins-bot
c8d4728813 Merge "api: Add missing documentation to class properties" 2024-09-12 23:20:10 +00:00
Umherirrender
465777f188 Use const keyword for constant list of strings or ints
Also changed visiblity of some to private

Change-Id: I113b040321d27c84fe9b807c162736909e96fb20
2024-09-11 23:16:24 +02:00
Umherirrender
512aadac31 Use type declaration for class properties holding type hinted arguments
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
2024-09-11 20:08:50 +00:00
Translation updater bot
3d2c3032fd
Localisation updates from https://translatewiki.net.
Change-Id: Ia965b94753aa0a16be1deef703977b909b1f4dce
2024-09-10 09:01:15 +02:00
jenkins-bot
65f6dcb558 Merge "editstash: migrate ApiStashEdit to statslib" 2024-09-09 18:06:12 +00:00
Aaron Schulz
e63f87b0dc editstash: migrate ApiStashEdit to statslib
Bug: T359465
Change-Id: Id5aa4000e8b8bbb13b0ccd4d7cdf8bb355963ad7
2024-09-09 09:39:16 -07:00
Dreamy Jazz
24d8b04558 Return early in ApiLogout if user not logged in
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
2024-09-09 13:47:50 +01:00
Translation updater bot
b692f6210e Localisation updates from https://translatewiki.net.
Change-Id: I55d48a6c8844e87442f46a368f0e4112896825d3
2024-09-09 08:45:22 +00:00
Ebrahim Byagowi
7db85051f8 Avoid use of deprecated wfParseUrl in MediaWiki\Api
Change-Id: Idd0f98ccb449735b5244bb7531327be763daceb8
2024-09-08 21:15:44 +03:30
Umherirrender
3fca49a1f4 api: Add missing documentation to class properties
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
2024-09-07 22:22:13 +02:00
jenkins-bot
784804f1a8 Merge "rdbms: Migrate MediaWiki.rdbms_trxprofiler_warnings to statslib" 2024-09-07 19:47:58 +00:00
Larissa Gaulia
3bd0435eaa rdbms: Migrate MediaWiki.rdbms_trxprofiler_warnings to statslib
* Remove StatsdAwareInterface
 * Remove setStatsdDataFactory()
 * Add setStatsFactory()
 * Migrate api and action setStatsdDataFactory() usage.

Bug: T359366
Change-Id: Ic4e82c24d3b1cdca638b22885902cc441d8510b8
2024-09-07 19:18:11 +00:00
jenkins-bot
15bfd2e9f8 Merge "Remove ParserOutput::getText() calls from core (runOutputPipeline)" 2024-09-06 19:39:11 +00:00
Isabelle Hurbain-Palatin
ce2bccc0a8 Remove ParserOutput::getText() calls from core (runOutputPipeline)
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
2024-09-06 19:07:49 +00:00
Fomafix
b43860cc09 Add new hook OutputPageRenderCategoryLink
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
2024-09-05 15:53:43 +00:00
jenkins-bot
5b6859aab1 Merge "api: Avoid assignment in condition in ApiLogin" 2024-09-03 10:10:23 +00:00
Translation updater bot
909aac2eca Localisation updates from https://translatewiki.net.
Change-Id: I765638759751cb748490d3f2a3391854ae1dd986
2024-09-02 08:18:40 +00:00
Umherirrender
3c8dd16d93 api: Avoid assignment in condition in ApiLogin
Change-Id: Ic2bcc7eeb16d3333dcd019bd209bd7fde843dab9
2024-09-01 00:06:04 +02:00
Aaron Schulz
1e138c9340 api: make ApiMain::getUserAgent() only use api-user-agent when set
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
2024-08-30 00:38:29 +00:00
jenkins-bot
4f323be830 Merge "api: Use MW_INSTALL_PATH in ApiBase" 2024-08-29 18:59:34 +00:00
jenkins-bot
4474aaf440 Merge "Allow ApiParse to use the ArticleParserOptions hook" 2024-08-29 17:00:00 +00:00
C. Scott Ananian
9dbce134c6 Allow ApiParse to use the ArticleParserOptions hook
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
2024-08-29 11:33:35 -04:00
Translation updater bot
3624d128c4
Localisation updates from https://translatewiki.net.
Change-Id: I61445bcd27320e74d47d85cc4fc938f8544e84a1
2024-08-29 09:04:03 +02:00
Timo Tijhof
d5a044ba35 api: Use MW_INSTALL_PATH in ApiBase
Does not need to be configurable.

Change-Id: Iaf58333db54a09af1dca2f39bbb86d256e7eb0a0
2024-08-29 02:47:46 +01:00
Translation updater bot
f0aecf7235
Localisation updates from https://translatewiki.net.
Change-Id: Ic5cfc584d8047dcd8f68e6b4a7e6a23a46e0bee4
2024-08-28 09:07:09 +02:00
jenkins-bot
2d587f8187 Merge "Clarify Action::requiresWrite() and ApiBase::isWriteMode() comments" 2024-08-26 18:21:06 +00:00
jenkins-bot
356e1709fa Merge "Make use of the ??= and ?? operators where it makes sense" 2024-08-26 17:16:23 +00:00
Aaron Schulz
8938ec6ded Clarify Action::requiresWrite() and ApiBase::isWriteMode() comments
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
2024-08-26 09:28:30 -07:00
thiemowmde
dca4931b42 Make use of the ??= and ?? operators where it makes sense
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
2024-08-26 09:26:36 +02:00
Translation updater bot
b371b0623e Localisation updates from https://translatewiki.net.
Change-Id: I7e7af2daaa92635881e5fc6840c6b11ae307c673
2024-08-26 07:14:14 +00:00
Timo Tijhof
91f0237cfa recentchanges: Improve docs, fix file headers, fix doc groups
* 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
2024-08-22 23:30:55 +01:00
Translation updater bot
48d236c669
Localisation updates from https://translatewiki.net.
Change-Id: I9ea7d1ef388af399da0cfc1cc2104d8fa579c7ac
2024-08-22 09:01:50 +02:00
jenkins-bot
2d8677e77f Merge "Fix specifying messages with params as arrays in API documentation" 2024-08-21 14:59:11 +00:00
Bartosz Dziewoński
0c0d50ce81 Fix specifying messages with params as arrays in API documentation
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
2024-08-21 13:26:02 +00:00
jenkins-bot
1b25d273f8 Merge "API: clarify the meaning of write access" 2024-08-20 16:53:21 +00:00
jenkins-bot
3ddf03c3f8 Merge "Deprecate ApiBase::makeMessage" 2024-08-16 18:17:01 +00:00
theprotonade
12a4c08ad8 Deprecate ApiBase::makeMessage
Replace usages of ApiBase::makeMessage
with ApiBase::msg and deprecate the former
method

Bug: T370240
Change-Id: I9e6e775dad7f3e3cfd78351f87f4732677d90971
2024-08-16 12:09:33 -04:00
Translation updater bot
aa98ad8c6a
Localisation updates from https://translatewiki.net.
Change-Id: I858b92a5c8e04541ea3aa6fde6fc29d83dd34e41
2024-08-16 09:03:44 +02:00
daniel
f26d068c33 API: clarify the meaning of write access
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
2024-08-13 17:20:24 -07:00
Translation updater bot
b4b84bb5f5 Localisation updates from https://translatewiki.net.
Change-Id: I00eda4ce7eb827c644f88dd749beee958b76778d
2024-08-13 10:51:59 +00:00
Translation updater bot
803e854a20 Localisation updates from https://translatewiki.net.
Change-Id: If602f5635de9c22f25fb96ff90333f4a6144d1d8
2024-08-12 07:33:18 +00:00
James D. Forrester
bc662aec9b Move Language and friends into Language namespace
Bug: T353458
Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
2024-08-10 13:36:30 +02:00
Ebrahim Byagowi
697e19e461 Add MediaWiki\Registration namespace to registration classes
Bug: T353458
Change-Id: Ifa3b6a6e0353bb4ce21a3f4456f1fc696c8d377c
2024-08-10 10:08:22 +00:00
jenkins-bot
a03b19a19b Merge "ApiBase: Deprecate unused ApiBase::errorArrayToStatus()" 2024-08-08 10:10:20 +00:00
jenkins-bot
ad49d36f4b Merge "Revert "Drop writeapi flag from siteinfo API"" 2024-08-07 16:52:44 +00:00