| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Change-Id: I0d8d2237500ed6f18439410c902d47c42e4119bc
|
|
|
|
|
|
|
|
| |
Use modern php syntax to call a callable.
Reduce the stack trace to improve performance
and better IDE and static analyzer support
Change-Id: I9ef131032a662a3b8db69aa7079dbd51f88f575a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch does two things:
1. Be forgiving about associative arrays with numeric keys. This
is because lists can unintentially become associative arrays (as
a result of side effect) and discarding the keys is not a problem.
2. Correct the spurious error message for truly associative arrays
with non-numeric string keys.
Bug: T322131
Change-Id: I870218023093305a8f414d4de1a73282b5f53b9a
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
Provided arguments already have type declaration on the construtor
and it is safe to use the same type on the class property
Change-Id: Ia8bbdc4dee59dfb487582dd514486ec8542951be
|
|
|
|
|
| |
Bug: T353458
Change-Id: Ifa3b6a6e0353bb4ce21a3f4456f1fc696c8d377c
|
|
|
|
|
|
|
|
|
| |
And deprecated aliases for the the no namespaced classes.
ReplicatedBagOStuff that already is deprecated isn't moved.
Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In PHP 8, but not in PHP 7.4, every class with a __toString() function
implicitly implements the Stringable interface. Therefore, the
behavior of checks like "instanceof Stringable" differs between these
PHP versions when such classes are involved. Make every such class
implement the interface so that the behavior will be consistent.
The PHP 7.4 fallback for the Stringable interface is provided by
symfony/polyfill-php80.
Change-Id: I3f0330c2555c7d3bf99b654ed3c0b0303e257ea1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In I130326e5762e706be4889e308eeec45a6c7683c5 we introduced
support for json schema references. In some use cases
it may be more suitable to compute the references
and inline them in the resulting schema.
Introduce an $inlineReferences flag to do so.
Possible follow-up:
Memorization of already resolved and normalized references
could speed up the full schema processing, T363678.
Bug: T362098
Co-Authored-by: Sergio Gimeno <sgimeno@wikimedia.org>
Change-Id: I570faddca7216a65db2e8e70b12997bf7b5a2933
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Why:
In I130326e5762e706be4889e308eeec45a6c7683c5 we introduced
support for json schema references by traversing
and resolving any schema with a $ref property. However
the change missed to normalize the resolved references
along the process resulting in invalid json schema documents
with a $ref property of shape:
["class" => 'SomeClass', 'field' => 'SomeField' ]
instead of a json pointer string to the reference in the
document: "#defs/SomeClass/SomeField"
What:
Instead of spinning a separate reference traversal for
each $ref'ing schema, compute only the current node
reference and recursively call normalizeJsonSchema
on the resolved reference (aka definition)
Bug: T363111
Change-Id: Ic1b11eddebcdd546412ea9f27f3e037d5c242d64
|
|
|
|
|
|
|
| |
Per feedback in I130326e5762e706be4889e308eeec45a6c7683c5.
Bug: T357718
Change-Id: Ib1653daa0c374417f8aa4d00b5babb899bff94fa
|
|
|
|
|
|
|
| |
Follow-up to I130326e5762e706be4889e308eeec45a6c7683c5.
Bug: T357718
Change-Id: I58590f442850418752493ef78475bb1f034f6d42
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Why: supporting JSON schema $refs is desired for the
CommunityConfiguration 2.0 project so configuration
schemas can reuse definitions coming from another
PHP JsonSchema class. The https://json-schema.org/
specification supports relative and absolute URIs
as the content of a $ref. The change aims
to support only the former. Meaning that any
$ref defined in a schema should point to a
class that can be resolved by PHP.
What: update schema traversing in JsonSchemaTrait
to resolve any reference specified as:
[ 'class' => SomeClass:class, 'field' => 'someClassField' ]
into an actual json schema compliant $ref, eg:
$ref: '#/$defs/SomeDefinitionName'. Also annotate
new definitions found in a "$defs" array with the
resolved value of the refed class field.
Bug: T357718
Change-Id: I130326e5762e706be4889e308eeec45a6c7683c5
|
|
|
|
|
|
|
|
|
|
|
| |
* Switch out raw Exceptions, mostly for InvalidArgumentExceptions.
* Fake exceptions triggered to give Monolog a backtrace are for
some reason "traditionally" RuntimeExceptions, instead, so we
continue to use that pattern in remaining locations.
* Just entirely give up on PostgresResultWrapper's resource vs. object mess.
* Drop now-unneeded false positive hits.
Change-Id: Id183ab60994cd9c6dc80401d4ce4de0ddf2b3da0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch updates several Settings classes within the includes/Settings
directory to use typed properties, thus simplifying the codebase by
removing explicit docblock annotations for class properties.
- DynamicDefaultValues.php: Convert $configSchema property to use
typed property syntax.
- LocalSettingsLoader.php: Apply typed property syntax to
$settingsBuilder and $baseDir.
- WikiFarmSettingsLoader.php: Switch $settingsBuilder to typed property.
Change-Id: Iec8ee9c91362d13f49dea65f314d5c1113a19306
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A LogicException is very generic and doesn't mean much. An
InvalidArgumentException is also a LogicException, but more
specific: A method was called (for whatever reason – bad code,
bad user input – we don't know) with an invalid, unsupported
argument. This is exactly what's going on in these cases.
BadMethodCallException does have a confusing name and is often
misused because of this. It's documented as "thrown if a callback
refers to an undefined method or if some arguments are missing".
That's something else and not what's going on in these cases.
Change-Id: Id446227f578ba701e22acd5e530ffb795e76c147
|
|/
|
|
|
|
|
|
| |
Or just remove it. It's not needed when the structure is already an
array. PHP will happily initialize multi-dimentional arrays when
needed.
Change-Id: I93845e8d6f870d147bd55cfe3827bc94b375d0ba
|
|
|
|
|
|
|
|
| |
The global variable is now exactly the same as
`MW_ENTRY_POINT === 'cli'`.
Bug: T313841
Change-Id: I254bf4aa426e4834705be351cc9eb06d18a33f79
|
|
|
|
|
| |
Bug: T166010
Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
|
|
|
|
|
|
| |
Unit tests must use dependency injection, not global instances.
Change-Id: If7e35a67edc2337657bec4e35724d7f6bc034418
|
|
|
|
| |
Change-Id: I54c98085b21f1fe48ccf575d1b9dd60d3b855c58
|
|
|
|
|
|
|
|
|
|
|
| |
JsonFormat::decode() expects the content to decode as a string not a
StreamInterface but Response::getBody() will return a StreamInterface.
This was caught by phan as a PhanTypeMismatchArgument error. This patch
fixes it by calling getContents() which returns the remaining content
as a string.
Change-Id: I2ca03f06e7b481ccf19e1c39fa0002b4405ef23a
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Unnecessary regex modifier. I agree with this inspection which flags
/s modifiers on regexes that don't use a dot.
* Property declared dynamically.
* Unused local variable. But it's acceptable for an unused local
variable to take the return value of a method under test, when it is
being tested for its side-effects. And it's acceptable for an unused
local variable to document unused list expansion elements, or the
nature of array keys in a foreach.
Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
$wgHooks should be treated like a regular setting, which cannot be
manipulated after bootstrapping is complete. This will allow us to
greatly simplify the logic in HookContainer.
Replacing $wgHooks with a fake array after bootstrapping allows us to
detect any remaining live access to $wgHooks without breaking
functionality.
The plan is to have the fake array emit deprecation warnings in the 1.40
release, and make it throw exceptions in later releases.
See Iddcb760cf8961316d6527e81b9aa968657d8354c for the deprecation
warnings.
Bug: T331602
Change-Id: I0ebba9a29f81b0d86ad8fd84d478fb244f9e9c15
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, SettingsBuilder would allow configuration to be loaded
and modified until it was "finalized", at which point configuration
became read only. This patch introduces an intermediate stage where
registration dynamic manipulation of config values can be performed,
after all extensions have been loaded and all config schemas are known.
Motivation:
Extension registration callbacks are typically used to dynamically set
config variables, often based on other configuration. This should be
done using SettingsBuilder rather than global variables. But previously,
we could only be sure that all extensions are known after SettingsBuilder
was "finalized", at which point it would be impossible to change config
values.
Change-Id: I6f8f9f3f7252f0024282d7b005671f28a5b3acc3
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
While accessing a SettingsBuilder instance via global state should not
be encouraged, we still need it sometimes. So use a static getter
instead of a global variable. That way, we can emit deprecation warnings
when we have proper alternatives available.
Change-Id: I0013bdab474710fd521532dd2653b3789e2ede34
|
|/
|
|
|
| |
Bug: T278139
Change-Id: If451415b8acbc764b8f2b277dc8635dcfc88ff53
|
|
|
|
|
|
|
|
| |
Introduced in PHP 7.1. Because it's shorter and looks nice.
I used regex replacement.
Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This allows config variables to be declared obsolete. Obsolete config
will be omitted from the schema, defaults, name constants, etc. The
purpose of keeping a declaration of obsolete config around is to allow
the updater to warn admins that they are using a config variable that no
longer has any effect, and provide them with a remedy.
The idea is that support for deprecated config can be removed after one
release per the stable interface policy, but the declaration of
obsolete config should be kept for as long as we support updates,
that is, at least two LTS releases.
See https://www.mediawiki.org/wiki/Topic:X4bh4nf3pe2ho5jj for
discussion.
Change-Id: Ia7a00742ea7a5311e820a6a43b11135a3f2a825f
|
|
|
|
|
|
|
|
| |
Also make the same change for GlobalConfigBuilder for consistency, though
that's not critical path.
Bug: T317951
Change-Id: I9b46e7bc25365d01dbc86a9b2288559cb9e2cb8d
|
|
|
|
|
|
|
|
|
|
|
| |
This adds functionality to SettingsBuilder for collecting warnings to be
logged later, when the logging mechanism has been set up.
This also adds a validation step to update.php that aborts the update
if any warnings have been registered in SettingsBuilder, or the settings
fail to validate against the settings schema.
Change-Id: I387905289fb93591f79b96bf4c6cb5ec692b2aff
|
|
|
|
|
|
|
| |
CachedSource is newable and stable to call while the other interfaces
are now stable to implement.
Change-Id: Ifcb4865691cb7ec308acac2bd3f367b14424a0e1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The goal is to keep the actual default values for settings in the same
place as the setting is declared, and applied using the regular means
for loading the settings -- not in a separate piece of code that needs
to be loaded through some entirely different mechanism.
SetupDynamicConfig.php now contains a few categories of things:
* Post-processing of configuration settings, where already-set settings
are altered. This could be moved to MainConfigSchema too as a separate
set of methods.
* Processing of old aliases of settings (blacklist, slave) that are not
registered as settings anymore and therefore are not available to
MainConfigSchema. This could perhaps be moved to LocalSettings
processing somehow?
* Setting $wgUseEnotif, which is also not registered as a setting.
Easiest would be just to declare it as a setting and have it set
unconditionally.
* Setting the actual timezone to $wgLocaltimezone. This is not related
to configuration and should just be in Setup.php.
Bug: T305093
Change-Id: Ia5c23b52dbbfcb3d07ffcf5d3b7f2d7befba2a26
|
|
|
|
|
|
|
| |
Unused since change I88754b52c2 (commit 9e95539fc9) – this was only used
for SessionProviders, which is now a map/object instead.
Change-Id: I8da686e6379eb33a63799874fb44f9b0030ab5ba
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Added a EtcdSource to handle loading of settings from etcd. The
implementation is based on EtcdConfig but is much simpler due to
the reliance on the existing source caching layer.
GuzzleHttp\Client is used over MultiHttpClient as the latter depends on
MediaWikiServices and therefore should not be used during early
initialization.
A naive cache key is based on the etcd request URL, effectively
representing the etcd API version and settings directory, and uses
either the DNS SRV entry as the host name or the host name itself if
discovery is disabled.
The cache TTL is set to 10 seconds. The combination of this low TTL and
the naive key should replicate the current caching pattern of
EtcdConfig. Stale results are allowed for failover in case of temporary
unavailability.
At this time, the expiry weight was not changed from the suggested 1.0.
However, verification of this as a suitable early expiration coefficient
should be performed in a production like environment.
Bug: T296771
Change-Id: I782f4ee567a986fd23df1a84aec629e648a29066
|
|/
|
|
|
|
|
|
|
|
|
|
| |
This adds support for JSONSchema style property declarations with nested
schemas. This is a step towards using more nested structured for
configuration, rather than adding to the over 700 keys already defined
in the main config schema.
Defaults from property schemas are aggregated into a default value in
the top level schema. Descriptions are however not yet aggregated.
Change-Id: Iaf46a9ecc83bee3566098c56137a1be66bff2ab9
|
|
|
|
|
| |
Bug: T300129
Change-Id: I1e83a0dde6235bed91d28d7d43691c6a5d979f2f
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
By optimizing the structure of config-schema.php for fast loading,
some information needed for schema validation was lost. This patch
ensures that all schema information is retained in config-schema.php.
The code for consuming this field already existed, as written for
what we already output to the generated config.schema.yaml file.
Bug: T307769
Change-Id: I8adcdfd2b8fb5f5b96308eea74c07d8cc7a4d6ba
|
|/
|
|
|
|
|
|
|
|
|
| |
DefaultSettings.php has been replaced by MainConfigSchema.
Loading DefaultSettings.php is deprecated.
Code that needs to have access to configuration defaults should use the
ConfigSchema service object.
Bug: T300129
Change-Id: I7b2c0ca95a78990be1cdb9dd9ace92f6dcf1af15
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This is a modified rebase of a patch by Tim,
see I75f405930a7b14561389c59d147640e870146bec.
Some benchmark results (from my laptop):
Loading defaults from config-schema.php:
- Master: 115/sec ( 8.7ms)
- I75f4059: (Tim): 575/sec ( 1.7ms)
- Id9dd0bf: (Daniel): 1120/sec ( 0.9ms)
- This (Tim+Daniel): 1420/sec ( 0.7ms)
Loading defaults and merging settings (worst case):
- Master: 80/sec (12.4ms)
- I75f4059: (Tim): 93/sec (10.8ms)
- Id9dd0bf: (Daniel): 200/sec ( 4.9ms)
- This (Tim+Daniel): 682/sec ( 1.5ms)
Original commit message by Tim:
* Explicitly import function array_key_exists to activate the special
opcode
* Batch creation of MergeStrategy objects
* Batch default assignment to ArrayConfigBuilder
The batches mostly help by allowing more inlining, eliminating some
function calls.
Reduced time for apply/finalize benchmark from 540µs to 170µs.
Co-Authored-By: Tim Starling <tstarling@wikimedia.org>
Change-Id: I3d4dd685eaaa4351801b3bac6ce1592eea925c5f
|
|\ \
| |/
|/| |
|
| |
| |
| |
| |
| |
| |
| |
| | |
This adds tests for the abstract base class, to make sure the generic
implementation matches the contracts. Tests for existing subclasses may
not be using the generic code, and new subclasses may run into trouble.
Change-Id: I2c652c3028862ad52dbd0edaa454bec953e94506
|