Commit graph

111 commits

Author SHA1 Message Date
jenkins-bot
15bfd2e9f8 Merge "Remove ParserOutput::getText() calls from core (runOutputPipeline)" 2024-09-06 19:39:11 +00:00
jenkins-bot
e9409ac31d Merge "Introduce runOutputPipeline and clone by default" 2024-09-06 19:37: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
Isabelle Hurbain-Palatin
cd3240f044 Introduce runOutputPipeline and clone by default
This is the third 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 temporarily introduce runOutputPipeline in ParserOutput. It
creates and runs the pipeline with default options, and is called by
getText. (This is not entirely truthful because we go through a
runPipelineInternal transient method for null-argument-passing reasons,
but let's not over-complicate this commit message.)

getText is responsible for maintaining the current behaviour,
that is "disallow the cloning of the ParserOutput and putting text back
to as it was" to mitigate T353257. As we get rid of getText, this
behaviour should be moved, if necessary, to the caller site.

The new method is currently added to ParserOutput so that further
refactorings are, for the moment, simpler. It will eventually be moved
to another place within the Content framework.

We also rename 'suppressClone' to 'allowClone' (which is actually its
negation) to avoid multiple levels of negations that make the code
confusing. Note that the default value of 'allowClone' is true, and is
currently overriden in two places: getText and
OutputPage::getParserOutputText (which calls the pipeline directly and
not through ParserOutput).

Bug: T293512
Bug: T371022
Change-Id: Ibf04af1079aaa1934dc78685b00e636ff4d38a9a
2024-09-06 19:06:38 +00:00
jenkins-bot
07437e797b Merge "Add missing documentation to class properties (frontend-related)" 2024-09-06 08:07:40 +00:00
Umherirrender
ca8b1eb476 Add missing documentation to class properties (frontend-related)
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: Id75cb2e5fbee0fe7600f92473d876f23730d46b7
2024-09-05 21:41:19 +02: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
C. Scott Ananian
493df826b9 Add option to sort categories in OutputPage
Some wikis treat the category list from ParserOutput as a /set/, others
as an /ordered list/.  For those who don't care about the order of
categories, provide the option for wikis to sort the categories
in OutputPage.

This can also be activated with a query parameter, `&sortcat=1`, which
is useful to the Parsoid team when doing visual diff testing to avoid
false positives caused by differences in category ordering.

Bug: T373480
Change-Id: Idd14650a1898c6a49c88441ef024ce3012903bbe
2024-08-29 12:20:19 -04:00
C. Scott Ananian
3739467256 Deprecate OutputPage::setCategoryLinks()
This method has a weird behavior where it resets the category *link* list
while not resetting the category *list*.  It turns out that no one actually
needs that weird behavior; in fact no one needs this method at all, since
the only external user is the Translate extension, which could use the
OutputPage::addCategoryLinks() method instead, which has existed since
2014 (Id25041a7891f588ffa787fdd2c092342eecd30c8).

Deprecate this method with warnings.

Bug: T373480
Depends-On: Id25041a7891f588ffa787fdd2c092342eecd30c8
Change-Id: I7b07d761eb8cd5ad1e6da2dd836e969a0d492c2b
2024-08-27 22:42:09 +00:00
Isabelle Hurbain-Palatin
a3cf629d2f Remove ParserOutput::getText() calls from core (direct pipeline)
This is the second patch of a series of patches to remove
ParserOutput::getText() calls from core. This series of patches should
be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e.

This patch replaces the calls to getText where the legacy parser is
called directly by creating a pipeline and invoking it on the generated.
These should probably eventually use the Content framework to generate
output instead of using Parser directly (T371008), which will also allow
them to transparently support Parsoid.

Bug: T293512
Change-Id: I45951a49e57a8031887ee6e4546335141d231c18
2024-08-23 18:15:00 +02: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
jenkins-bot
22163e47a7 Merge "Add MediaWiki\Registration namespace to registration classes" 2024-08-10 11:33:27 +00:00
jenkins-bot
2c98129419 Merge "Move remaining four classes in includes/content into Content namespace" 2024-08-10 11:11:26 +00:00
Ebrahim Byagowi
697e19e461 Add MediaWiki\Registration namespace to registration classes
Bug: T353458
Change-Id: Ifa3b6a6e0353bb4ce21a3f4456f1fc696c8d377c
2024-08-10 10:08:22 +00:00
James D. Forrester
f7ce0a0976 Move remaining four classes in includes/content into Content namespace
Bug: T353458
Change-Id: Ia0f3e22078550be410c4b87faf6aa4eabe6e270d
2024-08-10 10:40:53 +02:00
Bartosz Dziewoński
3d40cde987 Deprecate more methods dealing with legacy error arrays
* PermissionStatus::toLegacyErrorArray() (soft-deprecated)
* OutputPage::showPermissionsErrorPage() (hard-deprecated)
* OutputPage::formatPermissionsErrorMessage() (hard-deprecated)

Depends-On: I5493deb8b72f499ecd46b8093b5fffbb12e7c246
Depends-On: Iee1dd844d36037982b9927e95d7519da87251ca1
Depends-On: Ic217af5f9766ae2d7850597a4aec1a890d58766f
Depends-On: I62c324b656ab4262fd3f4e252057802a5367f8f9
Change-Id: Ia2d590779176ae060a0567a143697436230c67a9
2024-08-09 17:30:21 +02:00
jenkins-bot
33aae1deec Merge "Hard deprecate various public or protected properties of OutputPage" 2024-08-08 11:08:57 +00:00
C. Scott Ananian
2a5a1ba6c2 Hard deprecate various public or protected properties of OutputPage
These were soft deprecated in 1.38, it's time to emit deprecation warnings
so we can complete their removal from the public API.

Change-Id: I437ab7dc8af4eb5d336e8074a42a0a54b4c00a4b
2024-08-01 15:00:54 +01:00
Bartosz Dziewoński
d20454f468 OutputPage: Add showPermissionStatus(), deprecate showPermissionsErrorPage()
Now that PermissionManager can produce a PermissionStatus (1fbe8b761),
we need a way to display it without going through legacy error arrays.

Test plan:

* While logged out, access a page that all logged in users can access,
  that uses the PermissionsError class (e.g. Special:Upload)
* While not an administrator, access a page that only administrators
  can access, that uses the PermissionsError class (e.g. Special:Block)

Verify that you see the same error messages before and after this
change.

Change-Id: If21200ea1dd66f6443b03625d6a5b8ea416b2922
2024-07-29 23:33:50 +00:00
jenkins-bot
2134c3ef12 Merge "OutputPage: Inline getCdnCacheEpoch() into checkLastModified()" 2024-07-29 14:03:12 +00:00
Bartosz Dziewoński
c9f73efd5a Namespace MessageSpecifier under Wikimedia\Message\
In change I625a48a6ecd3fad5c2ed76b23343a0fef91e1b83 I am planning to
make Wikimedia\Message\MessageValue use it, and we try to pretend that
it is a library separate from MediaWiki, so it makes sense to move
MessageSpecifier to the same namespace under Wikimedia\.

Bug: T353458
Change-Id: I9ff4ff7beb098b60c92f564591937c7d789c6684
2024-07-28 14:21:32 +02:00
Timo Tijhof
0ea6d7ff32 OutputPage: Inline getCdnCacheEpoch() into checkLastModified()
This useless function contains useful documentation, that is best
kept with the rest of the business logic. It is only used once and
is literally `a - b`.

Change-Id: I650c37c4655bcc6edcd12186b24b0b1bd3faafd2
2024-07-26 15:49:25 -04:00
jenkins-bot
3f18ad1e38 Merge "OutputPage: Minor refactor to avoid calling deprecated function" 2024-07-05 01:31:38 +00:00
Bartosz Dziewoński
6d23dea9f0 OutputPage: Minor refactor to avoid calling deprecated function
This allows the deprecated formatPermissionsErrorMessage function to
start emitting deprecation warnings and be removed one day.

Change-Id: Iea190deacdadb3e6b242042cfacbb406b8d92f9a
2024-07-05 01:06:48 +00:00
Jon Robson
c33b31728d Skins: Support useskin=json
This allows rendering of the data passed to the skin rendering
layer, to allow developers to debug the information used to render
a skin.

Bug: T364696
Change-Id: I32aaa6a85d24df4f4689269f6a455823bb08196b
2024-07-02 21:29:00 +00:00
Timo Tijhof
217d47d46e Replace direct use of $wgRestPath with wfScript()
Follows-up Idb5b0d21adc6. Avoid hardcoded references to REST internal
configuration variables, which create awkward "APIs" in the long run.
These are hard to deprecate or detect use of, and even harder to
normalize/support once variations exist. E.g. in T189966 and T233886,
I've been working to remove the concept of dynamic config in favour of
the uncomputed values being only valid as configuration for the
component that owns the variable, instead of using Config as public
API to read non-normalized information that belongs to a different
component.

By making the recipient responsible for any dynamic computation, it
also becomes clear that these are in fact not normalized or validated,
which can expose any number of unpredictable behaviours if used
directly. Consider special values like `false` or `null` and the
responsibility for interpreting that. Accessing these from a stable
function also gives a natural place for deprecation to happen. The
alternative, is for dynamic computation to happen in Setup.php for
all variabls, and only ever grow and become an append-only dumping
ground for every thing that we feel at some point needs validation,
normalization or expansion, which doesn't scale well, hence I reversed
this trend in T189966/T233886.

As it happens, RestPath actually is already computed, albeit very
trivially. This patch opens the way for someone to remove that in
favour of PathRouter accept `false` directly and expanding (and testing)
that code there instead.

As for REST API, the only stable and universally supported entrypoint
is /w/rest.php. Unlike some older entry points, we don't support
moving or removing the rest.php file. We do support routing/aliasing
additional paths to it.

Change-Id: I589a8aed8db3b8e7b72e4505749bb7ef25a755d9
2024-07-01 22:01:32 +00:00
jenkins-bot
7804c43be4 Merge "OutputPage: Convert helplink icon to use codex css mixin" 2024-06-27 22:16:38 +00:00
Steph Toyofuku
d3f41c86b2 OutputPage: Convert helplink icon to use codex css mixin
Migrate this icon to codex for the purposes of having it appear in night
mode correctly.  Additionally, clean up the svg as it is no longer used

A couple notes:
1. This is not entirely visually identical to the current method - in
practice it ends up being nearly imperceptible, but worth noting that
even with the padding there is a slight vertical shift if you compare
them side by side
2. Due to the approach taken, I'm making the intentional choice to not
make this backwards compatible with cached HTML.  This means a cached
page will not have an icon for the duration it is cached, which feels
like an acceptable intermediary state, but feel free to disagree with me
in code review!

Slight visual change due to aforementioned color and position difference

Bug: T366358
Change-Id: I1c53e1c501242f9f9ab88ef8e0e4e85fb1971fbe
2024-06-27 13:12:28 -07:00
Novem Linguae
c48722c9af OutputPage: delete method getCSPNonce()
Hard deprecated since MW 1.41.

Unique method name that does not appear in CodeSearch for MediaWiki
& services at WMF. Couple of CodeSearch hits using the "Everything"
filter.

Bug: T362636
Change-Id: I2ea134d31a8b18375183a4ae413e77dc0a6f1acc
2024-06-27 15:42:24 +00:00
Fomafix
bda7811bf7 OutputPage: Use single quotes instead of double quotes
where no variable expansion or escape sequences are used.

Change-Id: I5cb9debec70ebb8102f250963efad2be176153c8
2024-06-07 08:06:32 +00:00
theprotonade
54b5c3ff96 Add classname for permission error messages
Add unique classnames of the form "mw-permissionerror-$error"
on permission error message elements for easier debugging

Bug: T279915
Change-Id: I7c1a422f77b32240ebd6c40824f5b0b51329d541
2024-06-07 01:04:01 +02:00
jenkins-bot
402f7fc36a Merge "Add Phan taint annotations to OutputPage::formatPermissionsErrorMessage" 2024-06-06 21:28:24 +00:00
Bartosz Dziewoński
0d6bf5084c Add Phan taint annotations to OutputPage::formatPermissionsErrorMessage
Change-Id: I6fd56a24959a762bf0b222e267deba92322d009e
2024-06-06 18:20:01 +02:00
C. Scott Ananian
27d5ac2679 Hard deprecate OutputPage::setPageTitle() with Message argument
Bug: T343994
Depends-On: I2c0a5ff8055eea5e23f402c25174b8ebcd7d25af
Depends-On: I75508e494dd47bfe38be65d9cca8595edd662937
Depends-On: I91eaadd56aca7896c1329d13bc78c260fc4f6d8d
Depends-On: If92935766461edc1375d277066c2768415a45744
Change-Id: Ie125f229cd356c5a056c983389f92b4d5f8da98f
2024-05-31 19:23:26 +00:00
jenkins-bot
31a72c9b71 Merge "REST: introduce OpenSearchDescriptionHandler" 2024-05-21 19:54:56 +00:00
Ebrahim Byagowi
97d1202784 Add namespace and deprecation alias to TextContent
This patch introduces a namespace declaration for the
MediaWiki\Content to TextContent and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Ic251b1ddfcf6db9c85cb54cddf912aa827d2bc3a
2024-05-19 23:23:01 +03:30
daniel
879846b29c REST: introduce OpenSearchDescriptionHandler
Move open search description endpoint from /w/opensource_desc.php
to /w/rest.php/v1/search.

Bug: T363984
Change-Id: Idb5b0d21adc6152ef77e6d17846b6acc6a904e01
2024-05-18 17:29:07 +00:00
jenkins-bot
c5387f3802 Merge "[OutputPage] Hoist "null Title" checks up a level" 2024-05-18 15:19:50 +00:00
Ebrahim Byagowi
ccde5085de Add namespace and deprecation alias to JavaScriptContent
This patch introduces a namespace declaration for the
MediaWiki\Content to JavaScriptContent and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I87c17327911e28a461feaf2ff46242454cff257a
2024-05-17 13:51:18 +03:30
C. Scott Ananian
f61760614d [OutputPage] Hoist "null Title" checks up a level
Add strict types to private parsing-related methods
OutputPage::parseInternal() and OutputPage::addWikiTextTitleInternal()
and in the process hoist the "null Titles are not allowed" assertion
up a level to the callers.

Adjust some phan suppressions after this change.

Change-Id: If828d9ffa1edc292a1aca3eb6fe36daffa100bd4
2024-05-15 11:25:36 -04:00
jenkins-bot
20d4c113da Merge "OutputPage: Use the same script tag pattern as Html::inlineScript()" 2024-05-13 12:41:08 +00:00
Func
f6ee77a3e5 OutputPage: Use the same script tag pattern as Html::inlineScript()
Not sure why they are different in the first place, probably a mistake.

The `user` and `site` modules would be embeded as a string, so can be
previewed with <script> etc escaped properly, leaving the bug only
reproducible with User/global.js via the GlobalCssJs extension.

Bug: T360258
Change-Id: I61a3d9926dbfd7630c37bebd9d46fa49b05a4fc6
2024-05-13 12:16:43 +00:00
Bartosz Dziewoński
d116ea0bce Tweak docs stating that time values can be booleans
I just don't see how that could be correct.

Change-Id: I193d2df26db401b33bcc9e6a82f3842ff5b8b56e
2024-05-11 23:51:25 +00:00
Amir Sarabadani
214674d6b1 namespace MWDebug
Bug: T353458
Change-Id: I99d728bd111ff882220cd175ff09d4da20b81eae
2024-05-03 22:59:47 +02:00
jenkins-bot
22b42ae351 Merge "OutputPage: Omit browser default <link> for $wgFavicon or $wgAppleTouchIcon" 2024-04-29 16:17:13 +00:00
alistair3149
a8d8b1b06b OutputPage: Omit browser default <link> for $wgFavicon or $wgAppleTouchIcon
These link elements are unnecessary because (in this case) the locations are the default location for the files concerned.
They will be checked anyway by user-agents that make use of such files, so pointing to them is a waste of space.

Bug: T21392
Change-Id: I5e063bd002111243f6b38da1989a7baf2e4e05d3
2024-04-29 15:47:30 +00:00
Bartosz Dziewoński
6c47bfbd88 OutputPage: Deprecate showFatalError()
It's just a worse version of showErrorPage().

Only 1 use in MediaWiki core, no uses in WMF-deployed extensions,
very few uses elsewhere.

Change-Id: I091e789891f60ed97dd84a25c2b2e0456a1af01e
2024-04-26 00:10:06 +02:00
Bartosz Dziewoński
02044a5ba1 Document more methods that accept MessageSpecifier, not just Message
These methods can already handle any MessageSpecifier, but their
documentation didn't show this.

Change-Id: I1323d18baf17a8a27cc9bed31860c4cc89e61a22
2024-04-09 20:25:18 +02:00
Bartosz Dziewoński
603ef2f29c OutputPage: Mostly doc improvements for passing message params
* showPendingTakeover(): While $params can technically be
  a MessageSpecifier (because a message can take another message
  as a parameter), we don't usually explicitly document that,
  and it seems like a result of some misunderstanding here.
  Allow variadic parameters instead, like most message functions.

* addWikiMsg(): Document the hidden message key parameter, making
  it really required. Remove documentation that refers to functions
  removed many versions ago. Document a weird limitation on the
  format of parameters, which is unlike most message functions.

* addWikiMsgArray(): Document a similar, but almost exactly
  opposite, weird limitation on the format of parameters.

Change-Id: Icb8822def9ce56f42ff52a8e469bb08d61d576c6
2024-04-05 23:46:13 +02:00
James D. Forrester
8e940c4f21 Standardise all our class alias deprecation comments for ease of grepping
Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
2024-03-19 20:11:29 +00:00