aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Output
Commit message (Collapse)AuthorAgeFilesLines
* Use type declaration on undocumented private functionsUmherirrender2025-04-021-2/+2
| | | | Change-Id: I0d8d2237500ed6f18439410c902d47c42e4119bc
* Namespace all remaining files in includes/skinJames D. Forrester2025-03-253-3/+3
| | | | | Bug: T353458 Change-Id: I3e829e35c93bcaae75e401b1801bddf93c0b416c
* Merge "Hard deprecate OutputPage::addParserOutput{,Content} with null ↵jenkins-bot2025-03-241-2/+2
|\ | | | | | | ParserOptions"
| * Hard deprecate OutputPage::addParserOutput{,Content} with null ParserOptionsC. Scott Ananian2025-03-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: T350626 Follows-Up: Iec19f9f08a4d88ea534ffa7b24e6e01ffbba2723 Depends-On: Ib96c6f33ce30529fe41f5db1c54b727ce63fb7c0 Depends-On: If1ece68d06bbc81ba3d726c98adda064394b9cf1 Depends-On: I98ced3bd0820b2981fecc29caaddaab0e952f214 Depends-On: I43b77f0bfa01c1b1589fe044cf07005d53aaf161 Depends-On: I5a0905efb4f71b50e6a48cee4b6ac4e0bab3193a Depends-On: I50e7aaae2214193b8df2a8729d5527f67ca4fba9 Depends-On: If6573fc759c5735a1542bbe104f92f214a4e9c11 Depends-On: Ica3bb81b37d62a9233becf7558aa71042fc5ced1 Depends-On: Ia20dfa77021fbdd7a4578e26be74b439c58ead99 Depends-On: Idb0165c526e414c4208d46c6e20aeec92bbce3f3 Depends-On: Ia128b083b89b7f461d19e6d9464f0b894cc842bc Depends-On: I4e1b65845876e051be13abaf02988136cb1f9c53 Depends-On: I892831073bb5daee06abb5e04877c95e55551154 Depends-On: Iec53d8b338ba3e27d72712fcf45061108019d4d6 Depends-On: I634efdd086506bae02dab855a0e6869fb0d56c4a Depends-On: I6b337d673d3c98c532e8a5da650836aa3d4d6b51 Change-Id: I5c33f9bce88126c91cd5b6dc0b52dc63496a9573
* | Merge "Deprecate OutputPage::showNewSectionLink(), ::forceHideNewSectionLink()"jenkins-bot2025-03-241-9/+10
|\ \
| * | Deprecate OutputPage::showNewSectionLink(), ::forceHideNewSectionLink()C. Scott Ananian2025-03-241-9/+10
| | | | | | | | | | | | | | | | | | | | | The OutputPage::getOutputFlag(...) method should be used instead. Bug: T301020 Change-Id: I3b5a76d30e88da1f29e50689cfab7d05ff83e43f
* | | Merge "Split OutputPage::getModulesInternal()"jenkins-bot2025-03-241-10/+37
|\ \ \ | |/ / |/| |
| * | Split OutputPage::getModulesInternal()C. Scott Ananian2025-03-221-10/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In preparation for moving the module lists to OutputPage::$metadata, deprecate the additional parameters to OutputPage::getModules() and OutputPage::getModuleStyles(); refactoring the actual implementation to a new private method OutputPage::getModulesInternal(). Bug: T301020 Change-Id: Iea1a40fed68d3b61b8decf9ab838391b1477ff95
* | | Use OutputPage::$metadata to store $mRevisionTimestampC. Scott Ananian2025-03-221-5/+7
| | | | | | | | | | | | | | | Bug: T301020 Change-Id: Iee09b1591bfa11142686c9043a8294e7e77d2b61
* | | Deprecate OutputPage::getNoGallery()C. Scott Ananian2025-03-221-11/+5
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | Also switch to using OutputPage::$metadata to store $mNoGallery, although the expected replacement is OutputPage::getOutputFlag(). This is a slight semantic change, as it is the OR of the NO_GALLERY flag for all ParserOutputs used to compose the Output, instead of simply being the value of the last ParserOutput used. This isn't expected to be significant in practice. Improved the documentation of ParserOutputFlags::NO_GALLERY while we're touching this code. Bug: T301020 Change-Id: Ibaa31df331974e98254ecfcc4393ec1fda2ebe64
* | [OutputPage] replace ParserOutput::getText() options with ParserOptions, v2C. Scott Ananian2025-03-211-51/+154
|/ | | | | | | | | | | | | | | Suppress TOC, section edit links, and set wrapper div class via ParserOptions, instead of by passing options to ParserOutput::getText(). In the process deprecate the public OutputPage::parserOptions(), which is no longer used internally, and add OutputPage::addTOCPlaceholder() to DRY out some oft-repeated code. Bug: T350626 Depends-On: I6c12db1e0c42fe5b50ef43a9b6ff6804f44081ea Depends-On: I0d557951b8e17de05e8ceadeb6c18d3811bbdaa8 Change-Id: Iec19f9f08a4d88ea534ffa7b24e6e01ffbba2723
* Namespace all remaining files in includes/filerepoJames D. Forrester2025-03-191-1/+1
| | | | | Bug: T353458 Change-Id: I35864ad9bd48701703c51367d62f8ebde963c52d
* Namespace all remaining files in includes/pageJames D. Forrester2025-03-181-1/+1
| | | | | Bug: T353458 Change-Id: I7a9c74f2106655d41ae029742090253f541bd4a6
* OutputPage: Remove forgotten @deprecated commentsthiemowmde2025-03-141-41/+13
| | | | | | | | | | | | | | The comments are obsolete since I437ab7d. I think we just forgot to remove them. While I am here I also try to update the type hints and make them more specific, if possible. Two language-level "bool" are added where I am 100% sure it can not cause any problems. I'm intentionally not doing the same anywhere else. Change-Id: I7d2bb8ff038f8e0f262a2822b30fafa3ef7a7ca5
* Update PHPDocs for OutputPage::getIndicators() and relatedthiemowmde2025-03-111-4/+4
| | | | | | | We can be quite a bit more specific here. It's also pretty important to understand that the strings are actually HTML. Change-Id: I2a8a973a75510ab0fe16b5b5e1eb5fa02e18a114
* output: Use associative arrays to store modulesMáté Szabó2025-02-201-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - OutputPage::addModules() and OutputPage::addModuleStyles() currently store added module names in two lists, mModules and mModuleStyles. - The contents of these lists then get passed to array_unique() when OutputPage::getModules() is invoked, to filter out any duplicate module names. - In I4f70ff15becbc4991c4f1b0307a14d5354c79dc1, we would like to modify UserLinkRenderer::userLink() to automatically add the requisite ResourceLoader modules to the output, instead of every page where userLink() is called needing to do so manually. This can cause these modules to be added thousands of times when a large list with many user links is rendered, e.g. on RecentChanges. - Running `php maintenance/run.php benchmarks/benchmarkEval output.php`, where output.php holds: ``` $out = ( new RequestContext() )->getOutput(); for ( $j = 1; $j <= 2000; $j++ ) { $out->addModules( 'ext.foo' ); } $out->getModules(); ``` takes about 4-5ms on my system. - Turning the properties into associative arrays and getting rid of the array_unique() call drops this to < 0.2ms. - These properties are exposed via public property accessors that have been deprecated since MW 1.38 and have no usages in codesearch.[1] Since we're changing how the properties work, this is a good time to remove the deprecated public property accessors. What: - Use associative arrays to store module names in OutputPage. - Document that addModules() and addModuleStyles() take a string|string[] rather than a string or an arbitrary array. - Add unit tests for the behavior. - Drop the deprecated public property accessors for mModules and mModuleStyles. [1] https://codesearch.wmcloud.org/search/?q=mModule%5BSs%5D Bug: T358469 Change-Id: I86c557a4ce7207359d100538c0d4b1ffa75fcbf9
* Replace a few misplaces is_object checksthiemowmde2025-02-121-1/+1
| | | | | | | | | | | | is_object is very rarely what we actually need. In many cases we know exactly what the object can be, and should check for that specific class or for null. A database row is an instance of stdClass. Checking that with is_object also works but is less correct and would allow stuff we cannot accept in these places. Change-Id: I1dc663d7325cabc059ef11c4845b0189208e907f
* ResourceLoader: Copy ResourceLoader::inDebugMode to OutputPageHannah Okwelum2025-02-051-1/+25
| | | | | | | In addition to moving inDebugMode to OutputPage, global variables have been replaced with local context. Bug: T36738 Change-Id: I70958c5c2096104d6f06aac499fecacd49ee0de3
* Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-171-10/+0
| | | | | | | | | | | | | | | | Same as Ia294bf4 did for 1-line comments. This patch removes slightly more complex 2-line PHPDoc comments that don't add any new information to the code, but literally repeat what the code already says. They say "don't document the code, code the documentation", and we are doing this more and more. We just tend to forget to remove the obsolete comments. Note I'm also removing a line of text in a few cases when it's very short and literally says the same as the method name. Again, such comments add zero new information. Change-Id: I01535404bab458c6c47e48e5456403b7a64198ed
* Remove use of BagOStuff TTL constants from unrelated codeTimo Tijhof2025-01-131-2/+1
| | | | | | | | | | | | Neither of these are related to BagOStuff or other object cache expiry. * Article/OutputPage caller related to HTTP Cache-Control and its 'max-page' pragma. * expireTemporaryAccounts.php was about Unix timestamps. Bug: T353529 Bug: T364652 Change-Id: I78af9a126696144021fc8f4585a6f4b2931ed8a6
* Remove deprecated hook OutputPageMakeCategoryLinksFomafix2024-12-182-76/+37
| | | | | | | The hook is deprecated since I8ea56f2d111aeccee158c40b8379383e92154d8a included in MediaWiki 1.43. Change-Id: Icdf724fa2eeab10d4895fa1d45d7ff7320626c4e
* Merge "ResourceLoader: Use MW_INSTALL_PATH constant in transformResourcePath()"jenkins-bot2024-12-111-1/+1
|\
| * ResourceLoader: Use MW_INSTALL_PATH constant in transformResourcePath()Timo Tijhof2024-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function was created in I7f38bfc1be (419db58c8b), which predates the existence of MW_INSTALL_PATH. If created today, I would have simply used this constant. But, given that was created when $IP was the standard, we naturally wrote tests for it the same way, which still predated the constant, in Ic5a4af705c (a9d14289d7). Then, a few years later in commit I7142af16d6 (cf581bb2ca), $IP was replaced with two things: a constant MW_INSTALL_PATH, and a mutable $wgBaseDirectory, on the very reasonable assumption that, if $IP is overwritten in tests, then it could not be migrated to a constant. At least for ResourceLoader, this turns out not to be the case. The only reason $IP was overwritten was to shorten the path in the test fixture. The only thing transformResourcePath() cares about is whether a file is served within MediaWiki's install path (where it can map the URL to a file on disk, and md5-hash that), or served externally. In PHPUnit we want to test it both ways, and given that the PHPUnit files are all within /w/, this is perfectly testable as-is without needing to overwrite MW_INSTALL_PATH. It just needs a slightly longer URL. Change-Id: If3b7942d25f3d8380fe76f5c81faa275d2e013c2
* | OutputPage: Minor cleanupReedy2024-12-021-36/+41
| | | | | | | | | | | | | | * Mostly typos * Comment locations Change-Id: Id00d27ef8e2bc397b49004241600741fd29c9260
* | Merge "Use ParserOutput::getLinkList() internally"jenkins-bot2024-11-191-3/+19
|\ \
| * | Use ParserOutput::getLinkList() internallyC. Scott Ananian2024-11-151-3/+19
| |/ | | | | | | | | | | | | | | This replaces the internal uses of the deprecated ParserOutput::get* methods and isolates the ParserOutput internal representation from most of the users. Change-Id: I32df68714ffdf2f0745b974f47bc3ccceef1f41c
* / Don't copy POST query params when generating link/redirect URLsBartosz Dziewoński2024-11-161-1/+1
|/ | | | | | | | | | | | | | | | | | | | Use WebRequest::getQueryValues() instead of WebRequest::getValues() whenever the result is used to generate links or redirect URLs, so that only GET query params are copied and not POST params. This is the same change as I53e58c16cd1292d78b5775358fc180901f4ce203 (for T309907), but repeated in several more places. Two of these had bugs filed for it (T152920, T291852), others were as yet undiscovered. Some of my changes have no effect in practice (e.g. when the code is guarded by wasPosted()), but I'm changing them anyway to avoid perpetuating the bad pattern. Bug: T152920 Bug: T291852 Change-Id: I67fbf82a7ec084623595e6aff62c26dbcce8fa4d
* Add type hints to detect bool/null message paramsBartosz Dziewoński2024-11-141-3/+8
| | | | | | | | | | | | Add more precise type hints to every method I could find that takes message params as arguments, so that Phan will warn if bool or null is passed, which is deprecated (T378876). Errors found in this repository thanks to these checks are fixed in I286a4a51e879bdf61f65c87dc078621c51045bee. Bug: T378876 Change-Id: I3e0df790ff9db2fa630f82408a7254a359fe61ca
* Revert^2 "Skin: [BREAKING CHANGE] Remove support for rendering outside body ↵Zabe2024-10-301-1/+1
| | | | | | | | | | element" This reverts commit efe9d29472481887883b59114a00d38c15ad38b8. Reason for revert: not the issue Change-Id: Ifef8358462ba29e2b20f24d6e63daa2243d7afee
* Revert "Skin: [BREAKING CHANGE] Remove support for rendering outside body ↵Jforrester2024-10-291-1/+1
| | | | | | | | | | | element" This reverts commit c7656257159a3d85422f4558f5add6df1564f3c3. Reason for revert: Train-breaking deprecation / breaking change, let's revert now and fix later. Bug: T378531 Change-Id: Id05b9f3aa9156473c194ebae2c8c672b0b47b6b5
* Skin: [BREAKING CHANGE] Remove support for rendering outside body elementJon Robson2024-10-231-1/+1
| | | | | | | | | | | | | | | | | | | 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
* Merge "Remove support for using Skin::addToBodyAttributes"jenkins-bot2024-10-211-9/+0
|\
| * Remove support for using Skin::addToBodyAttributesAmmarpad2024-10-201-9/+0
| | | | | | | | | | | | This is back compat logic for a removed Skin method since 1.35 Change-Id: I526973e97f9093fd082bfb9a9aa85edaebc1126d
* | OutputPage::setRobotPolicy(): deprecate 'index' after 'noindex'C. Scott Ananian2024-10-181-1/+1
| | | | | | | | | | | | | | | | | | 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
* | Deprecate OutputPage::{get,set}PreventClickjacking()C. Scott Ananian2024-10-171-1/+6
| | | | | | | | | | | | | | This is redundant with the same-named methods on ParserOutput. Bug: T301020 Change-Id: I60455186e3a6e9b4329ff09e2f7ea920e2e05192
* | Deprecate OutputPage::{get,set}IndexPolicy()C. Scott Ananian2024-10-171-4/+6
| | | | | | | | | | | | | | This is redundant with the same-named methods on ParserOutput. Bug: T301020 Change-Id: I41dcca30e106f77d12d9afe780f8578a4f1c81c9
* | Use OutputPage::$metadata to store language linksC. Scott Ananian2024-10-171-28/+7
| | | | | | | | | | Bug: T301020 Change-Id: I0208d4670817c52c917e3fca680451a170330909
* | Use OutputPage::$metadata to store the 'prevent clickjacking' flagC. Scott Ananian2024-10-171-12/+7
| | | | | | | | | | | | Bug: T301020 Depends-On: I885f778eef92fa7d2b7d6a2c2997db6a8b0142e5 Change-Id: I3bfd47b078a5b84a88fffc04b48abe4c0023370f
* | Use OutputPage::$metadata to store index policyC. Scott Ananian2024-10-171-8/+48
| | | | | | | | | | | | | | | | | | | | 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
* | Use explicit nullable type on parameter argumentsUmherirrender2024-10-161-3/+3
|/ | | | | | | | | | | 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
* Namespace all remaining classes in includes/parserJames D. Forrester2024-10-151-1/+1
| | | | | Bug: T353458 Change-Id: If02cc9b1ff78e26c1cf8c91ee4695845eb133829
* Remove meaningless @var documentation from constantsthiemowmde2024-10-091-1/+1
| | | | | | | | | 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
* OutputPage: Remove reference to outdated E_STRICTTimo Tijhof2024-10-061-5/+3
| | | | | | | | | | | | | 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
* Add namespace to remaining parts of Wikimedia\FileBackendJames D. Forrester2024-10-031-1/+1
| | | | | Bug: T353458 Change-Id: I49c843c9d8f6459c0fbf774afeea7a82fa564b59
* Deduplicate language links in ParserOutput and OutputPageC. Scott Ananian2024-09-261-10/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Merge "Remove ParserOutput::getText() calls from core (runOutputPipeline)"jenkins-bot2024-09-061-1/+1
|\
| * Remove ParserOutput::getText() calls from core (runOutputPipeline)Isabelle Hurbain-Palatin2024-09-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Introduce runOutputPipeline and clone by default"jenkins-bot2024-09-061-1/+1
|\|
| * Introduce runOutputPipeline and clone by defaultIsabelle Hurbain-Palatin2024-09-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Add missing documentation to class properties (frontend-related)"jenkins-bot2024-09-061-0/+7
|\ \