aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/page
Commit message (Collapse)AuthorAgeFilesLines
...
* | Add ParserOutput::{get,set}RenderId() and set render id in ContentRendererC. Scott Ananian2024-02-071-2/+4
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* tests: Use namespaced class names in @covers annotationsUmherirrender2024-01-271-1/+1
| | | | | | Assist from 8c9cb701e56226cac43fee2fa24b0d0e586f1733 Change-Id: I47897c499028d9e24c00ad0bc6ba7fd8002d9bc1
* Merge "Change more uses of getDBLoadBalancerFactory() to ↵jenkins-bot2024-01-233-3/+3
|\ | | | | | | getConnectionProvider()"
| * Change more uses of getDBLoadBalancerFactory() to getConnectionProvider()Bartosz Dziewoński2024-01-233-3/+3
| | | | | | | | | | | | | | | | | | | | | | Some less trivial cases. Also update variable names. 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: I6657d783375fac5c7fa856b884ff1fb09285e94c
* | title: Make TitleArrayFromResult via TitleFactory serviceDerick Alangi2024-01-231-3/+3
|/ | | | | | | | | | | | | | The TitleFactory should really be where TitleArrayFromResult should live as it's a place where Title objects are created based on certain specifications. This patch tries to consolidate the creation of TitleArrayFromResult via the TitleFactory services and in the future, we will consolidate more of the logic and kill TitleArrayFromResult. Follow up on: a99ec1b and e54665d. Change-Id: I98215af3252d756de4435b77d1280dacda8e85dc
* Allow MergeHistory to split up joined revisions with same timestampPppery2024-01-051-0/+37
| | | | | Bug: T183501 Change-Id: Iedd818a83838683fb07334aade11754557828062
* WikiFilePage: Fix handling of file redirectsdaniel2024-01-031-0/+107
| | | | | | | | | File::getRedirected() will return null per default. WikiFilePage was interpreting this as "we have been redirected", because null is different from the file's name. Bug: T353688 Change-Id: I40d5b8db3b5f0d14d1c801d86982b3e48eac14c1
* Revert "Use Remex for DeduplicateStyles transform"Isabelle Hurbain-Palatin2023-12-221-3/+1
| | | | | | | | | | | This reverts commit 82da9cf14be08e9458f58fa96be51966a2fe7cb1. Passing through Remex seems to have unexpected consequences to be investigated but, for the sake of unbreaking the UBN, let's revert this first. Bug: T353920 Change-Id: Iaac7942aa77aee5ab525852ac5b41dd516ff13c9
* PoolCounter: Namespace classesAmir Sarabadani2023-12-201-0/+1
| | | | | | | | Two of the classes in this directory have already namespaced to MediaWiki\PoolCounter. Bug: T353458 Change-Id: Ie41f8d935f7623bb40040a5eb78f99c6d7b7b75e
* Use Remex for DeduplicateStyles transformC. Scott Ananian2023-12-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | The previous implementation was using an ad-hoc regular expression which was matching inside the data-mw attribute of Parsoid output, eg: <sup about="#mwt42" [...] typeof="mw:Extension/ref mw:Error" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;name&quot;:&quot;infobox_stats_ref_rail&quot;},&quot;body&quot;:{&quot;html&quot;:&quot;<style data-mw-deduplicate=\&quot;TemplateStyles:r1133582631\&quot; typeof=\&quot;..."> After substitution, the <link> element inserted contained " instead of &quot; and so broke out of the attribute. Instead use a proper HTML tokenizer (via wikimedia/remex-html) so that we don't allow bogus matches inside attribute values. To fix up tests: * Don't deduplicate styles when parsing UX messages (also helps performance) * Don't deduplicate styles in ContentHandler integration tests * Don't deduplicate styles by default in parser tests (unless explicit option is set) Depends-On: Id9801a9ff540bd818a32bc6fa35c48a9cff12d3a Depends-On: I5111f1fdb7140948b82113adbc774af286174ab3 Followup-To: Ic0b17e361bf6eb0e71c498abc17f5f67f82318f8 Change-Id: I32d3d1772243c3819e1e1486351d16871b6e21c4
* tests: Use namespaced classesUmherirrender2023-12-114-0/+4
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statements and changes to docs done manually Change-Id: Ib326ae1e5c8409a98398c721e8b8ce42c73bd012
* Remove deprecated Article::__get/__set magic functionsUmherirrender2023-12-061-25/+0
| | | | Change-Id: If8e8006e88f11848f129ebfb10d5093d492287bb
* Merge "Replace a few manually crafted assertTrue assertions"jenkins-bot2023-11-302-6/+6
|\
| * Replace a few manually crafted assertTrue assertionsthiemowmde2023-11-232-6/+6
| | | | | | | | | | | | | | … replace them with the named convenience methods provided by PHPUnit. Change-Id: Ib46dbc3ab7926cf176477254f466b9bdd3be7c46
* | page: Widen `@covers` annotations in WikiPageDbTestTimo Tijhof2023-11-291-117/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > We lose useful coverage and spend valuable time keeping these tags > accurate through refactors (or worse, forget to do so). > > I've audited each test to confirm it is a general test of the > subject class, where adding any called methods would be an accepted > change, thus widening it is merely a no-op that clarifies intent > and reduces maintenance. I am not disabling the "only track coverage > of specified subject" benefits, nor am I claiming coverage in > in classes outside the subject under test. > > Tracking tiny details per-method wastes time in keeping references > in sync during refactors, time to realize (and fix) when people > inevitably don't keep them in sync, time lost in finding uncovered > code to write tests for only to realize it was already covered but > not yet claimed, etc. https: //gerrit.wikimedia.org/r/q/owner:Krinkle+is:merged+message:%2522Widen%2522 Change-Id: I8d8a185e8bcdf854ddd4fd3930d3bd6268f38083
* | Merge "Fix testSourceUpdateWithRedirectSupport"jenkins-bot2023-11-281-2/+7
|\ \
| * | Fix testSourceUpdateWithRedirectSupportPppery2023-11-171-2/+7
| | | | | | | | | | | | | | | Bug: T349431 Change-Id: I57794b599ac6ffa5a5dc3ef5a9f53ac5b7417633
* | | tests: Remove dead code from WikiPageDbTest::assertPreparedEditNotEqualsUmherirrender2023-11-241-10/+3
| |/ |/| | | | | | | | | | | | | | | | | | | | | PreparedEdit->timestamp is not declared. There is __get() support to read the property, but not __set() to set the property. Setting the timestamp on the clone results in creation of a dynamic property, that is deprecated in php8.2 and make the test fail. Remove the dead code, the assertion of not-equal also not test this property as there is no PreparedEdit::equals() function. Change-Id: Ic6218b6357a18eedd95b6bfc73b178b5f784447e
* | Namespace remaining files under includes/deferredJames D. Forrester2023-11-221-0/+1
| | | | | | | | | | Bug: T166010 Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
* | Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessaryJames D. Forrester2023-11-216-87/+0
|/ | | | | Bug: T342301 Change-Id: I5ea01f7ee103570165261bde0965c5b65e04c369
* Merge "WikiPage: Avoid loading redirect from replica after edit"jenkins-bot2023-11-151-0/+1
|\
| * WikiPage: Avoid loading redirect from replica after editErik Bernhardson2023-11-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After editing a page the WikiPage::updateRevisionOn method was setting mRedirectTarget to null, allowing it to be loaded from the redirects table. WikiPage::getRedirectTitle though always queries DB_REPLICA. This combination allowed PageSaveComplete hooks to sometimes receive the previous revisions data when invoking WikiPage::getRedirectTarget. On review of other database usages in WikiPage DB_REPLICA seems appropriate in getRedirectTarget. It could plausibly vary based on mDataLoadedFrom, but it didn't seem the use case was strong enough to implement and debug a new pattern of access here. Instead populate mRedirectTarget from updateRevisionOn. This avoids the extra round trip to the database, and ensures there can be no race in data loading. This adds some additional complexity, there are some transformations that happen between Content::getRedirectTarget and WikiPage::getRedirectTarget, those have been consolidated into a single function and invoked in both cases. Bug: T350299 Change-Id: I3dd75e0acf936aa900e442fb3ff4de9fb3150359
* | ParserOutputAccess: Change local cache from array to MapCacheLRUBartosz Dziewoński2023-11-081-1/+1
| | | | | | | | | | | | Daniel made me do it. Change-Id: I710b0341e240650d42110bc73a11acd0aa712397
* | parser: Move lang/dir and mw-content-ltr to ParserOutput::getTextTimo Tijhof2023-11-032-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | == 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
* Revert "Hacks to avoid cold cache misses after ParsoidOutputAccess changes"Subramanya Sastry2023-10-241-63/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * This reverts commit c1b82097. * This reverts commit 56025174. * This updates a test change from commit c8d0470f. * Now that ParsoidOutputAccess has become a thin wrapper over ParserOutputAccess and the code has landed in production without needing to be reverted, we can revert the above hacks as soon as the hits from the 'parsoid' instance start to go down to a small number. As of the time of creating of this patch, of the combined hits to the 'parsoid' and 'parsoid_pcache' instance, over 90% are now from the 'parsoid_pcache' instance. We can wait for a couple more days to watch how this number changes. * Note that once we deploy this patch, the accesses which would have hit in the 'parsoid' instance (with this hack) will instead result in a cache miss thus adding the full parse latency to REST API requests (whether by VisualEditor or by other clients). So, we need to figure out what the cutoff point is. While 3 weeks is a guaranteed switchover timeframe (because all entries in 'parsoid' cache will expire at that time and we'll get no more hits from there after that), note that we are at < 10% hits in this cache just 4 days after the train rollout. So, there is a good chance we could get beyond 95% by the end of this week. Bug: T347632 Change-Id: Ibd741b92b860b4d4b03ca220863debaf53fab44a
* Simplify/remove duplicate assertStatusOK and suchthiemowmde2023-10-192-11/+10
| | | | | | | | For example: * assertStatusGood = ok without any errors or warnings * assertStatusWarning = ok, but not good, i.e. there is a warning Change-Id: I4b3ec7a3c5b028c0505e1371c297a9c47e448b42
* MergeHistory: Support for pagelinks migrationAmir Sarabadani2023-10-181-1/+2
| | | | | Bug: T346457 Change-Id: Ifedb0a9b95c3f475b4e08535a6f90fda242b305b
* ParserOutputAccess: fix the wrapper div fetched from the fallback cacheC. Scott Ananian2023-10-061-1/+12
| | | | | Followup-To: I7f933fd61bf358c6ea0e0c1202231cac618f9e8d Change-Id: I502adc85cd2a75160f090b8979213b5d7563aefd
* Title: Use TitleArrayFromResult instead of TitleArrayDerick Alangi2023-10-031-2/+2
| | | | | | | | TitleArray is just a tiny little wrapper to TitleArrayFromResult, so use the latter instead of the former. I have plans of killing the former soon. Change-Id: Ia06a6bb370ce313f38d3ec9a221ed7296aec0ee2
* Hacks to avoid cold cache misses after ParsoidOutputAccess changesSubramanya Sastry2023-09-301-2/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ParsoidOutputAccess used a 'parsoid' ParserCache instance and did not set the 'useParsoid' parser option for tier 2 ParserOutput cache key computations. * ParserOutputAccess uses 'pcache' for legacy parser output and 'parsoid-pcache' for Parsoid parser output objects based on whether 'useParsoid' parser option is true or false. * 'parsoid-pcache' is right now very sparsely populated since useParsoid is only used for testing. * In Ic9b7cc0fcf36, where we make ParsoidOutputAccess a thin wrapper over ParserOutputAccess, all Parsoid parser output requests will go to ParserOutputAccess's 'parsoid-pcache' instance which is sparsely populated and hence will result in a lot of cold cache misses. * To eliminate this scenario, this patch adds hardcoded hacks to both ParserOutputAccess and ParserCache to query the 'parsoid' PC instance on cache misses to the 'parsoid-pcache' instance. Over a 3-week period, as 'parsoid-pcache' fills up, there will be fewer and fewer access to the 'parsoid' PC instance which will also expire. At the end of that period, we can remove this hack. T347632 tracks removal of these hacks. * Added new PHP unit test verifying that the hack work as intended. Bug: T332931 Change-Id: I7f933fd61bf358c6ea0e0c1202231cac618f9e8d
* Merge "WikiPage: Make internal updateRedirectOn() private"jenkins-bot2023-09-261-1/+2
|\
| * WikiPage: Make internal updateRedirectOn() privateBartosz Dziewoński2023-09-251-1/+2
| | | | | | | | | | | | | | | | | | | | We may do this without deprecation: https://www.mediawiki.org/wiki/Stable_interface_policy#Remove_guarantees The method is not used outside of this class: https://codesearch.wmcloud.org/search/?q=updateRedirectOn Change-Id: I5ff311557be656776f112c9a08feff8527a1d214
* | tests: Use $this->getDb() instead of wfGetDB() in integration testsAmir Sarabadani2023-09-252-10/+6
|/ | | | | | | Deprecated long time ago. Bug: T330641 Change-Id: Ia57f12d350c3346029aafae25534c9ed262a7e98
* page: Clean up PageProps file header and improve docsTimo Tijhof2023-09-241-18/+3
| | | | | | | | | | | | | * Move potentially duplicate brief and ingroup from file doc to class doc. <https://gerrit.wikimedia.org/r/q/message:ingroup+owner:Krinkle> * Ensure methods have an understable brief, separate from other text. <https://www.mediawiki.org/wiki/Manual:Coding_conventions/Documentation> * Flesh out type hints and improve descriptions. Change-Id: Icec95c82e063a499234106d31ce4a3989802f5ce
* tests: Migrate more cases to SQBAmir Sarabadani2023-09-212-16/+25
| | | | | Bug: T344971 Change-Id: Ia69d82d6a6e623b9032240dc910fb47ff5887661
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-195-0/+5
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* Namespace TitleValue under \MediaWiki\TitleJames D. Forrester2023-09-181-1/+1
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: I4c901d5c32696d8334ec30cede7d9b6f3d8d645e
* Merge "tests: Move test cases from /includes/ into sub folder"jenkins-bot2023-09-152-0/+764
|\
| * tests: Move test cases from /includes/ into sub folderUmherirrender2023-09-132-0/+764
| | | | | | | | | | | | | | Follow move of the tested class Most moves are part of T321882 Change-Id: I74ab45d6a5331dcb2ff0b65dc2cc7c6315146646
* | tests: Migrate some Database::select() calls to SQBAmir Sarabadani2023-09-131-4/+20
| | | | | | | | | | | | | | | | | | | | | | Done semi-automatically via migrateselect[1]. The script only accepted ascii chars until I found out and fixed it and now I can run it in more places. [1] https://gitlab.wikimedia.org/ladsgroup/migrateselect Bug: T344971 Change-Id: I3ffc8764d95600abd5c0ce00aaf2e83b2af9252d
* | Remove WikiPage::doDeleteUpdates(), deprecate ::doDeleteArticleBatched()Daimona Eaytoy2023-09-121-93/+0
|/ | | | | | | | Neither of them has known callers. WikiPage::doDeleteArticleBatched(), soft-deprecated in 1.37, is now hard-deprecated. ::doDeleteUpdates(), hard-deprecated in 1.37, is removed. Change-Id: I62cb896817039a88077a7a27a5dc0678892eb3cf
* s/NO_CACHE/OPT_NO_CACHE/g in ParserOutputAccess and testsSubramanya Sastry2023-09-101-2/+2
| | | | Change-Id: I9b853646b34bf212bab8602796f4258727827c50
* Merge "rdbms: Introduce ReplaceQueryBuilder"jenkins-bot2023-09-101-16/+6
|\
| * rdbms: Introduce ReplaceQueryBuilderAmir Sarabadani2023-09-081-16/+6
| | | | | | | | | | | | | | To replace IDatabase::replace() Bug: T335377 Change-Id: I446f7a09cfc0ee37c2e016052d452751f7333e27
* | Merge "Introduce ArchiveSelectQueryBuilder"jenkins-bot2023-09-072-20/+10
|\ \ | |/ |/|
| * Introduce ArchiveSelectQueryBuilderAmir Sarabadani2023-09-072-20/+10
| | | | | | | | | | | | | | Similar to RevisionSQB (Ifd690dc8f030) Bug: T344971 Change-Id: Ic520bcf09f4cc95ebd6a3990cff46dec5b7cd350
* | Merge "Make MediaWikiIntegrationTestCase::addCoreDBData a noop"jenkins-bot2023-09-072-8/+0
|\ \ | |/ |/|
| * Make MediaWikiIntegrationTestCase::addCoreDBData a noopDaimona Eaytoy2023-09-052-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | The method should never be called directly, so make it throw an exception. Nonetheless, mark it as deprecated and detect overrides in the constructor, so that anyone who tries to override this method will see a warning. Fix the few tests that were relying on the existence of the test page. Bug: T342428 Depends-On: Ic64ded5e2c0b59e7c888ece9566076058a125be4 Change-Id: I308617427309815062d54c14f3438cab31b08a73
* | Introduce RevisionSelectQueryBuilderAmir Sarabadani2023-09-062-18/+7
| | | | | | | | | | | | | | | | | | Deprecating RevisionStore::getQueryInfo() and cleaning up a lot of code Also removing a brittle test that wasn't really testing anything. Bug: T344971 Change-Id: Ifd690dc8f030f86e3567a717eaeb830cb6dc703b
* | Merge "Reorg: Move three output related classes to includes/Output/"jenkins-bot2023-09-051-0/+1
|\ \