Commit graph

142 commits

Author SHA1 Message Date
Jon Robson
c6741353e3 Skin: [BREAKING CHANGE] Remove support for rendering outside body element
Methods were deprecated in 1.39 and the majority of skins are now
updated. This change means that skins can no longer override the rendering
of the HEAD element meaning extensions can rely on ResourceLoader support,
and hooks that modify the HEAD element indirectly

The new Skin::outputPageFinal method is adding to honor the existing
outputPage method that is stable to override but to prevent extending skin classes
from generating HTML which does not include HTML generated by hooks e.g.
ResourceLoader internals. This new method is for
internal usage by OutputPage only for this reason.
This keeps all HTML generation inside
the Skin class (e.g. preserves the status quo) until we can work out better
boundaries between Skin and OutputPage.

Bug: T306942
Change-Id: Ib023ef3335bb72306a01230b6cd1169dc7652588
(cherry picked from commit c7656257159a3d85422f4558f5add6df1564f3c3)
2024-10-30 15:18:51 +00:00
jenkins-bot
2f8c2f41c7 Merge "Remove support for using Skin::addToBodyAttributes" 2024-10-21 17:14:02 +00:00
Ammarpad
223bc155b1 Remove support for using Skin::addToBodyAttributes
This is back compat logic for a removed Skin method since 1.35

Change-Id: I526973e97f9093fd082bfb9a9aa85edaebc1126d
2024-10-20 21:45:31 +01:00
C. Scott Ananian
31039fefe6 OutputPage::setRobotPolicy(): deprecate 'index' after 'noindex'
Use OutputPage::setIndexPolicy() so that we document the change in
behavior for OutputPage::setRobotPolicy() and emit deprecation
warnings as needed.

Bug: T377586
Change-Id: Ieab6a66b7ba868acf4da2d785a44a0307c0dacc1
2024-10-18 10:46:38 -04:00
C. Scott Ananian
d6d6343c68 Deprecate OutputPage::{get,set}PreventClickjacking()
This is redundant with the same-named methods on ParserOutput.

Bug: T301020
Change-Id: I60455186e3a6e9b4329ff09e2f7ea920e2e05192
2024-10-17 23:51:39 -04:00
C. Scott Ananian
8509ded4f0 Deprecate OutputPage::{get,set}IndexPolicy()
This is redundant with the same-named methods on ParserOutput.

Bug: T301020
Change-Id: I41dcca30e106f77d12d9afe780f8578a4f1c81c9
2024-10-17 23:51:12 -04:00
C. Scott Ananian
ec311245f2 Use OutputPage::$metadata to store language links
Bug: T301020
Change-Id: I0208d4670817c52c917e3fca680451a170330909
2024-10-17 23:46:21 -04:00
C. Scott Ananian
fda71c4391 Use OutputPage::$metadata to store the 'prevent clickjacking' flag
Bug: T301020
Depends-On: I885f778eef92fa7d2b7d6a2c2997db6a8b0142e5
Change-Id: I3bfd47b078a5b84a88fffc04b48abe4c0023370f
2024-10-17 23:46:21 -04:00
C. Scott Ananian
62d6c23539 Use OutputPage::$metadata to store index policy
As a first step in a plan to reduce redundancy in OutputPage, replace
the $mIndexPolicy property of OutputPage with the corresponding
getter/setter methods in a ParserOutput held for the purpose of
storing metadata.

Bug: T301020
Change-Id: I6073f4033be936b669532ecf8104a8e5ff498e24
2024-10-17 23:46:19 -04:00
Umherirrender
e662614f95 Use explicit nullable type on parameter arguments
Implicitly marking parameter $... as nullable is deprecated in php8.4,
the explicit nullable type must be used instead

Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a

Break one long line in SpecialPage.php

Bug: T376276
Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
2024-10-16 20:58:33 +02:00
James D. Forrester
a5387c7c20 Namespace all remaining classes in includes/parser
Bug: T353458
Change-Id: If02cc9b1ff78e26c1cf8c91ee4695845eb133829
2024-10-15 23:54:32 +01:00
thiemowmde
b1c9ec74fa Remove meaningless @var documentation from constants
A constant is not a variable. The type is hard-coded via the value
and can never change. While the extra @var probably doesn't hurt much,
it's redundant and error-prone and can't provide any additional
information.

Change-Id: Iee1f36a1905d9b9c6b26d0684b7848571f0c1733
2024-10-09 09:33:12 +02:00
Timo Tijhof
c610b0774a OutputPage: Remove reference to outdated E_STRICT
According to https://www.php.net/strtotime, strtotime() can emit
E_WARNING, but not E_STRICT. Anyway, which type of error it emits
doesn't really matter. The cure is the same either way, to use AtEase
or "@" silencing operator, and to explain why.

Remove outdated error code from the explaination, and while at it
replace AtEase with the silence operator (per T253461 and T272554).

Bug: T375707
Change-Id: I641d27b7e73f5ef202f096ceccf16d9f2b89a684
2024-10-06 17:30:57 -04:00
James D. Forrester
9203493606 Add namespace to remaining parts of Wikimedia\FileBackend
Bug: T353458
Change-Id: I49c843c9d8f6459c0fbf774afeea7a82fa564b59
2024-10-03 16:21:22 +00:00
C. Scott Ananian
7495f9bc15 Deduplicate language links in ParserOutput and OutputPage
Move deduplication of language links out of Parser.php and into the
ParserOutput in order to be compatible with alternate Parsers (Parsoid).
Clean up various inconsistencies: ensure deduplication also happens in
OutputPage when multiple ParserOutputs are merged into the final output,
and ensure that the deduplication in LinksUpdate is done in the same
order (first link prevails) as in Parser/ParserOutput/OutputPage.

Deprecate OutputPage::setLanguageLinks() (the matching
ParserOutput::setLanguageLinks() was deprecated in 1.42).

As a breaking change, return an array, not an array *reference*, from
ParserOutput::getLanguageLinks().  This allows us to safely modify the
internal representation of language links. As far as I can tell, no one
used the returned reference to sneakily modify the list of language
links, and there not a good way to have deprecated this before making
the breaking change.

While we're at it, we've added tests to ensure that language link
fragments are preserved.

Bug: T26502
Bug: T358950
Bug: T375005
Change-Id: I82a05a51d94782ebb9fa87ff889ca0f633b3e15c
2024-09-26 15:28:49 -04:00
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
Fomafix
b8a1014679 Hard deprecate OutputPageMakeCategoryLinksHook
The hook OutputPageMakeCategoryLinks was only used by extension
CategoryTree:
https://codesearch.wmcloud.org/search/?q=OutputPageMakeCategoryLinks

CategoryTree switched to the new hook OutputPageRenderCategoryLink.

Depends-On: Ic86f210474cbc0e2dcebf664cf2309a4a4408f60
Change-Id: I8ea56f2d111aeccee158c40b8379383e92154d8a
2024-09-05 16:28:10 -04: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
Func
0c889c7fdc StreamFile: Support streaming webp from thumb_handler.php
Bug: T366422
Change-Id: Ib3ba7dccc10f8308fc706500c74a2beca357efdf
2024-09-03 14:39:04 +08: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
Ebrahim Byagowi
fab78547ad Add namespace to the root classes of ObjectCache
And deprecated aliases for the the no namespaced classes.

ReplicatedBagOStuff that already is deprecated isn't moved.

Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
2024-07-10 00:14:54 +03:30
Umherirrender
1951aea6b8 Fix various version mention for class_alias
Versions are changed in 8e940c4f21,
but that makes the version wrong

Follow-Up: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
Change-Id: Iae43725b8e0fffc4d44bf57f6227334b41290bd9
2024-07-05 18:39:49 +02: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
Umherirrender
c08b492d75 Use namespaced classes (3)
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Ia35b2d3105880631dd26ec974068b000ac7f4b6b
2024-06-16 20:26:43 +02: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