Commit graph

22 commits

Author SHA1 Message Date
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
Umherirrender
a3a9cf99cb tests: Use namespaced class names in @covers annotations
Assist from 8c9cb701e56226cac43fee2fa24b0d0e586f1733

Change-Id: I47897c499028d9e24c00ad0bc6ba7fd8002d9bc1
2024-01-27 01:11:07 +01:00
Daimona Eaytoy
2520f3d1c4 Replace more usages of deprecated MWException
Bug: T328220
Change-Id: Ie9b56bcf5e962e275d80570cad98d676da505894
2024-01-19 22:01:12 +00:00
James D. Forrester
273cc042ae ResourceLoader: Drop targets system, deprecated in 1.41
Bug: T340802
Depends-On: Ie936afed7042d5a4713b027c30d7487565a35eaf
Change-Id: Icad30d62301be5d7390ebdf34e818519e3fe56c4
2024-01-12 16:42:38 -05:00
jenkins-bot
e98fd01c98 Merge "In OutputPage::addParserOutput, getText() before processing metadata" 2023-11-06 21:02:58 +00:00
Subramanya Sastry
6d80f9e793 In OutputPage::addParserOutput, getText() before processing metadata
* This ensures that getText() transforms are completed before
  additional output page transformations (and hook handlers) run.

* This change lets us implement DiscussionTools DOM transforms in
  a post-parsercache output transform hook. While this hook currently
  modifies the ParserOutput object in place (and is considered bad
  practice), when the OutputTransform pipeline is instantiated, the
  post-cache parser output object is cloned before the pipelines
  modify it.

  That also opens the possibility of being able to cache the transformed
  ParserOutput object separately for scenarios where the transforms
  are expensive.

* This is needed by I9846193656cdc658f5237df0a133d9d4dcc20d00 to
  make it work as intended.

Change-Id: I97c9a17c5edb36e4af6ee257b80ea923a786d62b
2023-11-06 08:36:02 -06:00
Timo Tijhof
d0a96db0f9 parser: Move lang/dir and mw-content-ltr to ParserOutput::getText
== Skin::wrapHTML ==

Skin::wrapHTML no longer has to perform any guessing of the
ParserOutput language. Nor does it have to special wiki pages vs
special pages in this regard. Yay, code removal.

== ImagePage ==

On URLs like /wiki/File:Example.jpg, the main output handler is
ImagePage::view. This calls the parent Article::view to handle most of
its output. Article::view obtains the ParserOptions, and then fetches
ParserOutput, and then adds `<div class=mw-parser-output>` and its
metadata to OutputPage.

Before this change, ImagePage::view was creating a wrapper based
on "predicting" what language the ParserOutput will contain. It
couldn't call the new OutputPage::getContentLanguage or some
equivalent as Article::view wouldn't have populated that yet.

This leaky abstraction is fixed by this change as now the `<div>`
from ParserOutput no longer comes with a "please wrap it properly"
contract that Article subclasses couldn't possibly implement correctly
(it coudln't wrap it after the fact because Article::view writes to
OutputPage directly).

RECENT (T310445):

A special case was recently added for file pages about translated SVGs.
For those, we decide which language to use for the "fullMedia" thumb
atop the page. This was recently changed as part of T310445 from a
hardcoded $wgLanguageCode (site content lang) to new problematic
Title::getPageViewLanguage, which tries to guestimate the page
language of the rendered ParserOutput and then gets the preferred
variant for the current user. The motivation for this was to support
language variants but used Title::getPageViewLanguage as a kitchen
sink to achieve that minor side-effect. The only part of this
now-deprecated method that we actually need is
LanguageConverter::getPreferredVariant().

Test plan: Covered by ImagePageTest.

== Skin mainpage-title ==

RECENT (T331095, T298715):

A special case was added to Skin::getTemplateData that powers the
mainpage-title interface message feature. This is empty by default,
but when created via MediaWiki:mainpage-title allows interface admins
to replace the H1 with a custom and localised page heading.

A few months ago, in Ifc9f0a7174, Title::getPageViewLanguage was
applied here to support language variants. Replace with the same
fix as for ImagePage. Revert back to Message::inContentLanguage()
but refactor to inLanguage() via MediaWikiServices::getContentLanguage
so that LanguageConverter::getPreferredVariant can be applied.

== EditPage ==

This was doing similar "predicting" of the ParserOutput language to
create an empty preview placeholder for use by preview.js. Now that
ApiParse (via ParserOutput::getText) returns a usable element without
any secret "you magically know the right class, lang, and dir" contract,
this placeholder is no longer needed.

Test Plan:

* EditPage: Default preview
  1. index.php?title=Main_Page&action=edit
  2. Show preview
  3. Assert <div class="mw-content-ltr mw-parser-output" lang=en dir=ltr>

* EditPage: JS preview
  1. Preferences > Editing > Show preview without reload
  2. index.php?title=Main_Page&action=edit
  3. Show preview
  4. Assert <div class="mw-content-ltr mw-parser-output" lang=en dir=ltr>
  5. Type something and 'Show preview' again
  6. Assert old element gone, new text is shown, and new element
     attributes are the same as the above.

== McrUndoAction ==

Same as EditPage basically, but without the JS preview use case.

== DifferenceEngine ==

Test:

1. Open /w/index.php?title=Main_Page&diff=0
   (this shows the latest diff, can do manually by viewing
   /wiki/Main_Page, click "View history", click "Compare selected revisions")
2. Assert <div class="mw-content-ltr mw-parser-output" lang=en dir=ltr>
3. Open /w/index.php?title=Main_Page&diff=0&action=render
4. Assert <div class="mw-content-ltr mw-parser-output" lang=en dir=ltr>

== Special:ExpandTemplates ==

Test:

1. /wiki/Special:ExpandTemplates
2. Write "Hello".
3. "OK"
4. Assert <div class="mw-content-ltr mw-parser-output" lang=en dir=ltr>

Bug: T341244
Depends-On: Icd9c079f5896ee83d86b9c2699636dc81d25a14c
Depends-On: I4e7484b3b94f1cb6062e7cef9f20626b650bb4b1
Depends-On: I90b88f3b3a3bbeba4f48d118f92f54864997e105
Change-Id: Ib130a055e46764544af0f1a46d2bc2b3a7ee85b7
2023-11-03 19:24:47 -04:00
C. Scott Ananian
835daa0681 ParserOutput::hasTOCHTML(): Remove old back-compat code
We'll remove ::getTOCHTML() and ::setTOCHTML() shortly as well, but
we need to adjust our parser cache serialization tests first.

Bug: T348134
Bug: T305161
Change-Id: I19f1e3d0ecbbf1225a3cb41d48e668cad9867bc5
2023-10-12 15:36:31 -04:00
jenkins-bot
e410ea172e Merge "Revert "Deprecate TOC mutation in OutputPageParserOutput hook"" 2023-10-04 21:27:49 +00:00
Subramanya Sastry
cd069591fa Revert "Deprecate TOC mutation in OutputPageParserOutput hook"
This reverts commit 20dbf6e3c9.

Reason for revert: T348134 is causing logspam

Bug: T348134
Change-Id: I03c9ff0a3f88c7e7ea55ac0af874446530063943
2023-10-04 21:12:04 +00:00
jenkins-bot
36031cf0e9 Merge "Hard-deprecate ParserOutput::getCategories(), deprecated in 1.40" 2023-10-03 20:59:07 +00:00
jenkins-bot
6e4a469f3f Merge "Deprecate TOC mutation in OutputPageParserOutput hook" 2023-09-30 04:11:58 +00:00
C. Scott Ananian
d20663259f Hard-deprecate ParserOutput::getCategories(), deprecated in 1.40
It is difficult to distinguish this method from OutputPage::addJsConfigVars()
in code search:

   https://codesearch.wmcloud.org/deployed/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3EgetCategories%5C%28&files=&excludeFiles=&repos=

We generally try to replace $output with $parserOutput or $pOutput
as we touch code to improve the ability of codesearch to dig up
deprecated ParserOutput methods.

Bug: T305161
Depends-On: I02dd4f61c43c225b0ef6dc51c3e4f9d967a0a272
Depends-On: I61d2d77591579d825ad9d37f902e40366be55dd6
Depends-On: I91155106b7a9e10d3334f95ba4936d02851bfb11
Depends-On: Iaca745c79d9587571af03b23b21d76a6cba0ebf1
Depends-On: Id10a171c44411b1233ee4d6cf8fbd3dc57744eef
Depends-On: I47a25c011d9bd4b1a15dda4e673e32c25eb64f2b
Depends-On: I683fc768aba50b801f46467fcfa1668fa8731ea6
Change-Id: I5a2ac1c99b8b199102e12f0d32dd6ec5cdc24054
2023-09-29 15:25:50 -04:00
Amir Sarabadani
f5abfb8d58 Bump codesniffer to 42.0.0
Most noisily, this enables MediaWiki.Arrays.OneSpaceInlineArray.

Change-Id: I8ab11399c67ce7e3ab1b6249b591452774393428
2023-09-27 15:06:32 -04:00
C. Scott Ananian
20dbf6e3c9 Deprecate TOC mutation in OutputPageParserOutput hook
This has effectively been deprecated since 1.40, since it would
involve a call to ParserOutput::setTOCHTML() which was itself
hard-deprecated in 1.40.  But emit a deprecation warning on this
branch just to clarify the downstream messaging further.

Bug: T293513
Change-Id: I02b40290717e07927a4995de4b06e83a879fc734
2023-09-22 17:27:25 -04:00
James D. Forrester
c1599c91b3 Namespace Config-related classes under \MediaWiki\Config
Bug: T166010
Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
2023-09-21 05:41:58 +00:00
James D. Forrester
1d0b7ae1e2 Namespace User under \MediaWiki\User
Bug: T166010
Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
2023-09-19 19:18:16 +00:00
jenkins-bot
be82d8edb0 Merge "OutputPage: introduce ::setPageTitleMsg() to fix escaping issue" 2023-09-19 18:25:00 +00:00
C. Scott Ananian
22ee8f7afe OutputPage: introduce ::setPageTitleMsg() to fix escaping issue
The page title is expected to be HTML, albeit "safe" HTML which is stripped
of many tags.  FORMAT_PARSE/FORMAT_BLOCK_PARSE and FORMAT_ESCAPED are the
three Message types which emit HTML, and ::escaped() is the most reasonable
(aka fastest) one to use by default for page titles.  For callers which
do want literal HTML in the title, they can use Message::rawParams()
or pass the argument as a string.

However, historically ::setPageTitle() has used ::text() to format
Message objects passed as its argument.  In my survey, I could not find
any caller which used HTML metacharacters and would be affected by
changing the formatting from TEXT to ESCAPED, but in order to prevent
regressions I've introduced a new method ::setPageTitleMsg() and
soft-deprecated the use of ::setPageTitle() with a Message argument.
Eventually I hope ::setPageTitle() will only take strings and all
callers passing a Message will use ::setPageTitleMsg(), which should
also help out phan-taint-check.

Bug: T343994
Bug: T343849
Change-Id: I384a12bdb66dfc8fa6650e76e27c671fae5163d6
2023-09-18 11:52:30 -04:00
C. Scott Ananian
d421ab57f8 Remove ParserOutput::addOutputHook() and related code
ParserOutput::addOutputHook() has been deprecated since 1.38, and without
any calls to ::addOutputHook() the associated ::getOutputHooks() and
$wgParserOutputHooks configuration do nothing.

Bug: T292321
Bug: T305161
Change-Id: Ib770c680d5e0697980e7e36a323ec56ba1d806b8
2023-09-18 11:34:02 -04:00
Fomafix
b1449dbcd0 Remove deprecated HTTP header field 'Pragma'
Since RFC 9111 from June 2022 the HTTP header field 'Pragma' is
deprecated: https://www.rfc-editor.org/rfc/rfc9111.html#name-pragma

Bug: T345420
Change-Id: I6b699cd63396cad2a3dcc64516cfde5a7a64da3d
2023-09-14 19:44:46 -07:00
Umherirrender
790ae736c1 tests: Move test cases from /includes/ into sub folder
Follow move of the tested class
Most moves are part of T321882

Change-Id: I74ab45d6a5331dcb2ff0b65dc2cc7c6315146646
2023-09-13 00:09:05 +02:00
Renamed from tests/phpunit/includes/OutputPageTest.php (Browse further)