aboutsummaryrefslogtreecommitdiffstats
path: root/includes/cache
Commit message (Collapse)AuthorAgeFilesLines
* Use type declaration on undocumented private functionsUmherirrender2025-04-021-1/+1
| | | | Change-Id: I0d8d2237500ed6f18439410c902d47c42e4119bc
* GenderCache: Clean up optional/unused constructor paramsBartosz Dziewoński2025-03-101-6/+4
| | | | | | Depends-On: I81df79e5c036392d6c17589935f4420a5e4a387b Depends-On: I208c75db3b1049fa7cdd64a86ea8f08f02a67063 Change-Id: I209ad728f3033c19d6109fcc4a7fa425754f2bbb
* user: Allow gender to be a global preferenceTim Starling2025-03-061-28/+9
| | | | | | | | | | | | | | | | | | | | | | | | GenderCache gets the "gender" user preference directly out of the core database. Thus it does not respect global preferences. So: * Add UserOptionsLookup::getOptionBatchForUserNames(), which gets a single user preference for a set of named users. * Add UserOptionsStore::fetchBatchForUserNames() as a backend. This is a new interface method so is a breaking change. * Have GenderCache call the new interface. The no-database case in ServiceWiring is apparently no longer reachable from the installer due to my previous patch which split MediaWikiTitleCodec. Performance generally degrades from one query to three. For change lists and user page namespace redirects, it shouldn't be a problem, but for the {{GENDER}} parser function there may be a user-visible performance degradation. Bug: T386584 Depends-On: Id02489a597f96cd1cd6db08e16b3624542fdf1f7 Change-Id: I9646b5422afce356e9a1dceeb09d8d4e286dc65e
* Split MediaWikiTitleCodecTim Starling2025-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | For the linked bug, I would really like GenderCache to use UserOptionsManager. But all user-related services need UserNameUtils which depends on TitleParser, and TitleFormatter needs GenderCache to correctly format NS_USER titles. Having TitleFormatter and TitleParser together in a single class creates an intractable dependency loop. So, split MediaWikiTitleCodec. On Daniel's advice I converted the existing TitleParser and TitleFormatter interfaces to classes. The code was always structured to allow this. Extensions require surprisingly few updates. MediaWikiTitleCodec remains only for its deprecated static methods. The implementations were split cleanly with no need for shared code. The tests did have a little bit of shared code, for round-trip testing, so I added a shared test base class for that. Bug: T386584 Depends-On: Ibf307e953b666d8923bc96a507907421558da378 Depends-On: I47e83e95727e6830500e9af7cff92e7d3f91167e Depends-On: Id9c045864a9dc3c640a896e6b34f516c7e42b050 Change-Id: I3dcce6639ed01c7611a663671c872cec775bdaa2
* LinkBatch: Introduce addUser() helperMáté Szabó2025-02-202-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | Why: - After I4f70ff15becbc4991c4f1b0307a14d5354c79dc1, it will become necessary to prefetch the expiration status of temporary accounts when rendering user links via UserLinkRenderer for a large list of users. - We would ideally like to accomplish this without requiring every user of UserLinkRenderer to take a direct dependency on TempUserDetailsLookup, which exposes this functionality. - Since most users of UserLinkRenderer / Linker::userLink() already use LinkBatch to prefetch page existence for the user and user talk pages that UserLinkRenderer will link to, encapsulating the TempUserDetailsLookup interaction within LinkBatch seems like a decent middle ground. What: - Add LinkBatch::addUser(), which takes a UserIdentity and adds its user and user talk pages to the batch while also triggering a batch lookup of expiration status for users added this way when execute() is called. Bug: T358469 Change-Id: Ic837961296cc4bf166dde79c7f073cc50ce925da
* Merge "Broaden LinkTarget to include Wikimedia\Parsoid\Core\LinkTarget"jenkins-bot2025-01-282-2/+2
|\
| * Broaden LinkTarget to include Wikimedia\Parsoid\Core\LinkTargetC. Scott Ananian2025-01-282-2/+2
| | | | | | | | | | | | | | | | The MediaWiki link target is a trivial subclass of the Parsoid version. Use the broader type where possible. Follows-Up: I5c715c5df325fe04860c6da7a0b933dc92f54616 Change-Id: I5b0ec401f23e2a225d4cd6f153ca22772408f967
* | Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-171-2/+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 trivial 1-line PHPDocs that just repeat the codethiemowmde2025-01-161-3/+0
|/ | | | | | | | | | | | | I assume these are all either auto-generated by an IDE or the language-level type declarations have been added later. In any case the comments don't add any new information to what the code already says. This is just extra clutter that makes the code harder to read, I would argue. There are many, many more comments like this. In this patch I intentionally focus on the most trivial 1-line comments. Change-Id: Ia294bf4ce0d8a77036842fe25884bc175c2b0e7d
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-162-6/+6
| | | | | | | | | | | 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
* 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
* Add namespace to remaining parts of Wikimedia\ObjectCacheJames D. Forrester2024-09-273-3/+3
| | | | | Bug: T353458 Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
* Add namespace to IDBAccessObject and DBAccessObjectUtilsJames D. Forrester2024-09-271-1/+1
| | | | | Bug: T353458 Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
* objectcache,profiler,externalstore: Simpler mt_rand() for 1 in N chanceTimo Tijhof2024-09-251-1/+1
| | | | | | | Based on https://gerrit.wikimedia.org/r/1057269, as confirmed by https://3v4l.org/XW30U. Change-Id: I5dc2e140a213bf59f48e39c333280f9662979964
* cache: Add missing documentation to class propertiesUmherirrender2024-09-103-3/+16
| | | | | | | | | | Add doc-typehints to class properties found by the PropertyDocumentation sniff to improve the documentation. Once the sniff is enabled it avoids that new code is missing type declarations. This is focused on documentation and does not change code. Change-Id: I67bb532efff05b7fb01abec540620239cb4031b2
* Move Language and friends into Language namespaceJames D. Forrester2024-08-102-2/+2
| | | | | Bug: T353458 Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
* Merge "BacklinkCache: cleanup, use fullResultCache with limit"jenkins-bot2024-07-194-96/+108
|\
| * BacklinkCache: cleanup, use fullResultCache with limitTim Starling2024-06-284-96/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * In queryLinks(), use the full result cache even if a limit is specified. Truncate the result in the caller if necessary. * Remove the confusing boolean parameter from partitionResult(). Make it always false and fix up the results afterwards. So the batches are always the inclusive start and end IDs, false is never returned. * Inject a logger instead of using wfDebug() * Use private not protected. Defaulting to protected was just a coding style quirk I had at the time. * In queryLinks(), use early return. * In hooks BacklinkCacheGetConditionsHook and BacklinkCacheGetPrefixHook adjust the parameter type hint to avoid the need for a Phan override. Change-Id: Ia53f494633affe48316f0a8b63d03596239ad53c
* | cache: Deprecate UserCache classUmherirrender2024-07-151-0/+1
| | | | | | | | | | | | | | The ActorStore could be used to lookup user names. UserCache is not cross-wiki aware. Change-Id: Ie5456a09bbf8ab0f236157182309cea8bedd9359
* | cache: Deprecate calling `UserCache::singleton()`Derick Alangi2024-07-131-0/+2
| | | | | | | | | | | | | | | | The last callers themselves were already soft deprecated and the singleton on UserCache itself was almost unused. The last usage has been replaced and the method now emits deprecation warnings. Change-Id: Ic9f5e4f427c0402b6c0e7232bcf1d5f9eec6e73e
* | Add namespace to the root classes of ObjectCacheEbrahim Byagowi2024-07-101-1/+1
|/ | | | | | | | | And deprecated aliases for the the no namespaced classes. ReplicatedBagOStuff that already is deprecated isn't moved. Bug: T353458 Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
* Fix use of stale backlink partition cacheTim Starling2024-06-281-30/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a template is created, and then used on a page, and then the template is updated, all within an hour, then the page_touched of the page is never updated and the user will always see the old template contents. This is because htmlCacheUpdate jobs are fully suppressed for one hour following template creation, due to the WAN backlink partition cache. So: * Revert 4f3efbf4065a9, so that htmlCacheUpdate jobs always do something regardless of the state of the partition cache. * Factor out the job queueing parts of WikiPage::onArticleCreate, ::onArticleDelete and ::onArticleEdit. Instead of queueing a job unconditionally, check for the existence of backlinks in a post-send deferred update. If there are none, don't queue the job. * It's convenient to use BacklinkCache::hasLinks(), however, it suffered from the same stale cache problem as BacklinkCache::partition(). It's a short and fast query, and code review shows that none of the callers are particularly performance sensitive. So, do not use the WAN cache in BacklinkCache::hasLinks(). * Since hasLinks() and getNumLinks() no longer share a significant amount of code, separate them. Remove the $max parameter from getNumLinks(), which only existed to support hasLinks() and has no other usages in codesearch. * Log a debug message when entering the post-send request stage, so that it's easier to confirm that no additional pre-send queries are done. * Add a regression test, confirmed to previously fail. Bug: T368006 Change-Id: Id5c7af6d4fcdbeb6724a9036133742c5f76624df
* Use namespaced classes (1)Umherirrender2024-06-163-4/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: Ic4d4dd61de5ab896fb6173eb579c81f164a1e4a3
* User objectCacheFactory methods not deprecated ObjectCache methodsWandji692024-06-061-3/+4
| | | | | Bug: T363770 Change-Id: I2335b315bec6a540409492df4891c518640966d5
* Change some type hints from IDatabase to IReadableDatabaseUmherirrender2024-05-241-4/+4
| | | | | | Use narrow interface if no writes are done Change-Id: I55148c8b6fda8830a29a235c63fc118f636ab3e6
* Remove last uses of DBAccessObjectUtils::getDBOptions()Amir Sarabadani2024-04-301-3/+11
| | | | | | | With this and soon T360517 be done, we can hard-deprecate this method. Bug: T354194 Change-Id: Idad6ae65527fdb15ddd46cc41060726e3132620f
* Stop using LoadBalancer::getConnectionRef() so it can be hard-deprecatedAmir Sarabadani2024-04-301-2/+2
| | | | | Bug: T326274 Change-Id: I90493d7cd4c21fdc022bcc19765fc04d986a9c8f
* Ignore/fix MediaWiki.Commenting.PropertyDocumentation.WrongStyleTaavi Väänänen2024-04-221-1/+1
| | | | | | | | Fix the real issues found by this sniff, and convert the remaining false positive ignores to per-line ignores so that any more real issues won't be added. Change-Id: I18e75d59df327e2d93a3a487c115e92b9f268722
* Standardise all our class alias deprecation comments for ease of greppingJames D. Forrester2024-03-197-7/+7
| | | | Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
* Namespace includes/cacheJames D. Forrester2024-02-208-9/+58
| | | | | Bug: T353458 Change-Id: Ic3f3168ef17113f5fb3ec11e0a47f52d65eefba9
* Namespace includes/contextJames D. Forrester2024-02-083-1/+3
| | | | | Bug: T353458 Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
* Use thousands separators in selected integer literalsTim Starling2023-12-121-1/+1
| | | | | | | | | | For readability. Allowed since PHP 7.4. I searched for integer literals of 6 or more digits, and also changed some nearby smaller numbers for consistency. Bug: T353205 Change-Id: I8518e04889ba8fd52e0f9476a74f8e3e1454b678
* Move user options related classes into its own namespaceMartin Urbanec2023-11-291-1/+1
| | | | | | | | | | | | | There are a couple of user options related classes already, and the T321527 work on dynamic defaults is going to add even more. Let's move them into a separate namespace to make core a bit more organized. Old name is kept as an alias for compatibility purposes. Bug: T321527 Bug: T352284 Change-Id: I9822eb1553870b876d0b8a927e4e86c27d83bd52
* Namespace remaining files under includes/deferredJames D. Forrester2023-11-221-0/+3
| | | | | Bug: T166010 Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
* Replace single-value $db->buildComparison() with $db->expr()Bartosz Dziewoński2023-10-221-2/+2
| | | | | | | | | | Find: ->buildComparison\( ('..?'), \[(\s*)([^\],]+) => ([^\],]+)(\s*)\] \) Replace with: ->expr($2$3, $1, $4$5) Change-Id: I2cfc3070c2a08fc3888ad48a995f7d79198cc336
* cache: Dependency inject more args into BacklinkCacheDerick Alangi2023-10-022-12/+33
| | | | | | Injecting LinksMigration and ServiceOptions into BacklinkCache. Change-Id: I2068cccc472e00bc025de771760d289aaaec2831
* GenderCache: Improve docs and fix outdated commentsTimo Tijhof2023-09-291-48/+37
| | | | | | | | | | | | | | * Follows-up I00813228e177a7a7, which removed the "valid username" check, but getGenderOf() still referred to this check. The fallback in getGenderOf seems fine and cleaner to keep but no longer needs to mention this outdated implementation detail. * Simplify newSelectQueryBuilder call by moving the caller() value and turn it into a single chain. * Document why missLimit isn't a constant. Change-Id: I5791bfdf5b234f266812a478904bf3e7b1dc2313
* Merge "Migrate another major batch to SelectQueryBuilder"jenkins-bot2023-09-201-7/+6
|\
| * Migrate another major batch to SelectQueryBuilderAmir Sarabadani2023-09-201-7/+6
| | | | | | | | | | | | | | | | I fixed some edge cases in the script that migrates to SQB and it managed to fix these now. Bug: T344971 Change-Id: I00cc9a6660d9bd4c64c976121b2121ccd7aae1f0
* | cache: Add support for pagelinks read new in BacklinkCacheAmir Sarabadani2023-09-191-5/+0
|/ | | | | | | That also simplified the code and deduplicated logic a bit. Bug: T346457 Change-Id: I31cc253469f13c6b1a3ef50be74f1a7e6466db79
* Namespace TitleFormatter under \MediaWiki\TitleJames D. Forrester2023-09-193-1/+3
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: Ic2d59eb6764b1a273ed7162ecabf641f638b8f66
* Namespace NamespaceInfo under \MediaWiki\TitleJames D. Forrester2023-09-192-0/+2
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: Ibe103cd362535d3cb94cb8931e95fc74099d1497
* Namespace TitleValue under \MediaWiki\TitleJames D. Forrester2023-09-183-0/+3
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: I4c901d5c32696d8334ec30cede7d9b6f3d8d645e
* Migrate several services to use ICP instead of LBAmir Sarabadani2023-09-162-15/+15
| | | | | | Bug: T330641 Depends-On: I4b8a8ecd2efd0e872dbf6b24762401f95a7654c7 Change-Id: Ic4359b05f7f4fdc2a25a2f11aae33c63a2836bc9
* Reorg: Move WebRequest to includes\RequestAmir Sarabadani2023-09-111-0/+1
| | | | | | | This has been approved as part of RFC T166010 Bug: T321882 Change-Id: I6bbdbbe6ea48cc1f50bc568bb8780fc7c5361a6f
* Migrate several more Database::select calls to SQBAmir Sarabadani2023-08-241-7/+6
| | | | | | | | | These are not too complicated to require their own query builder or playing with hooks but too complicated for the automated script to do it cleanly. Bug: T311866 Change-Id: Ib3ca9cc2a046b03748db0f2eb8bfbb31de641c07
* LinkCache: Drop addGoodLinkObj(), deprecated in 1.37James D. Forrester2023-08-231-33/+0
| | | | Change-Id: I9c426689f0db9658bacc93da1f591e452c51910b
* ResourceLoader: Completely remove FileCacheAmir Sarabadani2023-08-111-125/+0
| | | | | | | | | | | | When I was testing for caching in RL, I realized file cache is completely broken and mostly useless, specially for not taking into account new query parameters and thinking basically all RL modules are uncachable. Let's just remove this. Bug: T330576 Change-Id: I5b17bfc4c5543bd0e96e1099c87341ddf8fd6572
* cache: Remove deprecated methods from BacklinkCacheDerick Alangi2023-08-101-48/+0
| | | | | | | BacklinkCache::get(), ::getLinks(), ::getCascadeProtectedLinks() have been removed from core. No longer used. Change-Id: I84d743719e08c755dc98777ecf6d6d1e92eb2d2b
* Merge "Simplify WHERE conditions with field IS NULL"jenkins-bot2023-07-241-4/+1
|\