aboutsummaryrefslogtreecommitdiffstats
path: root/includes/config
Commit message (Collapse)AuthorAgeFilesLines
* Add missing documentation to class properties (miscellaneous classes)Umherirrender2024-09-142-1/+6
| | | | | | | | | | 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: I1da4b272a6b28c419cc8e860d142dae19ca0bbcf
* config: Intentionally throw TypeError for unsupported sourcesDerick Alangi2024-07-241-5/+3
| | | | | | | | | | | | | | | | For config sources that are not supported i.e. not either of the following (Config, ServiceOptions or array), we should fail hard as we don't want to allow anything else apart from those. `array_key_exists()` would throw a TypeError if a source is `null` for example which would be the appropriate behavior here since we don't support that. This was introduced in I06d16b473b256d3f9 (3e495f35c4d0ac6) and a simpler fix to the PSR-12 warning is not to do the `if(..){}` inside an `else`, but use `elseif(..){}` instead. Change-Id: Ib928871b6b4cefb6872484437ecb4c04a9327bad
* Merge "config: Remove unused extractGlobal() and extractVar()"jenkins-bot2024-07-221-48/+0
|\
| * config: Remove unused extractGlobal() and extractVar()Derick Alangi2024-07-221-48/+0
| | | | | | | | | | | | These where hard deprecated since 1.41. It's time to say farewell. Change-Id: I815374fce748cd9760f5760516fd320bfc87e0a6
* | config: Remove unused class property in SiteConfigurationDerick Alangi2024-07-221-6/+0
|/ | | | | | | | | | In cdd6a026f9bd89cfefa0 (Ie94b95feb7fd0885b7c22), I removed the `::getConfig()` method from SiteConfiguration but missed the class property cfgCache that was used by this method. This patch is a quick follow up to remove the unused class property. Change-Id: I923b28cd03d680600f051b50d2719914e2bacd46
* Fix PSR-12 compliance in ServiceOptionsDoğu Abaris2024-07-191-1/+1
| | | | | | - Use 'elseif' construct for PSR-12 compliance Change-Id: I06d16b473b256d3f9c50645ec79d04b9629ea5e7
* Add namespace to the root classes of ObjectCacheEbrahim Byagowi2024-07-101-2/+2
| | | | | | | | | And deprecated aliases for the the no namespaced classes. ReplicatedBagOStuff that already is deprecated isn't moved. Bug: T353458 Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
* Merge "config: Use stale cache instead of hard fail on "no retry" fetch error"jenkins-bot2024-05-211-1/+1
|\
| * config: Use stale cache instead of hard fail on "no retry" fetch errorTimo Tijhof2024-05-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Inspired by investigation for T349376 and T346971, although not currently known to happen in production. If the backend fetch fails with an error and an HTTP status code that tells us not to re-try again in the same process, this shouldn't affect whether or not we use the stale data. Due to this line doing an early return for non-retryable errors, it was bypassing the code below this where is_array results in stale cache being used. Note that $data is only re-assigned from the cache hit in case of a non-error etcd response. The added test fails (expected: from-cache-expired, actual: error) if the EtcdConfig change is not applied. Change-Id: I9b85c206d929706d692bb46efe034be943156031
* | Add namespace and deprecation alias to MultiHttpClientEbrahim Byagowi2024-05-201-1/+1
|/ | | | | | | | | This patch introduces a namespace declaration for the Wikimedia\Http to MultiHttpClient and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: I4ebc1a3b496de08b2b430301da376578d13fcfe6
* docs: Adjust all @deprecated tags to use 'since…' for consistencyJames D. Forrester2024-05-011-1/+1
| | | | | | | | This skips ones that have been marked but were never in the then RELEASE-NOTES and later HISTORY file, and so weren't properly deprecated ever. Change-Id: I31df2d7e83182b5bf9524237fc4a1862356bfd5a
* Drop hard-deprecated ConfigFactory::getDefaultInstance()Taavi Väänänen2024-04-211-12/+0
| | | | | Bug: T325966 Change-Id: I3c3c11946c5aa975358cd3a1cc8289b9be89e694
* Standardise all our class alias deprecation comments for ease of greppingJames D. Forrester2024-03-1910-39/+10
| | | | Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
* config: Drop `SiteConfiguration::getConfig()`Derick Alangi2024-03-181-70/+0
| | | | | | | | This patch deletes the `::getConfig()` method in the SiteConfiguration class. It's no longer used and due for removal. Bug: T289543 Change-Id: Ie94b95feb7fd0885b7c224533868e654453071cd
* Deprecate never-used ConfigRepository serviceDerick Alangi2024-01-241-0/+1
| | | | | | | Looks like this class and its corresponding services have been used since inception. Let's get rid of it. Change-Id: If427fb705bb86f019d24b6073f44af811dc1f13f
* config: replace unused Logger in EtcdConfig with native trigger_errorTimo Tijhof2023-09-261-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Introduced in 9b459d29e0 (I60914d31c2, T156924) and later extended in cde44feba3 (Ic5bdcb0cae). There is no details about the fatal error in Logstash, because EtcdConfig is by design a standalone class for use prior to any service wiring, site configuration, or logger Spi can be used. That's why EtcdConfig::setLogger() is unused and thus even the "error" level messages go nowhere (NullLogger). Rewrite these messages to instead surface via the native PHP error log, the same way that our first-party and third-party standalone libraries do, and as we do with deprecation warnings already. Given that there isn't a way to inject this into MultiHttpClient, we lose that visibility. However, not really because again setLogger was never called in practice. And, the only error message MultiHttpClient logs is the HTTP request failure, which is already returned by $this->http->run() as $rerr to EtcdConfig and logged by this patch. Bug: T346971 Change-Id: I227ead395513877da88dd8b8abbd5ba7be25d5c7
* Namespace Config-related classes under \MediaWiki\ConfigJames D. Forrester2023-09-2113-7/+86
| | | | | Bug: T166010 Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
* Reorg: Move SiteConfiguration to includes/config/Amir Sarabadani2023-09-111-0/+698
| | | | | | | | | | And namespace it to MediaWiki\Config This should be eventually deprecated and removed but this has been blocking the reorg for long enough. Bug: T321882 Change-Id: I7a1a073495469623f6f77e6f74b23b7b4c18033a
* ConfigFactory: Hard-deprecate getDefaultInstance()James D. Forrester2023-08-191-0/+2
| | | | Change-Id: I42d30ddcb9ce9a51f9d7a56bc19f0094dca85d5b
* config: Remove unused ConfigRepository::getValueOf() methodDerick Alangi2023-08-081-24/+9
| | | | | | | Introduced in I9419508eaa85ffc55520db7f33b3e9530fc99f00 but was never used anywhere. Change-Id: I4d5c059679313c37dd03eff8a77d6f77fbb7e33a
* config: Remove not needed indirection from GlobalVarConfigthiemowmde2023-07-171-26/+4
| | | | | | | | | | | | While this is not a bottleneck it can still be relevant for the total performance of the system. The function call overhead in PHP is surprisingly large and this code is called a lot, typically millions of times. These methods are never used anywhere for anything: https://codesearch.wmcloud.org/search/?q=%28has%7Cget%29WithPrefix&files=%5C.php%24 Change-Id: Ie6cb6cb333b1d2a89486494bd70bf32e8ca97fca
* Move array destructuring into foreachUmherirrender2023-07-081-3/+1
| | | | Change-Id: I54c98085b21f1fe48ccf575d1b9dd60d3b855c58
* 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
* GlobalVarConfig: Avoid slowness of array_key_exists on $GLOBALS in PHP 8.1+James D. Forrester2022-09-161-1/+5
| | | | | | | | Also make the same change for GlobalConfigBuilder for consistency, though that's not critical path. Bug: T317951 Change-Id: I9b46e7bc25365d01dbc86a9b2288559cb9e2cb8d
* [php8] Don't use strlen on potentially null stringBrian Wolff2022-07-241-1/+1
| | | | | | | Was causing test suite to fail in php8.1 Bug: T313663 Change-Id: I26635db7be47cf62ba5670399ee9cee13da4e5c2
* Use HashConfig to override config variables in phpunit testsdaniel2022-07-071-0/+8
| | | | | | | | | | | | | This implements config overrides with a HashConfig that is layered on top of the base config, so we can move away from global variables. Global variables are still updated using setMwGlobals, for compatibility with code that is still reading configuration from global variables. This fixes an issue with the default overrides not being applied to global variables. Change-Id: I1922d9b903dcafb83691c2d96790f72747eeef9c
* phan: Disable null_casts_as_any_type settingUmherirrender2022-03-211-3/+2
| | | | | | | | | | | Make phan stricter about null types by setting null_casts_as_any_type to false (the default in mediawiki-phan-config) Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T242536 Bug: T301991 Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
* Merge "Use updated ObjectFactory namespace"jenkins-bot2022-03-121-1/+1
|\
| * Use updated ObjectFactory namespaceAlexander Vorwerk2022-03-091-1/+1
| | | | | | | | | | | | | | Depends-On: I99c5e5664d2401c36a9890f148eba7c25e6e8324 Depends-On: I48ab818b2965da14af15ef370aa83ad9455badd9 Depends-On: I018371e4b77911e56152ca7b2df734afc73f58a5 Change-Id: I04ebdb52102f6191d49a9cc70b1f98308299e72f
* | EtcdConfig: Remove YAML from available 'encoding' optionsTimo Tijhof2022-03-111-11/+4
|/ | | | | | | | | | | | | | This appears impossible to use because the request is always made with `Content-Type: application/json`. * It seems unreasonable for an Etcd server to not support JSON. * It seems unreasonable for an Etcd server to respond with YAML to a JSON request. * It seems unlikely that anyone would prefer YAML over JSON for the automated encoding and decoding of fully automated inter-service communication. Change-Id: I290e03e17d547c3dc675820bb024c940e02e097a
* Merge "Simplify DnsSrvDiscoverer interface"jenkins-bot2022-02-171-20/+49
|\
| * Simplify DnsSrvDiscoverer interfaceDan Duvall2022-02-161-20/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor DnsSrvDiscoverer constructor to accept service, protocol, and domain as discrete arguments to better match the specifications outlined in RFC 2782 and make clearer the concerns and contract between the discoverer and the caller. The latter should not need to know about discovery details but only the service to be discovered and the scope of that discovery (the domain). Domain is now optional where an omitted value results in discovery relative to the host's configured search domain, supporting installations where full DNS based discovery is desired over explicit configuration. This makes the simplest use case: $servers = ( new DnsSrvDiscoverer( 'service' ) )->getServers(); Overall use of the interface is simplified by changing `getServers()` to unconditionally sort results by priority according to RFC 2872 and return a simplified result of host/port tuples (the only data relevant in primary discovery use cases). This makes the handling of discovery fallback simpler since the caller can construct a default without having to populate all response record details. Example $dsd = new DnsSrvDiscoverer( $service, $proto, $host ); $servers = $dsd->getServers() ?: [ [ $host, $defaultPort ] ]; A `getRecords()` method is provided as public to allow a caller to obtain details on the response (and do its own sorting) should that be needed. Added an optional `$resolver` argument to the constructor (which defaults to `dns_get_record`) to make the class implementation more testable, and wrote functional tests. EtcdConfig has been refactored to reflect the new usage of DnsSrvDiscoverer and now sets the discoverer as a property in the constructor to allow for mocking in tests. Implemented tests for etcd DNS SRV discovery within EtcdConfig. Bug: T296771 Change-Id: Idbd60049853439f96ff6045e01aa03014b4e587f
* | Introduce IterableConfigdaniel2022-02-142-1/+73
|/ | | | | Bug: T301544 Change-Id: I0a93ebb5305f95cf1b12df276f25a44195fedafa
* Refactor global variables to use MediaWikiServices insteadTChin2022-01-101-1/+3
| | | | | | | | | | | | Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI. Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228 * This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it. A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
* Introduce includes/Storage/PageUpdaterFactorydaniel2021-07-191-1/+6
| | | | Change-Id: I2a060bfa8ac098edf24fc4d51212eeb7ddf3942d
* Remove unused default values from class propertiesThiemo Kreuz2021-05-121-1/+1
| | | | | | | | In all these cases the property is unconditionally set in the constructor. The extra initialisation is effectively dead code and an extra source of errors and confusion. Change-Id: Icae13390d5ca5c14e2754f3be4eb956dd7f54ac4
* build: Enable phan-taint-check-plugin and suppress issuesUmherirrender2020-12-301-0/+3
| | | | | | | | | | | | | | | | | | Taint check checks for possible security issues by tracking html escaping and more by using phan. This slows done the phan-job a bit and requires more ram Keep the DoubleEscaped issues out to make reviewer easier Adds suppression for false positives Adds taint-annotation to help taint-check Removes suppression for code phan now understand better by the tracking of keys in taint-check Fix some small issues by adding int cast or htmlspecialchars calls Bug: T216348 Bug: T268920 Change-Id: I849ac4f120fd15b483e8939d4db45c98dc351259
* Mark ServiceOptions as @newableDannyS7122020-10-091-0/+4
| | | | | | Widely used in extensions Change-Id: Ib0bddcadf604cda3304e2ee7dd3408219d51e877
* Merge "Replace "@stable for implementation" with "@stable to implement""jenkins-bot2020-07-132-2/+2
|\
| * Replace "@stable for implementation" with "@stable to implement"daniel2020-07-132-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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
* | Replace "@stable for calling" by "@stable to call"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: If560596f5e1e0a3da91afc36e656e7c27f040968
* Mark exceptions as @newabledaniel2020-07-082-0/+4
| | | | | | | | Exceptions classes are nearly always value objects, and should in most cases by newable. Bug: T247862 Change-Id: I4faa8ec6ea8bc44086cfc8075b32d10eea61e9df
* Stability annotations for interfaces.daniel2020-07-072-0/+4
| | | | | | | | | Per the Stable Interface Policy, PHP interfaces should not be directly implemented by extensions, unless they are marked to be safe for that purpose. Bug: T247862 Change-Id: Idd5783b70fc00c03d57f5b1a887f0e47c4d7b146
* Annotate newable classesdaniel2020-07-071-0/+6
| | | | | | | | This annotates classes that can safely be instantiated by extensions, per the Stable Interface Policy. Bug: T247862 Change-Id: Ia280f559874fc0750265ddeb7f831e65fd7d7d6a
* Use namespaced IPUtils classKunal Mehta2020-01-011-1/+2
| | | | Change-Id: I047e099a93203a59093946d336a143d899d0271f
* Fix new phan errors, part 5Daimona Eaytoy2019-10-181-0/+1
| | | | | | | | | | | | | Some of the errors are suppressed because they're phan false positives. The idea behind this is that they'll be fixed in a future version of phan, and we'll just have to remove the suppressions. Note: I'm disabling UnusedPluginSuppression so that we can start suppressing issues even if they're still disabled. The sniff should be re-enabled as soon as we upgrade phan. Bug: T231636 Change-Id: I0f7fa06a9e03fbb86c7a5eb6e50a850bb258a7f7
* Services: Convert PermissionManager's static to a const now HHVM is goneJames D. Forrester2019-10-081-6/+6
| | | | Change-Id: Ib75b6f5d6b3e793ddbce42951693d8c99e6b7e57
* Better docs to make phan happyDaimona Eaytoy2019-09-072-1/+4
| | | | Change-Id: I8a9a6330cf1f889cbb77dfc28c93774204767323
* Upgrade phan config to 0.7.1Daimona Eaytoy2019-09-041-0/+1
| | | | | | | | This allows us to remove many suppressions for phan false positives. Bug: T231636 Depends-On: I82a279e1f7b0fdefd3bb712e46c7d0665429d065 Change-Id: I5c251e9584a1ae9fb1577afcafb5001e0dcd41c7
* config: Change ConfigException to extend LogicExceptionGergő Tisza2019-07-011-1/+1
| | | | | | | | | | | | | | This exception is thrown when someone tries to fetch a configuration entry with an invalid name, or override an already set entry, both of which are errors in the logic and cannot be meaningfully handled, so it does not make sense for this exception to trigger IDE warnings. (The one exception is the etcd load error, which probably shouldn't be a ConfigException in the first place. But even that is not something callers could meaningfully handle.) Change-Id: I26b5b32f3348965f0cbf607cbb7cb5aaa509ed51