aboutsummaryrefslogtreecommitdiffstats
path: root/includes/OutputPage.php
Commit message (Collapse)AuthorAgeFilesLines
* Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* OutputPage: Fix the behavior for canonical URL and alternate URLsWinston Sung2023-03-011-6/+23
| | | | | | | | | | | | | | | | | | | | This fix is for the behavior of language variants, including: * Fix the language variant behavior in meta alternate hreflang URLs. meta alternate URLs should point to respective canonical URLs. meta alternate URLs should be kept even in current page view language * Make meta canonical URL language-variant-aware. This only take effect when there's variant or uselang specified in URL, so it doesn't affect variant-non-specified (variant-auto- detected) URLs. See `LanguageConverter::getURLVariant()` . Bug: T54429 Bug: T108443 Bug: T305540 Change-Id: I5e6c8c3f7671d27aecdb52be271b34ba524fadf7 Co-Authored-by: Func <Funcer@outlook.com> Co-Authored-by: Jdlrobson <jrobson@wikimedia.org>
* OutputPage: Reduce line complexity of getHeadLinksArrayJon Robson2023-03-011-115/+188
| | | | | | | | Split this into multiple functions with multiple concerns for easier maintenance and code review. Bug: T330777 Change-Id: I80d93ec09be2df5c8b94a16140ba11da4827a42d
* Merge "mediawiki.user: Remove wgUserIsNamed variable as redundant"jenkins-bot2023-02-221-1/+0
|\
| * mediawiki.user: Remove wgUserIsNamed variable as redundantKevin Israel2023-01-291-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | mw.user#isNamed returns whether the current user is "a normal non- temporary registered user". "Registered" can be determined by checking whether wgUserName is non-null, and "temporary" can be determined by checking whether wgUserIsTemp is true. This matches User::isNamed(), and should very slightly reduce HTML size for registered users. As such, remove the wgUserIsNamed variable as redundant with the wgUserIsTemp variable that was also added in cfa44ae08f448b91. Change-Id: I78a76f8682493b081e012f36054845c8fb66cd66
* | ResourceLoader: Permit partial failure in OutputPage::getBottomScriptsTimo Tijhof2023-02-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until recently, `wgPageParseReport` was the only property in the bottom payload for mw.config. However, with the introduction of "late variables" in I86d46175639 (e3784468fc, T41813) this can now contains variables from extension as well. When a variable moves from one to the other, it should have no difference other than its position. Currently, this is not the case because the encoding in `<head>` silently tolerates invalid UTF-8 and has for several years. The bottom one, however, produces a fatal error. Change this to make the two more similar. As of I89832142b55e, encodeJson() improves debugging by logging the specific error that json_encode encountered as well. Bug: T329330 Bug: T41813 Change-Id: I1b78e81d08e11dce3426dfc195db5499efdc2dcf
* | Reorg: Move HTML-related classes out of includes/ to Html/Amir Sarabadani2023-02-161-0/+1
| | | | | | | | | | Bug: T321882 Change-Id: I5dc1f7e9c303cd3f5b9dd7010d6bb470d8400a18
* | Reorg: Move CSP class to Request/Amir Sarabadani2023-02-161-0/+1
| | | | | | | | | | Bug: T321882 Change-Id: Ic809656a31e08626d0e5a1172da02b2397096e14
* | Remove/simplify not trivial and unnecessary null checksthiemowmde2023-02-141-7/+1
| | | | | | | | Change-Id: I101dec0be2bd10e280acf6f5a0c8d7a3a81c6b1f
* | Pass appropriate userLang to ParserOutput::getText()C. Scott Ananian2023-02-011-2/+6
|/ | | | | | | | | | | | | | | | | | | | | | The rules for how ParserOptions::getUserLang() are set are a little baroque. When the 'uselang' option is set on the request, for example, RequestContext::getLanguage() can differ from the user language; we also deliberately force the "user language" to the content language during the post-edit path to avoid having the user language leak into the links table. The changes in this patch make the ParserOutput::getText() calls "more correct" but really they are just removing some uses of the global RequestContext::getMain() from the code path, since in all of these cases the main request context (which is what we use by default) does have the correct language set. For consistency, this patch also adds `allowTOC=false` in many of the places where we already had `enableSectionEditLinks=false`; for example, user interface messages, wikitext content injected on special pages, etc. Change-Id: Ib0d8c5e538e472ad672c45e5b68907242afb1e14
* Merge "ResourceLoader: Follow-up to adding ResourceLoaderClientPreferences"jenkins-bot2023-01-251-0/+9
|\
| * ResourceLoader: Follow-up to adding ResourceLoaderClientPreferencesTimo Tijhof2023-01-251-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Minor clean up: * Fix broken `@see` in MainConfigSchema. * Add missing `@since`. * Doc experimental nature, as per the Ic3b6eec1995393 msg. * Doc anonymous scope, and mention general strategy for elsewhere. * Dependency inject, to separate concerns and keep ClientHtml decoupled from MediaWiki settings like wgCookiePrefix, which otherwise break testing this class with only RL-specific config. * Apply JS conventions. Made easier by using "JS" as the heredoc identifier, which IDEs recognise as for highlighting. * Move code together with the other documentElement.className statement. This helps both with understanding the PHP side in terms of related logic and how it interacts, as well as the frontend as it literally brings <html script>, client-js, and clientpref all next to each other. HTML weight of default Main_Page on localhost, logged-out: * vector : 23.21 kB / 140.48 kB * vector-2022 : 24.17 kB / 146.43 kB +6.0 kB * vector-2022 ClientPref=true before : 24.28 kB / 146.70 kB +6.3 kB * vector-2022 ClientPref=true after : 24.27 kB / 146.68 kB +6.2 kB Given: * $wgResourceLoaderClientPreferences = true; Test plan: 1. View /wiki/Main_Page?useskin=vector-2022 while logged-out, confirm the inline script is there, and "vector-feature-limited-width-content" is set on <html class>, layout width appears fixed. 2. Run mw.cookie.set('mwclientprefs', 'vector-feature-limited-width-content'); 3. Refresh and confirm the class is changed at runtime and layout width is fluid. Use mw.cookie.set('mwclientprefs', null) to undo. Bug: T321498 Change-Id: I07f471b815ffadfca9eb4f7bd228cb72dfd1ec9b
* | mediawiki.user: Add methods for isNamed and isTempKosta Harlan2023-01-241-0/+2
|/ | | | | Bug: T327317 Change-Id: Ie3e817a6ebb4c468772c600a02257650750c3387
* Merge "Generate/set/get TOCData/SectionMetadata objects instead of arrays"jenkins-bot2023-01-191-14/+19
|\
| * Generate/set/get TOCData/SectionMetadata objects instead of arraysSubramanya Sastry2023-01-191-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ParserOutput::setSections()/::getSections() are expected to be deprecated. Uses in extensions and skins will need to be migrated in follow up patches once the new interface has stabilized. * In the skins code, the metadata is converted back to an array. Downstream skin TOC consumers will need to be migrated as well before we can remove the toLegacy() conversion. * Fixed SerializationTestTrait's validation method - Not sure if this is overkill but should handle all future complex objects we might stuff into the ParserCache. * This patch emits a backward-compatible Sections property in order to avoid changing the parser cache serialization format. T327439 has been filed to eventually use the JsonCodec support for object serialization, but for this initial patch it makes sense to avoid the need for a concurrent ParserCache format migration by using a backward-compatible serialization. * TOCData is nullable because the intent is that ParserOutput::setTOCData() is MW_MERGE_STRATEGY_WRITE_ONCE; that is, only the top-level fragment composing a page will set the TOCData. This will be enforced in the future via wfDeprecated() (T327429), but again our first patch is as backward-compatible as possible. Bug: T296025 Depends-On: I1b267d23cf49d147c5379b914531303744481b68 Co-Authored-By: C. Scott Ananian <cananian@wikimedia.org> Co-Authored-By: Subramanya Sastry <ssastry@wikimedia.org> Change-Id: I8329864535f0b1dd5f9163868a08d6cb1ffcb78f
* | Merge "Make sure hreflang Tags' alternate URLs are fully-qualified"jenkins-bot2023-01-171-3/+5
|\ \ | |/ |/|
| * Make sure hreflang Tags' alternate URLs are fully-qualifiedJunyin Chen2022-06-301-3/+5
| | | | | | | | | | | | | | | | | | | | | | Currently, the hreflang Tags' alternate URLs are not fully-qualified, resulting these tags useless in SEO stand point. This change makes sure hreflang Tags' alternate URLs are fully-qualified, with testcase coverage. Bug: T294716 Change-Id: I1dd3453c44f5c80adfbd7309860563d3bb9a7f86
* | Merge "OutputPage: Call setSections() from addParserOutputMetadata()"jenkins-bot2023-01-161-0/+2
|\ \
| * | OutputPage: Call setSections() from addParserOutputMetadata()Bartosz Dziewoński2022-12-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Remove calls elsewhere which now became redundant. Bug: T325562 Bug: T325600 Change-Id: I1611f3bdea46a729ecf9daf699d761b018d49b55
* | | Make use of ??= in more placesDannyS7122022-12-171-12/+4
|/ / | | | | | | | | | | New feature from PHP 7.4 Change-Id: Ifa7a9bc7b2ec415ad7ecb23f4c1776f51f58fd6b
* | Merge "Replace deprecated PermissionManager::groupHasPermission"jenkins-bot2022-12-141-3/+3
|\ \
| * | Replace deprecated PermissionManager::groupHasPermissionUmherirrender2022-11-131-3/+3
| | | | | | | | | | | | Change-Id: I1e89c5361255c55f71ac2d4008a88475b4b04447
* | | OutputPage: Remove unused dynamic property ParserOptions->isBogusUmherirrender2022-12-121-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | The usage was removed in a3a620a Bug: T314099 Follow-Up: I526b1e8e310c1ad3d14402b67e6c967923f3609f Change-Id: Iab866a18a948952d31727e3c3e36cd7957302443
* | | Cleanup: Remove some tiny private methods in favor of inlining the codeDannyS7122022-12-111-13/+3
| | | | | | | | | | | | | | | | | | | | | | | | HistoryPager: remove ::preventClickjacking OutputPage: remove ::getOriginTrials RevisionStore: remove ::getDBLoadBalancer Change-Id: Id60d9861ffd86d9a82ee7f56da939274b1be82e0
* | | Revert "resourceloader: Raise severity of targets violation to WARNING"Jdlrobson2022-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit aa2a3574076d00b45b1174ec01488cb84e56abda. Reason for revert: This was a temporary change to collect data around target violations. One week should be enough data so we can revert this in the following train. Bug: T235712 Change-Id: I3a3db293299771ab9465258d1a2a73c62c652a9b
* | | resourceloader: Raise severity of targets violation to WARNINGKrinkle2022-12-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This re-applies commit cb6a24d3c420430f6c7c0fcebbb0c3dfb32aee49. It would be useful to collect some new data for a week or 2 before the end of the year so we can refresh the associated Phabricator ticket. Bug: T235712 Change-Id: I815a104d4b4f71ac85589af40c5e8211429ff191
* | | Various doc fixes about false on method arguments/return typesUmherirrender2022-11-101-1/+1
|/ / | | | | | | | | | | Doc-only changes Change-Id: I5177f582ae7ee70c357e9389fed14819faf79463
* | Merge "OutputPage: Support loading some mw.config vars late, at end of body"jenkins-bot2022-11-071-10/+45
|\ \
| * | OutputPage: Support loading some mw.config vars late, at end of bodyBartosz Dziewoński2022-11-071-10/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JS config vars listed in the 'LateJSConfigVarNames' extension attribute or in the OutputPage::CORE_LATE_JS_CONFIG_VAR_NAMES constant will now be added to the end of the HTML response, instead of early in the HTML head where it blocks rendering/painting. Bug: T41813 Change-Id: I86d461756398780dc24949013f35b7730a481052
* | | Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Redoing I5ea70120d74 but without moving WebRequest that caused issues with phan-taint-plugin. Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequestUpload Bug: T321882 Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
* | | Revert "Reorg: Move some of request related classes to MediaWiki/Request"Zabe2022-10-271-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 2bdc0b2b7209441a42a784157633a8a01b321922. Reason for revert: T166010#8349431 Bug: T166010 Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
* | | Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-261-0/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | | | Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequest - WebRequestUpload Bug: T166010 Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
* | build: Update mediawiki/mediawiki-phan-config to 0.12.0Daimona Eaytoy2022-10-081-0/+1
| | | | | | | | | | | | | | | | This patch only adds and removes suppressions, which must be done in the same patch as the version bump. Bug: T298571 Change-Id: I4044d4d9ce82b3dae7ba0af85bf04f22cb1dd347
* | Fixes for the phan upgrade, part 1Daimona Eaytoy2022-10-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Mainly, document some parameters as non-empty-array so that phan knows the list of arguments won't be empty when unpacking. In EditPage, account for hooks potentially unsetting the copyright notice. Also rewrite some code in LogPager, so it's hopefully easier for phan to understand what's going on. Change-Id: Ic0638571554424098d0743db32dd46723a08e103
* | Allow large image previews by adding max image preview tagMoh'd Khier Abualruz2022-10-051-1/+1
| | | | | | | | | | | | | | | | - This is across all skins - Adjusted unit tests to check for value Bug: T310267 Change-Id: If61b8bb3bbbe990c8babb0742f747372004dc10c
* | Merge "Replace various `array` type hints with more specific `string[]`"jenkins-bot2022-10-041-3/+3
|\ \
| * | Replace various `array` type hints with more specific `string[]`thiemowmde2022-09-271-3/+3
| | | | | | | | | | | | | | | | | | | | | There are many, many more. I touch only a few where I'm sure it's never anything but an array of strings. Change-Id: I8b798f2e9d48f07a241b95ce0ace8fa9d981695d
* | | BadTitleError: Enable 1 hour CDN cache for this error responseAlexander Vorwerk2022-09-261-10/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Varnish is unable to cache these currently. However since pages with an invalid title will never have any variable/editable content, we can cache them unconditionally. Also, undeprecate OutputPage::enableClientCache for this since it is clearly useful here, but the parameter is being removed since OutputPage::disableClientCache should be used to disable client side caching instead. Bug: T316932 Change-Id: Ib98fd165bffd9ca3dcbbcb8c6f06964dba7c90b7
* | Remove unused key variable from foreach loopsUmherirrender2022-09-211-2/+2
| | | | | | | | Change-Id: Id2d91e30a6f7cc4eb93427b50efc1c5c77f14b75
* | Merge "Use ParserOutputFlags::SHOW_TOC in OutputPage"jenkins-bot2022-09-121-1/+15
|\ \
| * | Use ParserOutputFlags::SHOW_TOC in OutputPageC. Scott Ananian2022-08-181-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Parser output flags are intended to be "set only". That means that extensions can *set* the SHOW_TOC flag, but once set SHOW_TOC can't be reset, and the TOC will be shown in the result if *any* of the merged ParserOutputs on the OutputPage contain the SHOW_TOC flag set. That's consistent with prior merge behavior. There's a possibility extensions are playing other games with the Table Of Contents (TOC) in the OutputPageParserOutput hook; be compatible with prior behavior for now but we may need to provide additional functionality (perhaps a way to merge new section data) if needed. Bug: T310083 Change-Id: I0909ac85c6c785d9089b077a16923c61d6a09996
* | | Merge "OutputPage::addParserOutputText(): use default ParserOutput options ↵jenkins-bot2022-09-091-0/+7
|\ \ \ | | | | | | | | | | | | from skin"
| * | | OutputPage::addParserOutputText(): use default ParserOutput options from skinC. Scott Ananian2022-09-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This addresses the common case patched by I530d71d0f9279b40a263cd62467d3ef8c76975c3, If6267f3389b166043fc94d7f952bc54122b1a378 and probably the code in Article.php from I44045b3b9e78e7ab793da3f37e3c0dbc91cd7d39 by ensuring that "injectTOC" in the options passed to ParserOutput::getText() defaults to the correct value based on the skin being used by OutputPage. Bug: T317333 Change-Id: Ica30569efbb5730eff5b807e8fc34beb2e13e74f
* | | | OutputPage: Fix undefined `['host']` in ImagePreconnect codeTimo Tijhof2022-09-081-10/+12
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of checking the result of uncondiional `['host']` access in the foreach loop afterward, check the result of url parsing directly. Also: * Switch to plain parse_url(), we don't support exotic input here. * Move parsing to loop, minor optimisation, and will often thus mean we don't even need to parse or check the LocalRepo case, since the feature is generally only enabled when a cross-domain ForeignRepo exists. * Improve docs. * Remove experimental warning. Bug: T317329 Change-Id: I6492f5142861513e4a7eb65fe4c14fa12c46977a
* | | Merge "Allow customizing OutputPage::showErrorPage() return URL"jenkins-bot2022-09-021-2/+8
|\ \ \
| * | | Allow customizing OutputPage::showErrorPage() return URLGergő Tisza2022-08-311-2/+8
| | | | | | | | | | | | | | | | Change-Id: Id35574600e0118f0b6b823bdc84c8c4783d72d12
* | | | Merge "OutputPage: Provide consistent info about whether the revision shown ↵jenkins-bot2022-08-311-2/+19
|\ \ \ \ | |/ / / |/| | | | | | | is current"
| * | | OutputPage: Provide consistent info about whether the revision shown is currentBartosz Dziewoński2022-08-311-2/+19
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, OutputPage::isRevisionCurrent() would check a replica database, potentially different from the database used to fetch the revision being displayed, according to OutputPage::getRevisionId(). Now the data for both functions is provided in the same way. Bug: T314684 Change-Id: I266d643d1eed931df346889f43d72d42e5f4a3ba
* | | OutputPage: replace legacy link type "shortcut icon" with standardR4356th2022-08-191-1/+1
| | | | | | | | | | | | | | | Bug: T19980 Change-Id: I6ed3417fc9efa9bab9533f155dcfe23a78d19e3b
* | | Add markup to page titles to distinguish the namespace and the main textBartosz Dziewoński2022-08-161-0/+16
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pages outside of the main namespace now have the following markup in their <h1> page titles, using 'Talk:Hello' as an example: <h1> <span class="mw-page-title-namespace">Talk</span> <span class="mw-page-title-separator">:</span> <span class="mw-page-title-main">Hello</span> </h1> (line breaks and spaces added for readability) Pages in the main namespace only have the last part, e.g. for 'Hello': <h1> <span class="mw-page-title-main">Hello</span> </h1> The change is motivated by a desire to style the titles differently on talk pages in the DiscussionTools extension (T313636), but it could also be used for other things: * Language-specific tweaks (e.g. adding typographically-correct spaces around the colon separator: T249149, or replacing it with a different character: T36295) * Site-specific tweaks (e.g. de-emphasize or emphasize specific namespaces like 'Draft': T62973 / T236215) The markup is also added to automatically language-converted titles. It is not added when the title is overridden using the wikitext `{{DISPLAYTITLE:…}}` or `-{T|…}-` forms. I think this is a small limitation, as those forms mostly used in the main namespace, where the extra markup isn't very helpful anyway. This may be improved in the future. As a workaround, users could also just add the same HTML markup to their wikitext (as those forms accept it). It is not also added when the title is overridden by an extension like Translate. Maybe we'll have a better API before anyone wants to do that. If not, one could un-mark Parser::formatPageTitle() as @internal, and use that method to add the markup themselves. Bug: T306440 Change-Id: I62b17ef22de3606d736e6c261e542a34b58b5a05