aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Title.php
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge "PageStore: avoid getPageById, since it bypasses caching."jenkins-bot2021-11-231-11/+1
|\ \
| * | PageStore: avoid getPageById, since it bypasses caching.daniel2021-11-221-11/+1
| |/ | | | | | | | | | | | | | | | | | | | | Calling getPageById when the page ID is known was supposed to improve query performance, but since it bypasses LinkCache, it ended up causing a spike in database queries. This optimization can be re-introduced once we also cache PageRecords by ID. Bug: T296063 Change-Id: Ia4ee75b7b5a71d7d858f818d6467793bc642697b
* / Stop accessing members of the Title class publiclyDerick Alangi2021-11-221-43/+56
|/ | | | | | | | | For now, let's just proxy the title object and set the interwiki but to make things nicer, we should not provide a title via setUp(), we should use providers. Bug: T275763 Change-Id: I761de85ae5a839e8a695b85ce0fd7200b498da22
* Title: use PageStore instead of LinkCachedaniel2021-11-021-98/+94
| | | | | | | | | | | | | | | | | | | | | | | This causes Title to no longer look up fields in the database individually, but use LinkCache instead to load an entire row from the page table at once. This patch also causes Title to use in-process caching for some getters that did not use caching before, such as isNewPage() and getTouched(). These methods do not appear to be used on critical code paths that involve database updates. Note that getTouched() used to take an options $db parametr. This appears to be unused, and has been deprecated in favor of a $flags parameter, for consistency with other getters on the class. DEPLOY: Risky! This re-implements the internal caching logic of Title and slightly modifies caching semantics in some cases. This may have unforeseen consequences. Bug: T285389 Depends-On: I103b9e1d2bf594bfc1b0ea12b980dd20bb911c3a Change-Id: I2df81df7186025e001520f24fd498623c7184772
* Merge "Type-hint LinkTarget"jenkins-bot2021-10-251-8/+8
|\
| * Type-hint LinkTargetPetr Pchelko2021-10-211-8/+8
| | | | | | | | | | | | | | | | | | | | These type-hints are definitely correct, but it's still a relatively risky patch cause of how messy Title is. I did some manual review of Title, all tests are passing, but even still if this is approved, I'll add it to phab as a risky deployment. Change-Id: I1ed98ddae30066956e7adbde6780d6bab54dec04
* | Remove hard deprecated Watchlist methods in User, Title, and WatchActionCindy Cicalese2021-10-041-16/+0
| | | | | | | | | | Bug: T292464 Change-Id: Ie9cb3036a69810344971c49c424a76c7fa1cba07
* | Expand local URLs to absolute URLs in ParserOutputPetr Pchelko2021-09-231-16/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New option 'absoluteURLs' was added to getText method of the ParserOutput object that replaces all links in the page HTML with absolute URLs. Removing the action=render special case from Title seems safe cause we will end up replacing the result with absolute URL if we're in a render action no matter where Title::getLocalUrl was called from. This change is safely revertable from the perspective of ParserCache. Bug: T263581 Change-Id: Id660e1026192f40181587199d3418568f0fdb6d3
* | Deprecate WikiPage methods replaced by DeletePageDaimona Eaytoy2021-09-161-0/+1
|/ | | | | | | | | | | Also remove the "@unstable" annotation from DeletePage. Methods without known usages were hard-deprecated, the others soft-deprecated. Bug: T288758 Bug: T288759 Change-Id: I30c62572fd533526779a8ade3ab178f35bebb522
* Merge "Title: Make use of BacklinkCacheFactory service"jenkins-bot2021-09-101-2/+6
|\
| * Title: Make use of BacklinkCacheFactory serviceDerick Alangi2021-09-091-2/+6
| | | | | | | | Change-Id: I48161585de6f329ec4037156234e0b07b3b837e6
* | Merge "title: Avoid calling TitleArray::current on empty iterator"jenkins-bot2021-09-091-4/+1
|\ \
| * | title: Avoid calling TitleArray::current on empty iteratorUmherirrender2021-09-091-4/+1
| |/ | | | | | | | | | | | | Simplify setting of the class property Bug: T290642 Change-Id: I0ed383532876bfbe33e07263202d908cffb39786
* | Merge "PageStore: Use LinkCache"jenkins-bot2021-09-091-5/+3
|\ \
| * | PageStore: Use LinkCachedaniel2021-09-011-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes the data stored by LinkCache compatible with PageStoreRecord, so we can use LinkCache inside PageStore. This causes PageStore to make use of local caching as well as WANObjectCache. Note that getPageById() does not yet benefit from cache, but does populate the cache. Bug: T278940 Change-Id: Icc27a0d9299a3e4ce45521daef87ad06ec06f064
* | | Merge "Title: restore behavior of getCascadeStrictionSources"jenkins-bot2021-09-091-8/+5
|\ \ \ | |_|/ |/| |
| * | Title: restore behavior of getCascadeStrictionSourcesdaniel2021-09-081-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The behavior of getCascadeStrictionSources was changed by Ia73ea587586cb69eb5 to conform to the documented behavior: it would always return false as the first element of the return value if there were no cascading restriction sources, as specified in the documentation. Hopwever, the previous behavior was to return an empty array in that case, unless the $getPages parameter was false. That behavior seems more senible, and there is existing code that relies on it. This patch restores the previous behavior and updates the documentation instead. Bug: T218395 Needed-By: I31ca0a8987f9694bc3b312a48c2c111ceda6fa3e Change-Id: I1f24703b80566220ac6fe8ee500e838ed7fd29af
* | | Title: Deprecate Title::getDefaultNamespace()Derick A2021-09-081-0/+2
|/ / | | | | | | | | | | | | There are no callers of this method anywhere in our codebases. Seems like a relic from past refactoring. But maybe I'm wrong. Change-Id: Id8296ca28518a54d1712bca6b9770b918c92e0c2
* / build: Update mediawiki/mediawiki-phan-config to 0.11.0Umherirrender2021-09-071-0/+1
|/ | | | | | | Addition and remove of suppression needs to be done with the version update. Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
* Merge "New RestrictionStore service"jenkins-bot2021-09-011-405/+86
|\
| * New RestrictionStore serviceAryeh Gregor2021-08-281-405/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows checking restrictions without a dependency on Title, based only on a PageIdentity. Additional fixes along the way: * Correctly return false instead of 'infinity' for getRestrictionExpiry( 'create' ) on an existing page * Correctly handle non-special pages that can't exist (like media pages) in listApplicableRestrictionTypes() (return empty array instead of 'create') * Improve readability of isProtected() The expectation change in TitleTest::testIsProtected() is because the test was formerly broken, since it set mRestrictions without setting mRestrictionsLoaded. (Which illustrates how this approach to testing is essentially broken.) Co-authored-by: Vedmaka <god.vedmaka@gmail.com> Bug: T218395 Change-Id: Ia73ea587586cb69eb53265b2f8f7a296a2573dd0
* | Add typehints to several methodsDaimona Eaytoy2021-08-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | These not only make the code more robust, but also help a lot when writing unit tests: if a method is return-typehinted and its class is mocked, the mock method will automatically return a mock of its declared return type. Otherwise it will return null, and developers are forced to manually mock the method if the return value is used by the SUT in a way that doesn't accept null. Depends-On: I628fcb1807133390c7b9b47984f512f5b1ae58d0 Depends-On: I7080bc505f5838b2f51a368da562104e206063b0 Change-Id: I59068cfed10aabf6c6002f9e9312a6ef6e7e9441
* | Change trivial use of getVal('action') to getRawValTimo Tijhof2021-08-261-3/+3
|/ | | | | | | | | | | | | | | | | | | | | | | Per docs added in I18767cd809f67b, these don't need normalization as they are only compared against predefined strings, and besides are generally entered manually in a form, and even then would not require the kinds of Unicode chars that have multiple/non-normalized forms. In nearby areas to also fix some trivial cases: * getVal('title') obviously needs normalization. Use getText() to make this more obvious. * getVal() compared against simple string literals within the code obviously don't need normalization (e.g. printable === 'no'). * Change hot code in MediaWiki checking for whether 'diff' or 'oldid' are set to getCheck (which uses getRawVal) instead of getVal. As a bonus this means it now handles values like "0" correctly, which could theoretically have caused bad behaviour before. Change-Id: Ied721cfdf59c7ba11d1afa6f4cc59ede1381238e
* Remove dead variables and functions and unneeded parenthesisUmherirrender2021-08-131-21/+0
| | | | | | Found by sonarqube Change-Id: I3464d25e94d98aaca55d9209d5175542b335f994
* Various updates and fixes to PHPDoc documentationThiemo Kreuz2021-08-091-1/+1
| | | | | | | Some minor updates I collected in my local dev environment the past months. Change-Id: I30d5339bc262d54ba76e2860a3a3e9e5f002fdc3
* Don't needlessly reset article IDAryeh Gregor2021-08-021-1/+1
| | | | | | | | | | Title::resetArticleID() clears various caches and is meant for when a page was inserted or moved or similar. I can't see any reason that it needs to be called by Title::castFromPageIdentity. Doing so wastes resources and prevents use of the method in unit tests. It is also surprising for a cast to have side effects. Change-Id: I71c523e7406d493c52199c3a5a9ca7cd414bb5eb
* Hard-deprecate Title::isNamespaceProtectedAryeh Gregor2021-07-291-1/+3
| | | | | | No callers, deprecated in 1.34. Change-Id: If2e1c762f91e3c8255fbb58b7c9f01e8929a7fa2
* Update the todo on Title.phpwikitrent2021-07-221-1/+1
| | | | | | | | Changed format to TODO: so modern IDEs will be able to guide developers to the TODO Change-Id: I40c47d5dfe976752812a986a3284d978b794f144
* build: Updating dependencieslibraryupgrader2021-07-221-5/+5
| | | | | | | | | | | | | | composer: * mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0 The following sniffs now pass and were enabled: * Generic.ControlStructures.InlineControlStructure * MediaWiki.PHPUnit.AssertCount.NotUsed npm: * svgo: 2.3.0 → 2.3.1 * https://npmjs.com/advisories/1754 (CVE-2021-33587) Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
* Title: Avoid accessing class members directly & use accessor methodsDerick A2021-07-121-6/+36
| | | | | | | | | | | | | | First step here is to avoid accessing the Title class members directly. Instead, use their corresponding accessor methods. Affected members are, $mTextform, $mUrlform, $mDbkeyform, $mNamespace, $mInterwiki, and $mFragment. TODO: The next step from here would be to find usage of direct access and replace them with calls to accessor methods while making the members private. Bug: T275763 Change-Id: I9b3efe7a43597f14e19d5db8e824f65aeb169d0b
* Consistently normalize Title::mFragment before settingPetr Pchelko2021-07-011-2/+15
| | | | | Bug: T285951 Change-Id: Ifa04da54da8acdede6258330110d49453a8fffc3
* Fix a bunch of random typosDannyS7122021-06-291-1/+1
| | | | | | | | | | | | | | * yeild -> yield * paramter -> parameter * seperator -> separator * neccesary -> necessary * inital -> initial * intial -> initial * repsonse -> response * retreived -> retrieved Bug: T201491 Change-Id: I461941b027590997448f3bdd8a137a48bb338beb
* Remove some more comments that literally repeat the codeThiemo Kreuz2021-06-181-11/+11
| | | | | | | | | | | | | … including PHPDoc tags like `@return <type> $variableName`. A return value doesn't have a variable name. I can see that some people do this intentionally, repeating the variable name that was used in the final `return $var;` at the end of a method. This can indeed be helpful. I leave a lot of these untouched and removed them only when it's obviously wrong, or does not provide any additional information in addition to what the code already says. Change-Id: Ia18cd9f25ef658b08ad25b97a744897e2a8deffc
* Replace uses of DB_MASTER with DB_PRIMARY in documentation and local variablesJames D. Forrester2021-05-141-3/+3
| | | | | | | This is just a start. Bug: T254646 Change-Id: I9213aad4660e27afe7ff9e5d2e730cbf03911068
* Clean up hard deprecated Title methodsPetr Pchelko2021-05-111-66/+0
| | | | | Depends-On: If27bb6b5142d09bc9293d080e97b6642462219f4 Change-Id: I37f012e53d1c881292a19aac87eb107636c6bfbe
* Title: avoid instance cache pollutiondaniel2021-05-071-5/+27
| | | | | Bug: T281337 Change-Id: I2e8d18b2fc10509097f66287b2543217f4eb9b6a
* Remove remaining non-test uses of Revision objectsDannyS7122021-05-041-40/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following methods no longer support Revision parameters: - CategoryMembershipChange::__construct - ContentHandler::getUndoContent - DerivedPageDataUpdater::prepareUpdate - DifferenceEngine::getRevisionHeader The following methods were removed entirely: - Title::countAuthorsBetween The following methods return arrays that formerly include a 'revision' key that would emit deprecation warnings when accessed and return a Revision object. The Revision object has been removed from the arrays, and the 'revision-record' key should be used to get the relevant RevisionRecord instead: - PageUpdater::doModify - PageUpdater::doCreate - Parser::statelessFetchTemplate The ParserOptions `templateCallback` option is a callback that is called in Parser::fetchTemplateAndTitle() and should return an array - the 'revision' key to that array used to be a Revision object and was used if no 'revision-record' was returned - it is now ignored. Bug: T247143 Change-Id: I163ada88d649c75697aff4fa31a3a3c0bdef78b7
* Merge "Make Title::compare work with Linktarget and Pagereference as well"jenkins-bot2021-05-031-4/+4
|\
| * Make Title::compare work with Linktarget and Pagereference as welldaniel2021-05-031-4/+4
| | | | | | | | Change-Id: I78cca816915f64b84434c5c6d36da49df10e7de0
* | Start removing places using Revision objectsDannyS7122021-04-301-16/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - EditPage::$mBaseRevision - EditPage::getBaseRevision() - Title::getFirstRevision() - LinksUpdate::setRevision() - LinksUpdate::getRevision() - Article::$mRevision - Article::getRevisionFetched() - WikiPage::getOldestRevision() - WikiPage::getRevision() - ContribsPager::tryToCreateValidRevision() To make things easier, instead of rewritting the Revision tests that were using WikiPage::getRevision, just delete them, its not worth the effort to rewrite them since the class is going away. For the WikiPage tests, replace uses of getRevision with getRevisionRecord, manually converting to a Revision object where needed Bug: T247143 Change-Id: I52bc1f49649f8bd25797e3f7a090bec9c63ac2d1
* | Merge "Hard deprecate Title::isWatchable()"jenkins-bot2021-04-301-0/+1
|\ \ | |/ |/|
| * Hard deprecate Title::isWatchable()Cindy Cicalese2021-04-291-0/+1
| | | | | | | | | | | | | | Bug: T281497 Depends-On: I271960cbbbbb5db73aae36414a4c18c14940b6e1 Depends-On: I0f7a82191eae8edd4c0c1d16d89c81e601ae5c80 Change-Id: Ibb83ac71fc2214dcc71f73f009d137a2e5c80d0d
* | Merge "Document methods that may return StubUserLang instead of Language"jenkins-bot2021-04-301-2/+2
|\ \
| * | Document methods that may return StubUserLang instead of LanguageAmmarpad2021-04-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Typehinting parameters that take the return value of these methods with Language is not safe as they may return global $wgLang which may or may not be instance of Language. Bug: T278429 Change-Id: Ia5a71e4c39124f4427bd816e6e19207bb371cc6b
* | | Replace uses of DB_MASTER with DB_PRIMARYJames D. Forrester2021-04-291-7/+7
| |/ |/| | | | | | | | | Just an auto-replace from codesniffer for now. Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
* | Merge "RecentChange: replace Title in method signatures"jenkins-bot2021-04-261-6/+1
|\ \
| * | RecentChange: replace Title in method signaturesdaniel2021-04-261-6/+1
| | | | | | | | | | | | | | | Bug: T278459 Change-Id: I144ea130f29ec437302649d86494034af044c524
* | | Merge "Fix main page tab URLs when using $wgMainPageIsDomainRoot and custom ↵jenkins-bot2021-04-201-5/+5
|\ \ \ | |_|/ |/| | | | | $wgActionPaths"
| * | Fix main page tab URLs when using $wgMainPageIsDomainRoot and custom ↵Porplemontage2021-04-211-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | $wgActionPaths Before this change, all main page tabs with a custom action path go nowhere (href="/") when $wgMainPageIsDomainRoot = true Bug: T270004 Change-Id: I96f2a73cda39c5670ae93dad6396bb8791209c78
* | | Remove Title from method signatures in Userdaniel2021-04-161-2/+4
| |/ |/| | | | | | | Bug: T278459 Change-Id: I78c6a1b57e1b8383905e6650ab16085d28a38769