aboutsummaryrefslogtreecommitdiffstats
path: root/includes/interwiki
Commit message (Collapse)AuthorAgeFilesLines
* Merge Interwiki extension into coreDringsim2024-12-051-26/+53
| | | | | | | | | | | | | | | | | | | | | | | Merge Interwiki extension into core, with some changes: * Always register 'interwiki' user right and 'interwiki' log type, and remove $wgInterwikiViewOnly * Remove nonstandard 'intro' and 'body' CSS classes on Special:Interwiki * Make interlanguage special cases be conditional on $wgInterwikiMagic * Other cleanups * Add SpecialInterwikiTest * Add a constant MW_HAS_SPECIAL_INTERWIKI which can be used in config to suppress loading of the extension. After merging Interwiki extension into core we can remove InterwikiLoadPrefix hook, which is incompatible with Parsoid. Bug: T33951 Bug: T270444 Bug: T312425 Bug: T315759 Bug: T357247 Depends-On: I0d02d93f49c746a7ce86b72b456f13c4af9b6c34 Change-Id: I05049e7c2e056928977245367583d027b80ef613
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-161-1/+1
| | | | | | | | | | | 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/+0
| | | | | | | | | 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
* interwiki: Document order significance in InterwikiLookup return valueC. Scott Ananian2024-10-081-0/+7
| | | | | | | | Probably not the /only/ place this should be documented, but putting it somewhere is a start. Bug: T370691 Change-Id: Ia75709d3f1a6e37bf807ad549e3621e08d5cbe1b
* Add namespace to remaining parts of Wikimedia\ObjectCacheJames D. Forrester2024-09-271-1/+1
| | | | | Bug: T353458 Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
* Move Language and friends into Language namespaceJames D. Forrester2024-08-101-1/+1
| | | | | Bug: T353458 Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
* tests: Avoid usage of deprecated `setContentLang()`Derick Alangi2024-07-191-2/+2
| | | | | | | This patch uses the new style to override config: overrideConfigValue(). It also updates some minor typos in the Interwiki.php class. Change-Id: I74f7f47a31789e79d6f045a542d14db662bd1754
* Namespace remaining files in includes/siteJames D. Forrester2023-12-141-2/+2
| | | | | Bug: T353458 Change-Id: I38da09f28cd68add721ba7b05f351acb56515d95
* Namespace Site and SiteListAmir Sarabadani2023-12-141-1/+1
| | | | | Bug: T353458 Change-Id: I31f7cba42c02701e462eb3ed6bcc3928d438c1ef
* interwiki: Switch ClassicInterwikiLookup to use ICPAmir Sarabadani2023-08-241-8/+8
| | | | | Bug: T330641 Change-Id: Ibb1381b75bdc12d469ca04ec33ca552a69655a34
* Migrate more calls of Database::select* to SelectQueryBuilderAmir Sarabadani2023-07-261-10/+11
| | | | | | | | | Using a php parser written on top of ANTLR4, done semi-automatically. I checked everything and made adjustments. Bug: T311866 Change-Id: I6150c6909bce8f3dbd745a26380cc0af9d9c547f
* interwiki: Hard deprecate InterwikiLoadPrefix hookDerick Alangi2023-07-101-1/+1
| | | | | | | This hook interface was soft deprecated in 3d40c43b1f27 and is no longer used anywhere. Let's hard deprecate it. Change-Id: Ic15978f0d798c6b7e0dcd616ad876ffddd1446ea
* Fix even more PHPStorm inspections (#3)Tim Starling2023-03-251-1/+1
| | | | | | | | | | | | | | | * Inappropriate @inheritDoc usage. Arguably all @inheritDoc is inappropriate but these are the ones PHPStorm flags as misleading due to the method not being inherited. * Doc comment type does not match actual argument/return type. * I replaced "@return void|never" with "@return void" since never means never, it doesn't make sense for it to be conditional. If a method can return (even if that is unlikely) then @return contains the type that it returns. "@return never" means that there is no such type because the method never returns. * Incomplete/partial/broken doc tags Change-Id: Ide86bd6d2b44387f37d234c2b059d6fbc42ec962
* Reorg: Migrate WikiMap to WikiMap/ out of includesAmir Sarabadani2023-02-271-1/+1
| | | | | | | And WikiReference Bug: T321882 Change-Id: I60cf4b9ef02b9d58118caa39172677ddfe03d787
* interwiki: Inject wikiId into ClassicInterwikiLookupDerick Alangi2023-01-271-27/+37
| | | | Change-Id: I16594bbeeaa4ddab61e6a5b1fdb4b75b24b9491a
* Use short array destructuring instead of list()Tim Starling2022-10-211-2/+2
| | | | | | | | Introduced in PHP 7.1. Because it's shorter and looks nice. I used regex replacement. Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
* interwiki: Overall clean up and simplificationTimo Tijhof2022-09-292-179/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove inline `false` fallback in fetch(). load() does this already and can't return other falsey values like null. * Remove use of Database::getCacheSetOptions as this data is generally not mutable. * Remove foreach-wiki logic from clearInterwikiCache.php. Usually to make scripts apply cross-wiki they are iterated externally via something like foreachwiki (as WMF does) and by using the `--wiki` parameter that core supports. Iterating in-process is somewhat fragile and depended on various hardcoding and assumptions, including e.g. BagOStuff::makeKey() and how ClassicInterwikiLookup calls this. Also fix clearInterwikiCache.php to actually work on simple wikis. Previously it did nothing locally as $wgLocalDatabases is empty. * Remove non-confident code from loadFromArray() for tolerating absence of iw_url. Move the isset() check to the one place that needs it, namely the hook handler in load(), and document what it is for. * Simplify load() usage by inlining and moving fetchPregenerated() responsibility there. * Simplify load() by merging the aborted and non-aborted hook cases, and document the reasons explicitly. * Move use of WikiMap::getCurrentWikiId() to the constructor with TODO for proper injection. * Rename a bunch of variables and apply more consistent terminology within interwiki-related source code. In particular, it was confusing that the variable 'objectCache' in fact did not cache the objects, which are cached in 'localCache' instead. Use the common naming found in other MW components instead ("wanCache" and "instances"). Bug: T315315 Change-Id: If3429b0604974efd4ff5914660979d3e49266848
* interwiki: Remove outdated CDB referencesTimo Tijhof2022-09-235-54/+41
| | | | | | | | | | | | | | * CDB stands for "constant database" file, hence also changes references to "constant" when likely intended to refer to CDB. * Remove reference to non-existent docs/Configuration.md. * Remove unused resetLocalCache() method. This was documented as internal for testing only, but tests did not use it. It was left behind in 2016 with I7d7424345d0ce3ce90 (025f15a208). Bug: T315315 Change-Id: I61d9689160d9bf5715c4ff18009fbd16236d34e6
* Merge "interwiki: Adjust documentation for InterwikiLookup::getAllPrefixes"jenkins-bot2022-03-093-8/+4
|\
| * interwiki: Adjust documentation for InterwikiLookup::getAllPrefixesUmherirrender2022-02-243-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use bool instead of string, most caller provided int instead. The InterwikiLookupAdapter class is strict comparing Interwiki::isLocal (a bool) with the given $local value, which evaluates always to false and the expected filter option is not working. The unit tests is using bool, not the documented string. The ClassicInterwikiLookup is not affected. Found by phan strict checks Change-Id: I63ed9772429c6f5bfe38a9fad190491812866f3f
* | Avoid references to DefaultSettings.daniel2022-02-221-2/+2
|/ | | | | | | | | | | | | | This replaces references to DefaultSettings with references to config-schema.yaml where appropriate. NOTE: this does not yet change Setup.php. DefaultSettings.php remains intact and is still being used. NOTE: this does not remove usages in the installer, see I5d8843a1062fbf for that. Bug: T300129 Change-Id: Ie6152cf510c3be61bc22167ca6d90dfc28910a45
* Optimise Skin::getLanguages()Tim Starling2022-02-081-111/+69
| | | | | | | | | | | | | | | | | | | | Skin::getLanguages() was consuming 4% of index.php CPU time. In local testing, it was called three times per page view. So: * Memoize it, analogous to the nonfunctional code in SkinVector. * Simplify ClassicInterwikiLookup by removing the option to pass a CDB file path. This was only ever supported by a WikimediaMaintenance script. In the unlikely event that someone is using this feature, they have the same motivation to switch to PHP as we did in T122362. * Increase the size of ClassicInterwikiLookup's MapCacheLRU from 100 to 1000. This helps greatly in the case when $wgInterwikiCache is false and more than 100 interwikis are requested and seems harmless otherwise. * Optimise Title::getNsText() by assuming that the canonical name of NS_MAIN is the empty string. * Rearrange Message::__construct() to avoid duplicate type checks. Change-Id: I736cb74efc267fd2473a3267471735238217251c
* Use getWithSetCallback() instead of get() + set()Daimona Eaytoy2021-11-181-14/+13
| | | | | | | This allows the backend to do whatever it can to ensure atomicity, and is also easier to read, since the intent is obvious. Change-Id: Ibbfecd92a2c6d9a5997ca37ea101e068bd1e8202
* Use @deprecated annotation on hook interfaces, not functionsUmherirrender2021-05-171-2/+2
| | | | | | | | Use only one place to document the deprecation of hook interfaces/functions Bug: T282903 Change-Id: Ie7d2d7a50afe2897e5c2369f473a33ecaa821637
* Update Legoktm's email addressKunal Mehta2021-05-021-1/+1
| | | | Change-Id: Icd58c93bb0cff5b0a4e7b7f02873a271bab8964f
* ClassicInterwikiLookup: inject load balancerDannyS7122021-04-221-2/+9
| | | | | | Per todo comments, to avoid using wfGetDB Change-Id: Ic4a7f9c5bcbfef3042e5ec0606babbd14d3e6124
* Deprecate InterwikiLoadPrefix hookC. Scott Ananian2020-12-212-0/+38
| | | | | | | | | | | | | | | The InterwikiLoadPrefix hook isn't compatible with Parsoid, as it is unidirectional and doesn't support enumerating all valid prefixes (T270444). Set/reset $wgInterwikiCache to mock the interwiki table for parserTests and other unit tests instead. This is a soft deprecation, as the used-in-production Extension:Interwiki still uses InterwikiLoadPrefix, although not in a way that would break Parsoid (since $wgInterwikiCache is set in production). Bug: T270444 Change-Id: If2507017c99c4ee42c104a0890bc45a84d7239d5
* ClassicInterwikiLookup: Fix typo in commentC. Scott Ananian2020-12-181-1/+1
| | | | Change-Id: I24bf99554f6005bc37d2c5aa4dc0fd18c1585388
* InterwikiLookupAdapter: Move code out of loop that doesn't vary based on ↵Reedy2020-12-061-7/+8
| | | | | | loop variable Change-Id: If090a4603a22166b0e907ba2163f3bf68ae1e3a3
* Document hook names in hook interfaces.daniel2020-09-271-0/+3
| | | | | Bug: T258665 Change-Id: Ifddbf57f8aa2e3eb0d5845601376cbafa08ed407
* Replace "@stable for implementation" with "@stable to implement"daniel2020-07-131-1/+1
| | | | | | | | | | | For compliance with the new version of the table interface policy (T255803). This patch was created by an automated search & replace operation on the includes/ directory. Bug: T257789 Change-Id: I17e5e92e24c708ffc846945a136347670a3a20c7
* Remove terminating line breaks from debug messagesTim Starling2020-06-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | A terminating line break has not been required in wfDebug() since 2014, however no migration was done. Some of these line breaks found their way into LoggerInterface::debug() calls, where they mess up the formatting of the debug log. So, remove terminating line breaks from wfDebug() and LoggerInterface::debug() calls. Also: * Fix the stripping of leading line breaks from the log header emitted by Setup.php. This feature, accidentally broken in 2014, allows requests to be distinguished in the log file. * Avoid using the global variable $self. * Move the logging of the client IP back to Setup.php. It was moved to WebRequest in the hopes that it would not always be needed, however $wgRequest->getIP() is now called unconditionally a few lines up in Setup.php. This means that it is put in its proper place after the "start request" message. * Wrap the log header code in a closure so that variables like $name do not leak into global scope. * In Linker.php, remove a few instances of an unnecessary second parameter to wfDebug(). Change-Id: I96651d3044a95b9d210b51cb8368edc76bebbb9e
* Hooks::run() call site migrationTim Starling2020-05-301-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate all callers of Hooks::run() to use the new HookContainer/HookRunner system. General principles: * Use DI if it is already used. We're not changing the way state is managed in this patch. * HookContainer is always injected, not HookRunner. HookContainer is a service, it's a more generic interface, it is the only thing that provides isRegistered() which is needed in some cases, and a HookRunner can be efficiently constructed from it (confirmed by benchmark). Because HookContainer is needed for object construction, it is also needed by all factories. * "Ask your friendly local base class". Big hierarchies like SpecialPage and ApiBase have getHookContainer() and getHookRunner() methods in the base class, and classes that extend that base class are not expected to know or care where the base class gets its HookContainer from. * ProtectedHookAccessorTrait provides protected getHookContainer() and getHookRunner() methods, getting them from the global service container. The point of this is to ease migration to DI by ensuring that call sites ask their local friendly base class rather than getting a HookRunner from the service container directly. * Private $this->hookRunner. In some smaller classes where accessor methods did not seem warranted, there is a private HookRunner property which is accessed directly. Very rarely (two cases), there is a protected property, for consistency with code that conventionally assumes protected=private, but in cases where the class might actually be overridden, a protected accessor is preferred over a protected property. * The last resort: Hooks::runner(). Mostly for static, file-scope and global code. In a few cases it was used for objects with broken construction schemes, out of horror or laziness. Constructors with new required arguments: * AuthManager * BadFileLookup * BlockManager * ClassicInterwikiLookup * ContentHandlerFactory * ContentSecurityPolicy * DefaultOptionsManager * DerivedPageDataUpdater * FullSearchResultWidget * HtmlCacheUpdater * LanguageFactory * LanguageNameUtils * LinkRenderer * LinkRendererFactory * LocalisationCache * MagicWordFactory * MessageCache * NamespaceInfo * PageEditStash * PageHandlerFactory * PageUpdater * ParserFactory * PermissionManager * RevisionStore * RevisionStoreFactory * SearchEngineConfig * SearchEngineFactory * SearchFormWidget * SearchNearMatcher * SessionBackend * SpecialPageFactory * UserNameUtils * UserOptionsManager * WatchedItemQueryService * WatchedItemStore Constructors with new optional arguments: * DefaultPreferencesFactory * Language * LinkHolderArray * MovePage * Parser * ParserCache * PasswordReset * Router setHookContainer() now required after construction: * AuthenticationProvider * ResourceLoaderModule * SearchEngine Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
* docs: Hook interface doc comment reviewapaskulin2020-04-211-6/+6
| | | | | | | | Edited doc comments for hook interfaces to improve consistency and add type hints. Bug: T246855 Change-Id: I38fa802463cd6f39bf5946dbbeb1b3ebaea604b2
* Automatically generated hook interfacesTim Starling2020-04-201-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add hook interfaces which were generated by a script which parses hooks.txt and identifies caller namespaces and directories. Hook interfaces are mostly placed in a Hook/ subdirectory relative to the caller location. When there are callers in multiple directories, a "primary" caller was manually selected. The exceptions to this are: * The source root, maintenance and tests, which use includes/Hook. Test hooks need to be autoloadable in a non-test request so that implementing test interfaces in a generic handler will not fail. * resources uses includes/resourceloader/Hook * The following third-level subdirectories had their hooks placed in the parent ../Hook: * includes/filerepo/file * includes/search/searchwidgets * includes/specials/forms * includes/specials/helpers * includes/specials/pagers Parameters marked as legacy references in hooks.txt are passed by value in the interfaces. Bug: T240307 Change-Id: I6efe2e7dd1f0c6a3d0f4d100a4c34e41f8428720
* Remove deprecated methods in the Interwiki classDaimona Eaytoy2020-03-091-52/+0
| | | | | | codesearch lists 0 usages: https://codesearch.wmflabs.org/deployed/?q=%3A%3A(isValidInterwiki%7Cfetch%7CinvalidateCache%7CgetAllPrefixes)%5C(&i=nope&files=&repos= Change-Id: Ieea4ee724197d949db31c0430a8460ee273f9aba
* WikiMap: Add WikiMap::getCurrentWikiId() to make common use case easierTimo Tijhof2020-03-031-2/+2
| | | | Change-Id: Ie225ebfc37c824e3167742137bbbc9f64aca5f5e
* Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUseJames D. Forrester2020-01-102-2/+2
| | | | Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
* Set method visibility for various constructorsUmherirrender2019-12-032-2/+2
| | | | Change-Id: Id3c88257e866923b06e878ccdeddded7f08f2c98
* Fix new phan errors, part 6Daimona Eaytoy2019-10-201-0/+1
| | | | | Bug: T231636 Change-Id: I1870b6cbeb31e54fde5e675fec51446b330e06c5
* Add missing newline between <?php and namespace/use sectionThiemo Kreuz2019-06-032-0/+2
| | | | | | The rest of the codebase is using this code formatting standard. Change-Id: I4d2ba61757a7e28d40096d9dc5915005c340d4f2
* Clean up some database domain ID related code and fix some commentsAaron Schulz2019-03-291-1/+1
| | | | Change-Id: Id5c5640e05301161dbb7c2be363e32d7d1c9a511
* Rename WikiMap DB domain ID methods to reduce confusion with web domainsAaron Schulz2019-02-061-2/+2
| | | | | | Those added in this same release do not need alias methods. Change-Id: I05feeb9b0b13afe43aea1f95551965489cdbe094
* Use WikiMap methods in ClassicInterwikiLookup instead of wfWikiId()Aaron Schulz2018-10-291-4/+11
| | | | Change-Id: Ia3d843c79fa31fec59a04b92f4619458ae06de62
* Fix caller name in ClassicInterwikiLookup::loadUmherirrender2018-09-301-2/+3
| | | | | | | Seeing MediaWiki\Interwiki\{closure} in the logs as caller is not helpful Change-Id: I39af68a02d40667e428c7f30c88aacab8a02cd86
* Mass conversion of $wgContLang to serviceAryeh Gregor2018-08-111-5/+5
| | | | | | | Brought to you by vim macros. Bug: T200246 Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
* Fix PhanTypeMismatchDeclaredParamUmherirrender2018-07-071-1/+1
| | | | | | Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
* Hard deprecate Interwiki static methodsKunal Mehta2018-06-071-0/+4
| | | | Change-Id: I803df3ef90bf6b602e85ae48f25745f4dc6aab3a
* installer: Fix display of UPGRADE by disabling InterwikiLookupKunal Mehta2018-06-071-0/+57
| | | | | | | | | | | | | | Since 129067c907ea65f62, parsing section titles has looked up interwiki prefixes with InterwikiLookup. In the web upgrader, this triggers database access, and since that service is disabled, it throws exceptions, causing parsing to fail. Work around that by using a dummy InterwikiLookup service that knows about no interwiki prefixes. Maybe one could be written to just read from the stock `interwiki.list`, but that's a project for another time. Bug: T196607 Change-Id: I13485a9af79297b552a1128240cb8597c2ef83d8
* Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenientBartosz Dziewoński2018-05-301-4/+4
| | | | | | | | | | | | | | Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/ Replace with: '\1 ?? ' (Everywhere except includes/PHPVersionCheck.php) (Then, manually fix some line length and indentation issues) Then manually reviewed the replacements for cases where confusing operator precedence would result in incorrect results (fixing those in I478db046a1cc162c6767003ce45c9b56270f3372). Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf