This ensures that assertions work in a uniform way,
and provides meaningful messages in cause of failure.
Change-Id: Ic01715b9a55444d3df6b5d4097e78cb8ac082b3e
Since PHP arrays make no clear distinction between lists (JSON arrays)
and maps (JSON objects), some edge case handling is needed to make
validation work reliably when we declare types for all arrays:
1) Allow array keys to be ignored, so an associative PHP array validates
as a JSON array. This is needed for the SessionProviders setting.
2) Allow associative arrays with numeric keys to validate as JSON
objects. This is done by ignoring the type validation when numeric keys
are detected. A warning is returned in the status object.
3) Work around validation failing on float values that are expected to
be integers. All numbers come from the yaml parser as floats, and the
"integer" type in JSON schema should accept floats with if the
fractional part is 0. But that doesn't seem to work, we need to cast the
values to integers explicitly.
Also, this fixes some mistakes in the schema: LockManagers is a list,
so it should use the JSON type "array". NamespacesToBeSearchedDefault
is a map (JSON object), even though it uses numeric keys. The Actions
registry is also a map.
Change-Id: I9d0453d740c377b7cce574df743536c39a0ec619
$wgStyleSheetPath has been a deprecated alias for $wgStylePath since 1.3 (2004).
Time to get rid of it.
Change-Id: I78a6394003b9aefab7aa8559b8e2b22bc50154fc
This would have saved me around an hour if I knew it earlier. Let's make
it not happen for others.
Change-Id: I2e146424fc01677383a15d98071d8cbc2d832d9b
Follows-up I361fde0de7f4406bce6ed075ed397effa5be3359.
Per T253461, not mass-changing source code, but the use of the native
error silencing operator (@) is especially useful in tests because:
1. It requires any/all statements to be explicitly marked. The
suppressWarnings/restoreWarnings sections encourage developers to
be "lazy" and thus encapsulate more than needed if there are multiple
ones near each other, which would ignore potentially important
warnings in a test case, which is generally exactly the time when
it is really useful to get warnings etc.
2. It avoids leaking state, for example in LBFactoryTest the
assertFalse call would throw a PHPUnit assertion error (not meant
to be caught by the local catch), and thus won't reach
AtEase::restoreWarnings. This then causes later code to end up
in a mismatching state and creates a confusing error_reporting
state.
See .phpcs.xml, where the at operator is allowed for all test code.
Change-Id: I68d1725d685e0a7586468bc9de6dc29ceea31b8a
This patch ensures that we know which arrays are lists (JsonSchema type
"array") and which are maps (JsonSchema type "object"). We can then
default to array_merge for lists and to array_plus for maps. This seems
clearer than requiring an explicit merge strategy to be declared for all
arrays.
This patch specified a mergeTrategy for some config variables that need
behavior different from the default.
This patch also changes the merging behavior to allow non-array values
to replace arrays and vice versa. It also changes the behavior of
defaults to allow falsy values to override non-falsy defaults.
Bug: T300129
Change-Id: Ia7b0c0250af6a957eac1efb554fb47511f5e093f
This adds an option to the schema generating maintenance scripts to
validate abstract schemas and schema changes and a structure test to
validate exisiting schemas and schema changes. Schemas are also
validated when generating.
The validation for the schema doesn't impose limits on table, index or
column names as I couldn't find any reliable conventions for them.
The structure tests only cover MediaWiki itself as there is no
convention on where extensions store their abstract schema.
Ideally, auto detection would be possible for sql/, but for now
extensions have to define their own (thankfully trivial) tests.
A couple of invalid definitions were fixed thanks to these tests.
I aimed to be thorough, but not all parts of the abstract schema
are completely clear, and Doctrine's documentation is not complete.
As a result, not everything has a description field.
Bug: T298320
Change-Id: I681d265317d4d1584869142ebb23d4098c06885f
This is a first draft of the configuration doc renderer.
The resulting markdown certainly needs some love, but
we can work on improvements incrementally. This gives
us a baseline to reference on doc.wikimedia.org
Bug: T296647
Change-Id: I3c426b9fc37b1cf7ce8423969b2d7589767ee6cc
In order to allow configuration default to come from JsonSchema,
and dynamic defaults need to be initialized in Setup.php.
This movesd the initialialization of $wgExtensionDirectory and $wgStyleDirectory
to Setup.php
Bug: T294788
Change-Id: I11f5723aa299caa210cf6a1f5b7436f191b1ffc2
- Allow to specify a folder with --sql and get the name from json
filename or use the default sql filename.
- Show output that the script has something done.
Change-Id: I0dbec168efac465c962ab7184953bc2461e85d1d
The config-schema.yaml follows the settings file format.
It's not used in reality yet, but tests were added
to compare the yaml with the result of DefaultSettings.php
importing.
The list of properties not yet included:
- 'wgVersion' - deprecated alias to MW_VERSION
- 'wgConf' - instance of SiteConfiguration
- 'wgStyleSheetPath' - alias to another global
- 'wgExtensionDirectory', - depends on $IP
- 'wgStyleDirectory' - depends on $IP
- 'wgServiceWiringFiles' - depends on __DIR__
- 'wgHTTPMaxTimeout' - infinity default
- 'wgHTTPMaxConnectTimeout', - Infinity default
The PHPDoc was copied over as is into description fields,
it will be converted to something more pleasant in a separate
iteration.
The types were parsed out of PHPDoc and fixed up manually.
Default values come from executing DefaultSettings and serializing
the values into YAML.
Change-Id: I9aa9ad9713bdbdac2bd7b528c609772154b5a135
This is the same functionality provided by `npm test:size` in Minerva
and Vector skins, but as a structure test. Any extension/skin that
provides bundlesize.config.json containing an array of expected gzipped
sizes and module names will be processed by this test.
See also WikimediaMaintenance's blameStartupRegistry.php for similar
code.
Bug: T255149
Change-Id: Ieb7591f3c0ac843677a2a61b4ad47f920fc2ca2d
In all cases where the client registry is used, the `noscript` module
is inapplicable. Additionally, make it illegal to have a module
include the 'noscript' module as a dependency.
Bug: T291735
Change-Id: I5846f2c19b003989b56b12628b385fd37049483b
Update/Create override classes of ContentHandler.
Soft-deprecate and remove method from Content and classes that override them.
Bug: T287158
Change-Id: Idfcfbfe1a196cd69a04ca357281d08bb3d097ce2
This structure test makes sure that some basic operations work peroperly
for all registered content models.
The idea is to make sure we don't break anything for extensions when we
make changes to COntent and ContentHandler classes.
Bug: T287158
Depends-On: I739be0e8b03bf2c7f2589a106e2fae46f7bb160e
Change-Id: I2fc864a201b929fcf97c02296f7e3c831d5cbea4
This is no longer required now that the prefix of the proofreadpage
meta query is set to 'prpi'.
This reverts commit d6db8f4ad0.
Bug: T290585
Depends-On: If2041873eac35806ae14645064d1f544142186e1
Change-Id: Ie7092cf26c4e55d324834f3478188498012f48cb
This is shared between ProofreadPage's proofreadinfo and PageImages.
As these two extensions are not installed on the same wikis (PRP is
Wikisource-only, PageImages is disabled on Wikisource), there is not
urgent need to change one or the other, as that will break API
stability.
So, simply disable the API prefix uniqueness check for now (following
the example of T196962), and migrate the PRP info API as a follow up,
giving API clients time to update.
Bug: T290585
Change-Id: I7c35f911f254dcb7d2fa21bbac67416209229dcc
Does not rely on any integration, its a structure test
that ensures that all test files end in Test.php
MediaWikiUnitTestCase includes a check for the file being
under /unit, but rather than adding an exception there,
just extend the base PHPUnit test case class, since
we don't need anything from MediaWikiUnitTestCase or
MediaWikiTestCaseTrait.
Change-Id: Ie4d4dc0dd41c4d80c8347847ef72b2ce03b72042
Code that needs to store an actor ID in the database to
represent a UserIdentity, or needs to construct a UserIdentity based on
an actor ID loaded from the database, should use the ActorNormalization
service.
Note: The getActorId() method is removed from the UserIdentity interface,
but all concrete classes continue to support it for now.
UsererIdentityValue::getActorId() is hard deprecated and should
be removed in 1.37. It always returns 0.
User::getActorId() is not deprecated at this point.
Bug: T274179
Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237
Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1
Postgres:
- Change page_namespace from smallint to int
- Change page_random from numeric with arbitrary precision to float
- Make page_touched not nullable
MySQL/SQLite:
- Change datatype of page_title from varchar (with binary collation)
to varbinary(255)
- Drop default empty string from timestamp field of page_touched
Bug: T230428
Bug: T164898
Change-Id: Ibdaf332ea1da309d31d35a6ebbc1b8fefced335e
Jenkins logs show that some of the cases are slow,
but its hard to tell what special page "data set #74"
corresponds to
Change-Id: I9b2a04b35c31bedd71fa575a6d7b9634f8282031
This table is massive but thankfully we fixed most of its complexities
in previous patches.
For MySQL/Sqlite:
- Change type of rc_title and rc_source from "varchar binary" to
"varbinary"
- Drop default of rc_timestamp
- Change rc_timestamp from varbinary(14) to binary(14) to standardize
timestamp datatypes
One index doesn't follow the uniform prefix rule but since it's in a
maintenance script, will fix that in a follow up.
Bug: T230428
Bug: T42626
Change-Id: I13994e02ad3a2293148346ef7be96746578ad854
- JavaScriptMinifier: The public interface for this internal class is
ResourceLoader::filter which, except for one caller (minify.php)
is indeed consistently used already, no other callers need replacing.
- CSSMin: Idem for minification, however, this class has some other
method as well, which have a number of internal users, but none
outside core. These have all been replaced in this commit.
- Remove pear/net_url2 as own dependency as this was only used by CSSMin
and recently added there. This is now a dependency of wikimedia/minify
instead. This was not part of the public API and no longer mentioned
here in composer.json or RELEASE-NOTES. (It remains pinned in
mediawiki-vendor, however.)
Bug: T273247
Depends-On: Iadff8c2112d5e53bd994ab4882006e8c644a2379
Depends-On: Id3c6dcc0b952a9efe34b3a9ed88b716101a51f87
Depends-On: I589be910f57289fd908b22db87241b0e52da60d4
Change-Id: I8d71fc64aeecdb31db218b02e361ae9bb0d19b48
Sometimes the special page can’t be created – for example, the list of
registered pages could have changed between the data provider and the
test function, due to extensions conditionally registering their special
pages. Skip the test in this case instead of crashing.
Bug: T275661
Change-Id: I573967ac22ed3a596b4f80b76d395ac948f802e8
ActorNormalization needs to have separate wiring if we want to be able
to access it by name. This is needed to allow access to the service in
declarative wiring, e.g. via ObjectFactory specs.
As an aside, this changes SpecialPageFatalTest to not construct special
pages in a data provider. Accessing services in data providers should be
avoided. This change does not eliminate all such access, but reduces it
by deferring service lookups via ObjectFactory.
Change-Id: I5792cdcc0e5b0d1681f55dbe3e1f70c34a0cb775
Exception::getMessage() always returns string, so it will
never equals boolean false, so the test will always fail, but
with a confusing error message.
Bug: T274591
Change-Id: Icd10e67a70666927eca886c829a4a3b1cd7441eb
My personal best practice is to not document @params when there
is a @dataProvider. I mean, these test…() functions are not
meant to be called from anywhere. They do not really need
documentation. @param tags don't do much but duplicate what the
@dataProvider does. This is error-prone, as demonstrated by the
examples in this patch.
This patch also removes @throws tags from tests. A test…() can
never throw an exception. Otherwise the test would fail.
Most of these are found by the not yet released I10559d8.
Change-Id: I3782bca43f875687cd2be972144a7ab6b298454e
These are not only 100% identical to the actual code, but also:
* It's error-prone. Some are already wrong.
* These test…() functions are not meant to be called from
anywhere. What is the target audience for this documentation?
* There is a @dataProvider. What such @param tags actually do is
document the provider, but in an odd place. Just looking at
the provider should give the same information.
* The MediaWiki CodeSniffer allows to skip @param when there is
a @dataProvider, for the reasone listed.
Change-Id: I0f6f42f9a15776df944a0da48a50f9d5a2fb6349