aboutsummaryrefslogtreecommitdiffstats
path: root/includes/content
Commit message (Collapse)AuthorAgeFilesLines
...
* Add namespace and deprecation alias to JavaScriptContentHandlerEbrahim Byagowi2024-05-171-1/+7
| | | | | | | | | This patch introduces a namespace declaration for the MediaWiki\Content to JavaScriptContentHandler and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: Ic30789d4e80a27004b6bc3b3ba891a7332a5e1ba
* Add namespace and deprecation alias to JavaScriptContentEbrahim Byagowi2024-05-172-0/+6
| | | | | | | | | 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
* Add namespace and deprecation alias to FormatJsonEbrahim Byagowi2024-05-161-0/+1
| | | | | | | | | This patch introduces a namespace declaration for the MediaWiki\Json to FormatJson and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: I5e1311e4eb7a878a7db319b725ae262f40671c32
* ContentHandler: Hard-deprecate deprecated methodsJames D. Forrester2024-05-011-2/+11
| | | | | | Depends-On: If0049aabff2dedfcecf739dbbcf688d16d9cc864 Depends-On: I7f82748be5a7c16525bc57e33ebeb0bb974267b9 Change-Id: Ife87b189e73883cfc8a4ef115d431ec8ad37dea7
* Replace all instances of "per default" with "by default"Tim Starling2024-04-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to the dictionary, "per" (or more conventionally "as per") means "according to". Refer OED "per" sense II.3.a. For example: "No value was passed, so return null, as per default". In this sentence, we are not specifying the default, we are referring to the default. This correct usage of "per default" was used nowhere in MediaWiki core as far as I can see. Instead we have "per default" being used to mean "by default", that is, giving the value to use when no explicit value was specified. In OED, the phrase "by default" is blessed with its own section just for computing usage: "P.1.e. Computing. As an option or setting adopted automatically by a computer program whenever an alternative is not specified by the user or programmer. Cf. sense I.7a." There are highly similar pre-computing usages of the same phrase, whereas the phrase "per default" is not mentioned. As a matter of style, I think "per default" should not be used even when it is strictly correct, since the common incorrect usage makes it ambiguous and misleading. Change-Id: Ibcccc65ead864d082677b472b34ff32ff41c60ae
* Hard-deprecate ContentHandler::getContentText()Taavi Väänänen2024-04-211-1/+2
| | | | | | | | No remaining uses in WMF-deployed extensions. (Although there is a similarly named but separate function in CiteThisPage.) Bug: T268041 Change-Id: Iec68845c631758fe85d32a939b28b6d8b1243858
* IReadableDatabase::select cannot return falseUmherirrender2024-04-181-1/+1
| | | | | | | | | | | | Remove check for false from IDatabase::select as this is not possible A DBQueryError is thrown (documented since efda8cd3 / I056b7148) Use IResultWrapper::numRows to check for empty IResultWrapper This ignores includes\libs\rdbms as QUERY_SILENCE_ERRORS is an internal option to get false from this function Change-Id: I4b2fc26ca0e68612f6beadc01e68097a74962c84
* Merge "HtmlOutputRendererHelper: fall back to page language"jenkins-bot2024-03-131-0/+5
|\
| * HtmlOutputRendererHelper: fall back to page languagedaniel2024-03-061-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HtmlOutputRendererHelper should not crash hard if the ParserOutput has no language set. ParserOutput may come from a variety of places, we should be lenient about it not having a language. However, we should try harder to actually set a language on ParserOutput if we have one available. So this also updates PageBundleParserOutputConverter to keep the ParserOutput's language in sync wit the language header in the PageBundle. Bug: T349868 Bug: T353689 Bug: T359426 Change-Id: I2edf20dc3b199e22cda2f32bc858c21ca7d8f4bd
* | WikiTextStructure: Use raw text from ParserOutputBartosz Dziewoński2024-03-081-4/+1
|/ | | | | | | | | | | It should be good enough for search indexing, and it avoids a dependency on ParserOutput, Skin, OutputTransforms, and lots of other slow and scary code. getText() is deprecated, and we were trying to use a non-existent option 'enableSectionEditTokens', so fixing that is nice as well. Change-Id: Iac6b850af883ded414bdc26e954b0c0949af3b58
* Merge "ParserOutputAccess: only use PoolCounter if the caller asks for it."jenkins-bot2024-03-011-0/+16
|\
| * ParserOutputAccess: only use PoolCounter if the caller asks for it.daniel2024-02-291-0/+16
| | | | | | | | | | | | | | | | | | | | | | PoolCounterWorkArticleView was not designed for use by all callers of getParserOutput. It provides stampede protection but does not generally prevent duplicate concurrent parsing, and it may result in stale cache entries being returned to the caller. This is acceptable for page views, but not other use cases like editing or updating secondary derived data. Bug: T352837 Change-Id: Ie532c17e5b86e8e1adbb57ecd5c5c6405b83bf8f
* | Merge "content: lowercase model name before looking up message"jenkins-bot2024-03-011-1/+2
|\ \
| * | content: lowercase model name before looking up messageSiddharth VP2024-02-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In ContentHandler::getLocalizedName, lowercase the model name before looking up the relevant i18n message. This change allows localisation of names of content models which contain an uppercase character, which isn't possible today as message keys with uppercase chars cause build to fail. Bug: T358341 Change-Id: I0f090f21ce2b0f6d92790ae9f2b755dabb2e7082
* | | Tighten up phan type for ContentRenderer::getParserOutput()C. Scott Ananian2024-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Passing an `int` as the $revision was deprecated with a warning, but also tighten up the phan @param type to hopefully catch a few more cases of this in CI rather than the logs. Bug: T350538 Bug: T358243 Change-Id: I73a3b77d9982bcfaa9c235cde31fafff9a13e92e
* | | [ParserOutput] Rename $mText to $mRawText and ::setText() to ::setRawText()C. Scott Ananian2024-02-206-8/+8
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ParserOutput::getText() is not a simple getter, but does transformations on the "text" of the ParserOutput; the simple getter is named ::getRawText(). To maintain consistency, rename ParserOutput::setText() to ::setRawText() and the property name ParserOutput::$mText to ::$mRawText so future readers are not confused. The JSON property name as it appears in the serialized ParserCache is left as 'Text' so that we don't have any forward- or backward- rollback issues. Change-Id: I3ef34814ab9473cc70d0a6806e8c5a4a02b73491
* | Merge "WikiPage: remove ::suppressTOC hack"jenkins-bot2024-02-102-0/+8
|\ \
| * | WikiPage: remove ::suppressTOC hackC. Scott Ananian2024-02-052-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of overriding the ParserOptions for the page, just clear the section data and set the NO_TOC flag in the resulting ParserOutput. Bug: T307691 Bug: T350626 Change-Id: I6a24edcc5eb5bed50adcfb8648b953afa54ac0f6
* | | Revert "Do not hard deprecate passing an int to ↵C. Scott Ananian2024-02-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ContentRenderer::getParserOutput" This reverts commit 7fa728d6eca6fb4504ef6b46ba7cded1d5d71f81. Reason for revert: The remaining use in FlaggedRevs has been fixed. Depends-On: I3ad410bbbe12cfbe0caf32507dadbe2ae72e764f Change-Id: I9128231ac4f3b49db616bd4ecf2f950c44d4b0d2
* | | Merge "WikiTextStructure: Support heading tags with attributes"jenkins-bot2024-02-091-1/+1
|\ \ \
| * | | WikiTextStructure: Support heading tags with attributesBartosz Dziewoński2024-02-081-1/+1
| |/ / | | | | | | | | | Change-Id: Ie68c7c695cb84ed6844d6d422284dca8c0c13072
* | | Namespace includes/contextJames D. Forrester2024-02-086-2/+9
| | | | | | | | | | | | | | | Bug: T353458 Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
* | | Do not hard deprecate passing an int to ContentRenderer::getParserOutputTaavi Väänänen2024-02-081-1/+0
| | | | | | | | | | | | | | | | | | | | | Still used in Wikimedia deployed code. Bug: T357006 Change-Id: I107d6d830ef5b4bc7914a98945882a5e1b0d144c
* | | Rename ParserOutput::{get,set}Timestamp() to ::{get,set}RevisionTimestamp()C. Scott Ananian2024-02-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This avoids confusion with the "render timestamp" held by the cache, and is consistent with ::get*RevisionId() etc. The old ::getTimestamp() and ::setTimestamp() methods have been deprecated. Change-Id: Idb5e687709c98086c5d3075d31885c58a0723197
* | | Add ParserOutput::{get,set}RenderId() and set render id in ContentRendererC. Scott Ananian2024-02-071-4/+49
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Set the render ID for each parse stored into cache so that we are able to identify a specific parse when there are dependencies (for example in an edit based on that parse). This is recorded as a property added to the ParserOutput, not the parent CacheTime interface. Even though the render ID is /related/ to the CacheTime interface, CacheTime is also used directly as a parser cache key, and the UUID should not be part of the lookup key. In general we are trying to move the location where these cache properties are set as early as possible, so we check at each location to ensure we don't overwrite a previously-set value. Eventually we can convert most of these checks into assertions that the cache properties have already been set (T350538). The primary location for setting cache properties is the ContentRenderer. Moved setting the revision timestamp into ContentRenderer as well, as it was set along the same code paths. An extra parameter was added to ContentRenderer::getParserOutput() to support this. Added merge code to ParserOutput::mergeInternalMetaDataFrom() which should ensure that cache time, revision, timestamp, and render id are all set properly when multiple slots are combined together in MCR. In order to ensure the render ID is set on all codepaths we needed to plumb the GlobalIdGenerator service into ContentRenderer, ParserCache, ParserCacheFactory, and RevisionOutputCache. Eventually (T350538) it should only be necessary in the ContentRenderer. Bug: T350538 Bug: T349868 Followup-To: Ic9b7cc0fcf365e772b7d080d76a065e3fd585f80 Change-Id: I72c5e6f86b7f081ab5ce7a56f5365d2f75067a78
* | Merge "WikiTextStructure/WikitextContentHandler: Minor cleanup"jenkins-bot2024-02-012-91/+63
|\ \
| * | WikiTextStructure/WikitextContentHandler: Minor cleanupReedy2024-02-012-91/+63
| | | | | | | | | | | | Change-Id: If2f8243867994609d82618e61ddaaacca3516990
* | | Replace unchecked MWException with SPL exceptionsDaimona Eaytoy2024-01-281-4/+2
| |/ |/| | | | | | | Bug: T328220 Change-Id: I4e0454ce3ad3741756e2010a76e548d6c9a6bcb5
* | Drop deprecated config ContentHandlerTextFallbackAmir Sarabadani2024-01-261-28/+1
| | | | | | | | | | | | | | | | | | Soft-deprecated since 1.37 and hard-deprecated since at least I9776d11d4e2d184 (1.39) Not set in production. Change-Id: I0b25e89d1652dfa697ab1176a1e2b6ca3163bdab
* | Remove more indirect calls to IDBAccessObject::READ_* constantsAmir Sarabadani2024-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | Found via (?<!IDBAccessObject)::READ_ We are planning to deprecate and remove implementing IDBAccessObject interface just to use the constants. Bug: T354194 Change-Id: I89d442fa493b8e5332ce118e5bf13f13b8dd3477
* | Change uses of getDBLoadBalancerFactory() to getConnectionProvider()Bartosz Dziewoński2024-01-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Update cases where one of the IConnectionProvider methods is called immediately. This doesn't really change anything, but I hope it helps promote getConnectionProvider() as the common way to do this. Follow-up to 8604c384f624273f46b653ec252ffaed30e6ff89. Change-Id: Id0e7d02bab0c570343c2b1f03c70b44ee39db112
* | Merge "Replace unspecific exceptions with InvalidArgumentException"jenkins-bot2024-01-211-7/+3
|\ \
| * | Replace unspecific exceptions with InvalidArgumentExceptionthiemowmde2024-01-201-7/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | A LogicException is very generic and doesn't mean much. An InvalidArgumentException is also a LogicException, but more specific: A method was called (for whatever reason – bad code, bad user input – we don't know) with an invalid, unsupported argument. This is exactly what's going on in these cases. BadMethodCallException does have a confusing name and is often misused because of this. It's documented as "thrown if a callback refers to an undefined method or if some arguments are missing". That's something else and not what's going on in these cases. Change-Id: Id446227f578ba701e22acd5e530ffb795e76c147
* | Replace deprecated MWExceptionDaimona Eaytoy2024-01-191-1/+0
| | | | | | | | | | | | | | | | Also remove some unchecked exception from doc comments. Bug: T328220 Bug: T240672 Change-Id: I88b1e948ce5da77d9c4862a2b98793d6ba00cf8b
* | Merge "EditPage: Improve auto-merge in trivial non-conflict situations"jenkins-bot2024-01-191-1/+6
|\ \
| * | EditPage: Improve auto-merge in trivial non-conflict situationsthiemowmde2024-01-081-1/+6
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a direct follow up to I5b1438b. The check we added there already made the situation much better. It triggers when the user didn't even made a change to the text. The new check(s) in this patch trigger when the edit is based on either the latest revision or another revision identical to the latest revision. A 3-way-merge doesn't make sense in these situations because there aren't 3 different versions, only 2. For reference: * $oldContent = the base revision the edit is based on * $myContent = the unsaved edit we are trying to save * $yourContent = the latest revision already in the database As in I5b1438b it's unfortunately not possible to give easy steps to reproduce the issue. The setup that made me run into this is explained in https://www.mediawiki.org/wiki/Topic:Wugee2vl8m8kqr2h This is also nice to have for performance reasons, and might help reducing other false-positives where conflicts are detected that aren't really conflicts. One way to test this on dev machines is to break your $wgDiff3 config. This will make wfMerge() always return false, as if every edit is a conflict. Change-Id: I1a1523d1cc6fb09472cb40e41da85109a5fce851
* | Merge "Replace deprecated MWException"jenkins-bot2024-01-162-13/+3
|\ \
| * | Replace deprecated MWExceptionDaimona Eaytoy2024-01-162-13/+3
| | | | | | | | | | | | | | | Bug: T328220 Change-Id: Ic45438d9e6bbf127f1415add81ab902044765840
* | | Stop unstubbing and passing $wgLang to onPageContentLanguage hook handlersAaron Schulz2024-01-152-8/+4
| |/ |/| | | | | | | | | | | | | | | All handlers in WMF-hosted repos no longer make use of nor type-hint against this field. For compatibility with such handlers, pass null and document the value as being deprecated and of type mixed. Bug: T299369 Change-Id: Ie192beb6018ed40e2bc1920b23802ea62d1b105c
* | Merge "Skip TextContentHandler::merge3() when texts are identical"jenkins-bot2024-01-051-0/+5
|\ \ | |/ |/|
| * Skip TextContentHandler::merge3() when texts are identicalthiemowmde2024-01-051-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is mostly done for performance reasons, but can even be user-facing in rare situations. Unfortunately it's really hard if not impossible to provide steps to reproduce it. I hope the proposed line of code makes sense on it's own. The setup that made me run into this edge-case is explained in https://www.mediawiki.org/wiki/Topic:Wugee2vl8m8kqr2h But the idea is always the same, with or without the TwoColConflict interface: When $wgDiff3 is misconfigured wfMerge() will return false, as if a conflict was detected. But we can easily check if it's even possible to have a conflict (impossible when the texts are identical) even without having access to diff3. The relevant caller is EditPage::mergeChangesIntoContent(). We could add the new conditional to this spot as well. But I feel like it makes more sense to always do it, for all possible callers. The extra identity check is extremely inexpensive, even with long texts. Change-Id: I5b1438b1ff71590718120367eb414b8e9754236e
* | Indent JsonContent using tabsTaavi Väänänen2024-01-021-1/+1
|/ | | | | | | | | This reduces JSON page sizes by a significant amount as one tab is one characters and four spaces is four characters. Bug: T326065 Depends-On: I67c87484ea4ec23f703480c8d423b800c74f6518 Change-Id: I94e9580d48066b011d33d18751969c43799aa76a
* Namespace ParserOutputJames D. Forrester2023-12-1414-5/+14
| | | | | | | Most used non-namespaced class! Bug: T353458 Change-Id: I4c2cbb0a808b3881a4d6ca489eee5d8c8ebf26cf
* Merge "Only cache expensive renderings"jenkins-bot2023-11-301-0/+4
|\
| * Only cache expensive renderingsdaniel2023-11-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pages that are fast to render can be omitted from the parser cache to preserve disk space and cache write operations. The threshold is configurable per namespace, so the tradeoff can be evaluated based on different access patterns. For example, pages that are accessed rarely, like file description pages on commons, may have a high threshold configured, while pages that are read frequently, like wikipedia articles, may be configured to be always cached, using a 0 threshold. Filtering is based on a time profile recorded in the ParserOutput. A generic mechanism for capturing the timing profile is implemented in the ContentHandler base class. Subclasses may implement a more rigorous capture mechanism. Bug: T346765 Change-Id: I38a6f3ef064f98f3ad6a7c60856b0248a94fe9ac
* | Merge "Remove deprecated methods from Content interface"jenkins-bot2023-11-288-500/+2
|\ \ | |/ |/|
| * Remove deprecated methods from Content interfacedaniel2023-11-218-500/+2
| | | | | | | | | | | | | | | | | | | | Several methods on the Content interface had been deprecated in 1.35 and 1.36 in favor of corresponding methods on the ContentHandler base class, to allow implementations of these methods to use proper dependency injection. This patch removes backwards compatibility support for subclasses that were overriding these methods. Change-Id: I8e474a1cc4dec760a7f6db25e4b313392f3723b1
* | Namespace remaining files under includes/deferredJames D. Forrester2023-11-221-0/+1
|/ | | | | Bug: T166010 Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
* Migrate off wfGetDB() in more places to ICPAmir Sarabadani2023-11-201-1/+1
| | | | | | | | | | | | | | | | | This function is uber-deprecated, meaning even its replacement is deprecated, We have already migrated in static functions and more. In this batch, all calls have been migrated that there is already a call to MediaWikiServices::getInstance() making the migration easier. Of course in most cases, they should eventually turn into proper service injection but this at least makes it clear what services should be injected. Also removing "category" group since we are removing all groups except a handful from mw (see T263127 for more information). Bug: T330641 Change-Id: I90cd35ee45a37eb6e6bf7a531cc8f75effbd0328
* Plain text content model should show line breaksNovem Linguae2023-11-101-0/+2
| | | | | | | | | | | | | | Before this patch, if you go to Special:ChangeContentModel and set the content model of a page to plaintext, and it has line breaks, and you go view the page, you cannot see the line breaks. All the text is pushed together. This patch fixes that by wrapping everything in <pre>. nl2br was also considered, but wrapping in <pre> transforms the HTML less, so is a simpler solution. Bug: T202424 Change-Id: Iaa08c24f19267e48a92083e5dc4b886d0fe80288