aboutsummaryrefslogtreecommitdiffstats
path: root/includes/interwiki
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Fix MediaWiki.Commenting.LicenseComment.InvalidLicenseTag errorsKunal Mehta2018-05-231-1/+1
| | | | Change-Id: I936c3f5fca1a0061f215e80469f5d882cb32ee29
* Replace wfGetLBUmherirrender2018-05-021-1/+1
| | | | | | @deprecated since 1.27 Change-Id: Ibdd49fdfc0d1511503e1ed2173a592c612996c53
* Remove superfluous spaces and semicolons in commentsFomafix2018-02-051-1/+1
| | | | Change-Id: Ib4b452f1843ec250c8c1fcc2a738d80726b6135d
* Remove leading backslashes from "use \…" tagsThiemo Mättig2017-12-281-5/+6
| | | | Change-Id: I494b029de089a07e3b946ee78293a12d5036f63e
* Fix return of Interwiki::invalidateCacheUmherirrender2017-09-101-1/+1
| | | | | | InterwikiLookup::invalidateCache does not expected a return value Change-Id: I5b2ba21ccb42ba9925205eb1645f2152fd51c0a0
* Remove empty lines at begin of function, if, foreach, switchUmherirrender2017-07-011-1/+0
| | | | | | Organize phpcs.xml a bit Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
* Merge "Fix inconsistent spec of InterwikiLookup::getAllPrefixes."jenkins-bot2017-05-043-10/+25
|\
| * Fix inconsistent spec of InterwikiLookup::getAllPrefixes.daniel2017-05-043-10/+25
| | | | | | | | | | | | | | | | | | | | The documented return type was not what existing callers expected, and not what the default implementation actually returned. This patch fixes the interface documentation and the behavior of an alternative implementation. Change-Id: Ib09bffeba3ddc5b43da1c7c299f1fa946be4e2e2
* | Interwiki: Don't override interwiki map orderTimo Tijhof2017-04-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ksort() here was causing the order to be enforced as alphabetical instead of preserving the original order. The order usually doesn't matter, except with regards to handling of duplicates. Due to Parsoid normalising external links to interwiki links, it has to do a reverse lookup. In doing so it has to decide which one to prefer. It currently picks the first match from the API request for meta=siteinfo&siprop=interwikimap, which didn't match the defined order in the actual Interwiki map due to ksort() being called in getAllPrefixes(). Sort in this function was originally introduced in 2010 with commit 844e7c83e4 (2011; r92528; T21838), which is otherwise unrelated and left no rationale. The existing unit tests needed to be adjusted slightly as they assumed alphabetical order. While it appeared they were also defined in alphabetical order, this was merely the order of the variable creation. The effective order is preserved within locals and globals, but overall globals come before locals. Also removed the duplicate test for Hash and CDB in InterwikiTest that belongs in ClassicInterwikiLookupTest instead. Bug: T145337 Change-Id: I7348748801cbdf16c6ceea5b0654fc174b79707e
* | Merge "Move Database and subclasses to Rdbms namespace"jenkins-bot2017-04-121-1/+1
|\ \
| * | Move Database and subclasses to Rdbms namespaceAaron Schulz2017-04-121-1/+1
| | | | | | | | | | | | Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
* | | interwiki: Remove inappropiate use of wfMemcKey()Timo Tijhof2017-04-111-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is used for lookup in a CDB file or PHP static array. In neither case is the key created by wfMemcKey() or any other implementation of BagOStuff::makeKey(). This is already broken if: * An interwiki prefix were to contain characters not supported by Memcached. * An interwiki prefix and wikiid together are too long for Memcached. * If the site has wgCachePrefix configured, which overrides the wfWikiID() namespace makeKey() normally uses. dumpInterwiki.php does not use wfMemcKey() either (and should not). This was simply here as leftover from many rewrites ago, its only purpose is to create wikiid + prefix joined by colon. Ref T148958. Change-Id: I45682133ed593fbb0d66af5a67751f77f15a4a14
* / ClassicInterwikiLookup: Call static function selectFields staticallyReedy2017-04-051-2/+2
|/ | | | Change-Id: I5260ccad99057323d0f3a669a420bbd723363986
* Cleanup some incorrect return annotationsErik Bernhardson2016-12-121-1/+1
| | | | | | | | | | | | | | Most of these are simply changing annotations to reflect reality. If a function can return false to indicate failure the @return should indicate it. Some are fixing preg_match calls, preg match returns 1, 0 or false, but the functions all claim to return booleans. This is far from all the incorrect return types in mediawiki, there are around 250 detected by phan, but have to start somewhere. Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
* Fix case of MediaWikiSite in IWLookupAdapteraddshore2016-11-051-2/+2
| | | | Change-Id: Ice98cb0a3127333c045cfb4328081ad5c490c435
* Fix @since tags of changes that missed the branchaddshore2016-11-051-1/+1
| | | | | | | | | Follows: FormOptions: I29ae63472536f99f7f9546f30d86e7bd324d3094 MediaWikiServices: Ie5fd2c523ceec8cc2656e749928f38909dc4bdf1 InterwikiLookupAdapter: I387dc2ff3f5564fcedde835dec66781d8e9424fd Change-Id: I8d99d0b559d04083fb83b0fcf45cde95dab32d64
* Introduce InterwikiLookupAdapter on top of SiteLookupAmir Sarabadani2016-10-181-0/+175
| | | | | | | This adapter assumes the db name (Interwiki wiki id) equals global ids. Bug: T135146 Change-Id: I387dc2ff3f5564fcedde835dec66781d8e9424fd
* Fix doc typo in InterwikiLookupLeszek Manicki2016-09-081-1/+1
| | | | Change-Id: I2a547a005955cb9f596ff6927feb7df3d5d91872