Commit graph

178 commits

Author SHA1 Message Date
jenkins-bot bde2188280 Merge "Show much more actionable context when paramOrder is incomplete" 2023-09-04 13:45:24 +00:00
thiemowmde 39602bdb8d Replace calls to deprecated ApiPageSet methods
Bug: T339384
Change-Id: Iafc14bb31fd37d38fe0cf53c81f0b774f939f6ef
2023-09-01 07:08:25 +00:00
jenkins-bot 4aaa893c4b Merge "Load GUI on action=edit if page has templatedata even outside NS_TEMPLATE" 2023-08-30 19:42:09 +00:00
thiemowmde 416c3d4f45 Make use of the ??= and ?: operators where it makes sense
This patch also removes small pieces of code from tests that are
never called, as it turns out.

Change-Id: I10ce18339135fefd9a99e0613dc6bfc457ddf4df
2023-08-23 09:24:50 +02:00
thiemowmde bb7b801b64 Show much more actionable context when paramOrder is incomplete
So far we show nothing but the index in the "paramOrder" array. This
is especially useless when a parameter is missing. The index just
points to the end of the array then.

Same when an unknown parameter appears. What the user needs is not
the index but the name of the unknown parameter.

I played around with a few formats. As suggested in this patch:
 Required property "paramOrder[ "foo" ]" not found.
 Invalid value for property "paramOrder[ "foo" ]".

A possible alternative is:
 Required property "paramOrder[0] ("foo")" not found.
 Invalid value for property "paramOrder[0] ("foo")".

Bug: T340377
Change-Id: I1dbef1b6e585d5b972a0c9a373a040aee6027cf3
2023-08-21 12:52:42 +02:00
Timo Tijhof 1f105ed5f6 Load GUI on action=edit if page has templatedata even outside NS_TEMPLATE
Bug: T189989
Bug: T300676
Change-Id: I372e29af7f14fba6ebc60bb6ea025b8e1015f2a7
2023-08-21 10:22:45 +00:00
gerritbot cfd2e5b664 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I2a7aaadc47dd068ccea8fd8110054433973df52c
2023-08-19 18:11:41 +00:00
Umherirrender 8bd3dbc58c Use HookHandlers for core hooks
The use of "HookHandlers" attribute in extension.json makes it possible
to inject services into hook handler classes in a future patch.

Bug: T271031
Depends-On: Ic2d188d2c332ab8afeb5454fb5a956c8ba5670ae
Change-Id: Idf4cf94a0e4fae31a5c1f6c3dbf319c0d6913cd7
2023-08-15 13:03:15 +02:00
Ed Sanders 6107710ef1 Left align caption and put [Edit template data] inline
Bug: T339806
Change-Id: I69a46e64810edf458b8a8ee3e043f6dbc287c8aa
2023-08-05 15:13:22 +01:00
Thalia 855156c95f Hooks: Use UserIdentityUtils for temporary user check
Use instead of UserNameUtils, which has more dependencies.

Change-Id: If8c8687d360690368f9f07999a2baa7ee7a6ad61
2023-07-26 11:38:32 +01:00
thiemowmde b8f4df67f9 Replace inappropriate use of "word-separator" message
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
2023-06-25 16:57:50 +02:00
Thiemo Kreuz 647cd0bc65 Clean up base class reaching into the subclass
This does not change anything. It's only about the readabilility
of the code.

Change-Id: Ia908bd90ebc261f3bebc7854501a6f5d5e736384
2023-06-09 07:10:19 +00:00
gerritbot 2d16a7c72f Update moved class EditPage
See T321882. Moved in Ibefc44eb64aed

Bug: T321681
Change-Id: I9de606e32ac58ddbf68ee00587ee9b7f0f9f157d
2023-05-06 21:20:32 +00:00
jenkins-bot 82e5ba9172 Merge "Replace IDatabase with IReadableDatabase where possible" 2023-04-22 20:47:44 +00:00
jenkins-bot 849150c814 Merge "Add missing validation for empty parameter names" 2023-04-21 13:12:29 +00:00
Bartosz Dziewoński f2c89028bd Update TemplateDataEditor logging for IP masking
Bug: T332434
Change-Id: I9935e7d35b1cdb14c0958351cd84d9d6476d6363
2023-04-18 19:30:54 +00:00
thiemowmde b632162245 Add missing validation for empty parameter names
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
2023-04-11 19:08:37 +00:00
jenkins-bot 0298a2d116 Merge "Split validation and normalization into separate services" 2023-04-11 04:51:02 +00:00
thiemowmde 584fdcddf6 Extract serialization methods into TemplateDataStatus class
This makes the large Hook class quite a bit smaller.

Change-Id: I55229116eb16ccd9be21d1f34de5e52826ece2bf
2023-03-09 11:46:49 +01:00
Thiemo Kreuz 7a32cba3ef Split validation and normalization into separate services
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
2023-03-06 13:05:51 +00:00
thiemowmde 962e2828e0 Replace IDatabase with IReadableDatabase where possible
This is a much more narrow interface and really all this code needs
to know.

Change-Id: I2f20fadb8a9630cdb1b7baf9da70e0287db85de2
2023-03-06 12:38:42 +01:00
Sam Smith 0f4d04e83f Use EventLogging::submit() to submit analytics events
EventLogging::logEvent() was marked as deprecated at the beginning of
2021 in I0cfd07295d4b51ca4805c79a28a9a4bd64ff7cc9.

Bug: T318263
Change-Id: I2d89784cc249e97954c9be05169f3060fd69945f
2023-01-30 18:20:16 +00:00
EpicPupper 1e0cecd494 Improve API examples
Bug: T271040
Change-Id: I5b9bbc932d887086d647ce89fb77d192a896d32d
2023-01-17 01:08:27 +00:00
Thiemo Kreuz 505a835c49 Extract named isValidCustomFormatString() method
Bug: T301337
Change-Id: I02e81c264e7ebeb60483d7eacf9fa7b27ad1e545
2022-12-15 12:15:35 +00:00
jenkins-bot e1b5970d3f Merge "Split parameter validation off as separate methods" 2022-12-13 21:09:37 +00:00
Ed Sanders 678d95251b Add an "Edit template data" button to the TemplateData output
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
2022-11-08 13:36:38 +00:00
libraryupgrader ca32a8ced1 build: Updating mediawiki/mediawiki-phan-config to 0.12.0
Change-Id: If6ebb246effabc99b7d72a336bacee65c54b5c67
2022-10-09 15:42:03 +00:00
Bartosz Dziewoński ba0e71fd33 Migrate usage of Database::select to SelectQueryBuilder
Bug: T312348
Change-Id: I59057174c102c29877608db2a6c26b7a50bd34cf
2022-08-12 23:54:22 +02:00
Thiemo Kreuz 8497d85a2d Fix CSS styling of the HTML rendering broken since 2016
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
2022-08-08 11:56:16 +02:00
Thiemo Kreuz c0755ea392 Split parameter validation off as separate methods
This only moves code around but doesn't change anything. The tests
should prove this. The only change is that validating if "inherits"
points to an existing parameter is now done a little earlier as part
of validateParameters().

Bug: T301337
Change-Id: I20865d8f93ea0f3cb1c0683804c7871056a700a8
2022-07-15 11:11:32 +02:00
WMDE-Fisch d1ffdc2b95 Remove $wgTemplateDataSuggestedValues feature flag
Feature is always enabled now.

Bug: T307188
Bug: T310684
Change-Id: Ic99c594ceec0020a6c9d20f0a4f10285b74ea9a8
2022-06-27 12:14:02 +02:00
Umherirrender 560819e270 Use WikiPageFactory to create WikiPage object
Bug: T297688
Change-Id: I5e6da574bd1377b492005adbc1aff3e97fe9c31b
2022-06-24 19:53:40 +02:00
Thiemo Kreuz e297e767f0 Streamline HTML rendering code for format messages
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
2022-05-16 18:04:27 +00:00
Thiemo Kreuz ff7470e316 Add placeholder to avoid wikitext editor jumping down
Bug: T279869
Change-Id: Ic8f9bf7c95b42422dc4b477f9c752f5e89b20dc7
2022-04-25 08:42:59 +00:00
Thiemo Kreuz 1c8b4ae729 No HTML needed to validate <templatedata> in wikitext
I tried to benchmark this and yes, it makes a difference, but probably
not a big one. This is an additional parse in addition to the one core
will later do when the page is actually saved. For this one here we
are just not interested in the HTML.

Bug: T305105
Change-Id: I71147af5161c934a822651e80e11f3bd26af56cd
2022-04-11 18:29:51 +02:00
gerritbot 42061b7174 Fix usage of ApiBase::PARAM_* deprecated constants
The ones that are replaced with ParamValidator

Bug: T275455
Change-Id: Ia08525d4162d8b460ca8f7fd97b75f564b6bbb7c
2022-04-04 01:29:48 +02:00
Reedy 5341749f56 Use namespaced EventLogging class
Change-Id: I87ed269b205e83ce87e5350ef31d35847a6ad25b
2022-03-06 16:07:22 +00:00
Thiemo Kreuz d3f00177ba Don't extract template parameters from <pre>
<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
2022-03-03 21:20:40 +00:00
Thiemo Kreuz 8fec04c8fd Remove unreachable validation step
I tried to write a test that can cover this code, but realized it is
unreachable. All parameters with all their properties are already
validated in the first loop.

Bug: T301337
Change-Id: If97adba45beb0ef1303907746715613fca23468e
2022-02-22 10:51:00 +01:00
C. Scott Ananian 453c4152af ParserOutput::getPageProperty() now returns null when key is missing.
The return value of ParserOutput::getPageProperty() has transitioned
to returning `null` instead of `false` when the page property is missing.

Bug: T301915
Depends-On: Iaa25c390118d2db2b6578cdd558f2defd5351d15
Change-Id: I1126eab0e882b5bdfecea1ef6e3e27dca7b85115
2022-02-17 11:57:25 -05:00
C. Scott Ananian b87e24813e Update uses of ParserOutput::getPageProperty() to handle new return value
The return value of ParserOutput::getPageProperty() will transition to
returning `null` instead of `false` when the page property is missing.

Bug: T301915
Change-Id: I71628661b4539a4e35ae32846e719f92bcf782e0
2022-02-16 18:26:42 -05:00
jenkins-bot 67d6b77a84 Merge "Move getRawParams helper method to ApiTemplateData class" 2022-02-10 05:44:14 +00:00
Thiemo Kreuz da8969812c Move getRawParams helper method to ApiTemplateData class
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
2022-02-09 12:37:33 +00:00
Thiemo Kreuz b1a4a27531 Split and streamline HTML formatter code
Bug: T301337
Change-Id: Ic2dac65e6e54411abc33326abf8d0fab148cb784
2022-02-09 12:37:29 +00:00
jenkins-bot 5407262418 Merge "Improve test coverage for HTML formatter code" 2022-02-08 16:09:17 +00:00
jenkins-bot a64ed0a376 Merge "Fix/narrow visibility of several methods" 2022-02-08 15:54:22 +00:00
Thiemo Kreuz a81a8b52bc Improve test coverage for HTML formatter code
… as well as some smaller improvements to the test coverage of other
code.

Change-Id: I5bec9c456fdc597c340dc0b515d23d837a7c5651
2022-02-03 12:45:27 +01:00
Thiemo Kreuz b674294789 Fix/narrow visibility of several methods
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
2022-02-03 10:48:04 +01:00
Thiemo Kreuz 001494f443 Move last remaining HTML formating code out of blob class
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
2022-02-03 09:33:03 +01:00
jenkins-bot 59e582cfb6 Merge "Split validation into some smaller steps" 2022-02-02 14:39:59 +00:00