Introduced in PHP 7.3. I used it to replace reset()/end() followed by
key() where the return value of reset() is not captured and internal
pointer iteration is not locally occuring.
I also used it in a couple of places when reset() is absent but
array_key_first() is semantically desired.
Change-Id: I750d3fa71420cbdca5fb00d82ac5ca40821769d4
String offsets in MariaDB are 1-based, except in "Oracle compatible"
mode. SUBSTR(modtoken,0,13) was always the empty string and so the
modtoken comparison was always true. I was able to reproduce a failure
to reach consistency using ring replication.
Add regression test.
Bug: T315271
Change-Id: I74e54e8aba44505dd04426c12d91a9ea0de17f22
* When an exception is thrown from
modifyTableSpecificBlobsForIncrInit(), call cancelAtomic() on the
connection. Otherwise a subsequent call to
LBFactory::commitPrimaryChanges() will throw a user-visible error,
violating the goal of graceful failure.
* After getting a DBConnRef, call ensureConnection() on it. Otherwise
the try/catch blocks around getConnection() have no purpose since
connections are always lazy-initialised.
Bug: T315274
Change-Id: I8a5bc90bb340f34bd4a88872a1a2e72612ac91f4
The main object cache is disabled during testing. Some integration tests
need it though. This provides a clean way to enable it, to replace the hacks
that were used so far.
Note that we may want to enable the main cache during testing soon. When
that happens, this method is still useful to disable the cache in certain
tests, and to set a specific cache instance.
Change-Id: I04ae1bf1b6b2c8f6310acd2edf89459d01a9c870
It's not called by anything since it was removed from
ChronologyProtector, and it is not needed for production.
Pass the timeout directly to LoadBalancer::waitForAll() instead of
using a WaitConditionLoop, as it was before e99bb1b7dc
Change-Id: I5a1903e6e9ac145c06f77c690a0f6a487b4aa43f
Substantive changes:
* Remove the parameters globalKeyLB and localKeyLB, not needed in
production, probably not used anywhere.
* Add a "cluster" parameter, for production.
* Don't call markServerDown() in LoadBalancer mode.
Style changes:
* Document config parameters separately from constructor parameters, to
clarify the role of the wiring normalisation.
* Inject a load balancer from ObjectCache to SqlBagOStuff, using a
closure to defer construction.
* Clarify the split between LoadBalancer mode and server array mode by
introducing a useLB property. Use it instead of special shard index
values and array counts.
* multiPrimaryModeType wasn't needed anywhere and wasn't available in
the constructor, so it just became a boolean multiPrimaryMode.
* Add a test covering most of the server array (!useLB) branches.
Bug: T212129
Change-Id: Ib097082efb40b514a29a42286dc362f2e3743ee4
This edition brought to you by:
grep -ERIn $(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | tr
"\n" '|' | sed 's/|$/\n/') includes/
I only corrected a fraction of the results provided by that command. I'm
submitting the partial patch now so it doesn't bitrot.
Bug: T305805
Change-Id: If1918c0b3d88cdf90403921e4310740e206d6962
Since no mysql-specific queries are required, allow sqlite and
Postgres setups to use "multiPrimaryMode" for easier testing.
Avoid "CASE types text and integer cannot be matched" Postgres
error by making dbEncodeSerialValue() cast the result to a string
so that addQuotes() applies in buildUpsertSetForOverwrite().
Bug: T212129
Change-Id: Ic84a804c272a7070779c8d41d3a33003852d0839
Parsing "the reciprocal of the probability of purging on any write"
is fine in isolation, but requires too much effort when trying to
undertand the larger picture at the same time.
Bug: T212129
Change-Id: I6f21727c05b4fc0449de5d6acec14e49ed1991ef
By default, CACHE_DB and db-replicated are similar, with the main
difference being that db-replicated will prefer to read from a local
replica server rather than the primary server. Setups using sqlite
do not have use for replication logic, since everything uses local
database files. To reduce contention, SqliteInstaller makes CACHE_DB
use a different database file (rather than a table in the main wiki
database file).
This change makes 'db-replicated' reuse the same cache instance.
Tweak ObjectCache::newFromParams() to make ObjectFactory usable.
Also set $wgResourceLoaderUseObjectCacheForDeps to true to avoid
similar contention in SqlModuleDependencyStore.
Bug: T303225
Change-Id: Ia644f35698b69fe340fc1bcae8899c7e332f332d
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
All callers pass in floats and this is the expected type, used
to fill $microseconds.
Bug: T303628
Change-Id: I6c6176b4cc308646d86a5b9d2afdc91aadda4a0d
getMaintenanceConnectionRef second parameter is the group,
not the domain
Break another line to make the argument order more visible
Follow-Up: 618b61a4c6
Change-Id: Id6dd0c2f8e5aded759fe403f8435ee7251a46b8c
The functions returning null or the class property is set explict null.
Some function should not accept null or return null.
Found by phan strict checks
Change-Id: Ie50f23249282cdb18caa332f562a3945a58d86ff
Some function already document "False on failure", but does not document
it on the used type
Found by phan strict checks
Change-Id: I12eb8bbc99179833ee3e42c1a7d1dc1443682ca6
* Some functions accept only string, cast ints and floats to string
* After preg_matches or explode() casts numbers to int to do maths
* Cast unix timestamps to int to do maths
* Cast return values from timestamp format function to int
* Cast bitwise operator to bool when needed as bool
* php internal functions like floor/round/ceil documented to return
float, most cases the result is used as int, added casts
Found by phan strict checks
Change-Id: Icb2de32107f43817acc45fe296fb77acf65c1786
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
All callers in Wikimedia gerrit repos have since been migrated to
incrWithInit(), which is usually what is desired and is easier to
implement in various backends. Newer memcached versions of the
memcached protocol even support auto-initializing increments
(including an initial TTL) via the 'ma' command. The incr()/decr()
methods currently bloat the interface and subclasses (often with
slow and buggy implementations). These methods are also hard to
implement in a multi-DC store (either extremely slow or racey)
even though callers might assume they handle high concurrency.
Also, force each MediumSpecificBagOStuff subclass to implement
incrWithInit() instead of having some rely on the base method
In mcc.php, add incrWithInit() and simplify parameters, making
it possible to test non-memcached backends.
Change-Id: I53c9c2c839a1e71d5c104913fea0680c30d11108
Previously, "globalKeyLB" was generally useless for sharing keys since
the LoadBalancer would still use the default domain.
This does not effect configuration using "server"/"servers".
Follow-up to 6a8943d8c5.
Bug: T212129
Change-Id: I5b20c9d3f153650d6e03581fd523cba4961f664f