These aren't sentences but lists of aliases as well as suggested
values. They are rendered as <code>, visualized as light gray boxes.
We don't need them to respect some language-specific word separation
to be able to read them like a sentence.
https://translatewiki.net/wiki/MediaWiki:Word-separator/qqq
explains how the message should be used.
Bug: T340378
Change-Id: Ia082b5ccb211524262f0c535bb178ee7ec3c20eb
We need to disable this so that we can update the message box in core
to use codex components.
Once I16d8f53b9a83a468acdb3803044f6c4e9d5dfeeb has been merged
the test will be restored using the new message box markup.
Bug: T326587
Change-Id: I3959c8f8d4c7bbe019f5e3b356649b5b7dc88907
Note this will make the templatedata API temporarily fail for
templates that are affected by this, until their documentation is
fixed. I think we have two ways to proceed here:
1. Thanks to Ie572809 we can change the API module to not do the
validation again. This allows us to make the validation more strict,
but the API module will continue to deliver the same data as before
until the parser cache is invalidated.
2. We accept it and merge this patch as it is. The problem is
extremely rare and easy to fix.
Bug: T333826
Change-Id: I16c7cc2328c47dde196e2dc07edb2eace33a624f
This makes it possible to use these steps independent from each
other. For example, a future patch can get rid of the re-validation
that's done over and over again when the API is called.
A significant change is that this gets rid of an expensive deep
clone. It was necessary before exactly because validation and
normalization was intertwined. Normalized properties would mess with
the later inheritance.
Strictly splitting validation and normalization (and executing them
in this order) solved this. The only downside of this is that
inherited properties are validated twice. But this is much less of a
problem, compared to the deep clone, I would like to argue.
This was always covered by tests. You can still see the tests fail
when you flip the execution order of inheritance and parameter
validation.
Bug: T301337
Change-Id: Ie5728094f9ed813f53b709d8b5283c4b99dc7d63
This button, similar to an edit-section link, will launch the editor
and immediately open the TemplateDataGenerator UI.
Bug: T316759
Depends-On: Idb5e3c51a22361e0d9916d3c31444daeff310ed2
Change-Id: Ieb575c499c16d87c28972a55662ef0bd9cb72c06
Some time ago there was a little bit of custom CSS applied to the HTML
table rendering. This is broken since patch I74214ea from 2016. This
patch renamed all CSS classes but forgot to update the PHP code
accordingly.
I decided to not change the HTML rendering because these class names
might already be used in custom per-wiki or per-user CSS. Instead I
partly revert I74214ea.
Unfortunately, some of the styles are quite dramatic, don't look good
or just don't work. I decided to remove some. The argument is that
the HTML rendering looks the same for 6 years now. I don't see a good
reason to change it now.
In detail:
* Suggested values are not aliases and should not be rendered in
gray.
* The message "no description" is rendered in gray and italics. But
this was applied to the wrong DOM element and made everything else
gray and italic as well.
* The color #777 is not readable, violating WCAG rules. While it's ok
to dim aliases and such, it must be at least #555 or darker.
* The "nowrap" destroys the table the moment one of the parameters
does have a longer name or alias. Let the browser handle this, as
it did for 6 years now.
* Same for rendering aliases as individual, indented blocks. This
makes the table unnecessarily big when there are many aliases, and
just doesn't look right. Again, let's stick to what we had for
6 years.
Change-Id: Idfa76eed6e2d68474c79d4674efce091cb031b66
The idea is to make it a little easier to follow what's going on
here.
This also improves an error message when tests fail.
Change-Id: If35be8aefab5a1568d53a9ecdc4313a66f71317b
<pre> behaves very similar to <nowiki> in so far that whatever it
contains doesn't get parsed as wikitext. It might contain {{{…}}}
tripple brackets, but these aren't going to be activated as template
parameters.
Bug: T91326
Change-Id: I05c24e369d97c48161c565e2ef30969ec28c6a23
This method is not used anywhere else:
https://codesearch.wmcloud.org/search/?q=getRawParams
I tried to make the code a bit more readable. Notable:
* Make use of the return value we get from the preg_… function.
* {{3,} means "the character '{' 3 or more times". {{{+ does the
same. Note the { doesn't need to be escaped when it's not
followed by a number.
* At the end, it doesn't make any difference when we scan for
optional closing brackets. The moment we find at least 3 we are
done.
The test is intentionally not moved. This is something for a later
patch.
Bug: T301337
Change-Id: I55e31ceecea2ae7c35bcfbc2d641b35f751820db
One method is only public to be able to test it. Others look like
they have been made "protected by default", which is not needed
anywhere.
Change-Id: Ib2231f0b2a879323aa53f8d40a175527c5b131d8
Effectively a no-op. This patch doesn't change what the code does.
Tests are in place to prove this.
As before, the tests are intentionally not moved but left in place.
This is for later patches to clean up.
Change-Id: If130e0d006a36d8c755288f8a4e4e9a4c42a6295
No functional change was made to the code. It was only moved from one
place to another. Note there are a lot of tests that cover this code.
The tests haven't been touched on purpose. Splitting these as well
is something for a later patch.
Bug: T260980
Change-Id: I9fa0fa87768f2560b83a1b5f3d39211ea9d6cfad
Parameter names in a template can be numeric. While it makes a lot of
sense to force a specific format in the TemplateData JSON (i.e. only
strings), it's inconvenient and confusing if numbers are rejected for
being "invalid".
Effects of this patch:
* The incoming JSON is allowed to contain numbers in the aliases
array.
* However, the API normalizes these and forces all aliases to be
strings, as it was always documented.
* The editor component accepts anything in the aliases array, but
forces all aliases to be strings. Again, as documented.
* Note that it was never possible to use numeric keys in the `params`
list. This patch is only about aliases.
At the moment this is a somewhat "hidden" feature. We might or might
not update the documentation to officially allow numeric aliases.
Bug: T298795
Change-Id: I32ea296b4520e7f21b03a1f6390db4f43b613bdd
This streamlines the code of the helper method a bit, mostly by
avoiding duplication.
What actually happens is the exact same as before, with one
exception: When a test case doesn't have an expected "output",
the default (mostly empty) output does not run through the
roundtrip test. While doing this is not wrong, it doesn't tell
us anything about the specific test case.
Change-Id: I4a3d8a22c3dd6a9c5c3766195e5aef3cf37a6441
"Almost" because I found at least one that appears to be
unreachable (the very first check for null). But changing this
code is out of scope of this patch.
This also updates some of the error messages to explain the
location of the error better. It appears like the incomplete
paths are copy-paste mistakes.
I also found one duplicate test case and removed it.
Change-Id: Ic0ee9d04f5cd1060ade385ef308e70d221dd2f18
I find this good practice. It makes the tests more robust (e.g.
changes to a text don't make the test fail) and is potentially
faster, as no localization needs to be loaded.
Change-Id: I6c6342c80a40ab7260c35e7f1e3052aa4a9b9358
This test was reported as being slow (approx. 0.1s, but still).
This new implementation is 10 times faster, while still
fulfilling the requirements. While the new algorithm is more
predictable (every chunk is guaranteed to contain every
character exactly onece), it's obviously still good enough.
Neither the exact length of the generated string nor the exact
length of the gzipped string matter. PHP's random number
generator might be different – possibly generating a string
that compresses different. Newer versions of the gzip library
possibly save an extra byte. Who knows. This test shouldn't
care, as long as the gzipped string is long enough.
Compatibility with PHP 7.1 can be dropped as it is not
supported any more since MediaWiki 1.34, as far as I can tell.
Change-Id: I8d63390c9f4baa6084f932fa34068f606696cafc
Mostly unused variable initializations. Note I'm inlining some
`var` keywords in this patch. This is in line with the current
style guides. See for example the discussion in I4f198e2 (search
for "hoisted" in the comments). However, I'm not changing the
entire codebase, as this is not the goal of this patch and also
just not necessary at this point.
Change-Id: Ibd80566c44584851ee2530d6b16dd28eb3db6bfe
Two main mistakes:
* The {...foo} syntax is for a variable number of parameters.
But this is not the case here.
* Optional parameters should be marked as such via [foo].
Change-Id: I0c26ea44fab6094616443ce8fae4fd47c61fd7c4
This is covering parts of the TemplateDataHooks class. This
class does have a rather simple structure:
Either hook handlers are independent from each other. We don't
need to worry about accidental coverage then and can go with a
trivial top-level @covers tag.
Or some small helper methods are called. These are parts of
what's tested and should count as covered as well, I would
argue.
Change-Id: I6f419ae80b9ad78ff86ef2922db3178b29e244a4
assertEquals() does have weird effects, like not reporting a
method that is expected to return null but returns an empty
string, and such. While it's usually not a problem, I learned
to avoid it.
Change-Id: I4f27ed5b200278021e051f1ab4d272f48e0bf344