Commit graph

171 commits

Author SHA1 Message Date
libraryupgrader 3d79d3518b build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: I409d4c564a02f537dbd1ceec1576410aefe0ea64
2021-05-04 01:29:20 +00:00
libraryupgrader be7f1b3bd7 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 34.0.0 → 35.0.0
* mediawiki/minus-x: 1.1.0 → 1.1.1

npm:
* eslint-config-wikimedia: 0.17.0 → 0.18.1

Additional changes:
* Added the "composer phan" command to conveniently run phan.

Change-Id: I2e27a8ae5547829501c25402da5b72b390897ca1
2021-01-29 06:21:06 +00:00
Umherirrender e30f055226 Improve function and property documentation
Removed some wrong @param from test function,
the @dataProvider should be a enough here

Change-Id: Ib84ce497fef4d48df7547ebc38515fc377e7de01
2021-01-16 13:44:19 +01:00
Taavi Väänänen 9293e2d5ca Update Cite to use the new HookContainer/HookRunner system
Bug: T270875
Change-Id: Ieb29603cde24a1c52829c12ae431eca09ba37bf9
2020-12-28 17:55:34 +02:00
Ed Sanders 35b704dc2f Move ext.cite.ux-enhancements to extension.json
Change-Id: Ia6a0c34800b018e76b9e246898ddfb991f238d55
2020-12-14 10:38:32 +00:00
Thiemo Kreuz d44754168f Fix coverage report for ErrorReporter
The structure of this class changed a lot in If2fe5f5
(T239572). This was never reflected in the @covers tags. I
suggest to go with a trivial @covers for the entire class
and let PHPUnit figure it out. The alternative is to kind
of repeat many private implementation details, and this
doesn't feel right.

Change-Id: Ie414876489133ab9aca934c19a5e403cd339abf1
2020-10-27 09:49:56 +00:00
Thiemo Kreuz 27c5632ebd Compact trivial arrays in test providers
This is meant to make the code easier to read.

Change-Id: Ib684bf64acfbac9b458d110d9ccff2d071b993be
2020-10-08 11:07:35 +02:00
Thiemo Kreuz 7ce27b432f Stop using Language::formatNum to localize separators
This is done to make the discussion in If3dcfd7 easier.

When we introduced this code we actually used it to format
entire numbers. We had to change this later to *not* localize
digits, but only separators. Language::formatNum is and always
was able to do this, so we just continued to use it.

This is discussed now.

It turns out there is only a single place left where we use
formatNum, and it does nothing but localizing the decimal
point. There is another way to do the same.

Bug: T237467
Change-Id: I89b17a9e11b3afc6c653ba7ccc6ff84c37863b66
2020-09-02 09:40:33 +02:00
Thiemo Kreuz 41149d8072 Restore preview of a <references> section alone
We broke this feature in December 2019 because it was never covered
by any tests. Full explanation in T245376.

All the features we care about are covered by tests. If all existing
tests succeed, that should be proof enough that this patch does not
introduce any new regression.

Bug: T245376
Change-Id: I1a447884bdc507ac762d212466496b4591c18090
2020-07-21 13:19:38 +02:00
James D. Forrester c35d47fe0b Use QUnitTestModule instead of deprecated ResourceLoaderTestModules
CI already ensures that VisualEditor is loaded alongside Cite, so
the defensive check in the code isn't needed; ext.cite.visualEditor is
defined statically, it's just injected into the page dynamically in the
VisualEditor code handling VisualEditorPluginModules.

Bug: T232875
Change-Id: Ie5e096feca92f9c3ef13c732f3f1ae491e2b7d03
2020-05-11 20:51:24 +00:00
Bartosz Dziewoński 3678215a77 Add a newline in wikitext before autogenerated reflist
Previously the reflist was added at the end of the last line of text,
which messes up paragraph wrapping (as seen in many test cases), and
generated invalid HTML when the last line was a list item (T148701).

(second try, previously reverted in 8c933d03c5)

Note this affects only pages where the <references /> tag is missing,
and the references section is auto-generated at the very end of the page.

Bug: T148701
Change-Id: Ib2101346434a4e317b5fc7379215b60c7020cb2b
2020-05-06 20:51:25 +02:00
jenkins-bot a27b4c82a6 Merge "Revert "Add a newline in wikitext before autogenerated reflist"" 2020-04-01 08:15:41 +00:00
Awight 8c933d03c5 Revert "Add a newline in wikitext before autogenerated reflist"
This reverts commit 90697ffe43.

Change-Id: I659ce1689603fd16e378fb8d3d5bd6d1089342b2
2020-04-01 08:03:55 +00:00
jenkins-bot 45f4990e34 Merge "Add a newline in wikitext before autogenerated reflist" 2020-03-31 19:37:34 +00:00
Bartosz Dziewoński 90697ffe43 Add a newline in wikitext before autogenerated reflist
Previously the reflist was added at the end of the last line of text,
which messes up paragraph wrapping (as seen in many test cases), and
generated invalid HTML when the last line was a list item (T148701).

Bug: T148701
Change-Id: Ifc873fc913e717026d80d54b570c594d1073fb42
2020-03-31 19:00:51 +00:00
jenkins-bot a00401fdfc Merge "Remove not needed code without changing anything" 2020-03-31 18:30:21 +00:00
Thiemo Kreuz 53b043f28f Remove not needed code without changing anything
This removes a few tiny pieces of code, and a large chunk related to
incomplete follow="…" attributes (see T240858). It turns out we don't
need to insert elements at the top of the ReferenceStack::$refs
array, because this array is reordered anyway in
ReferencesFormatter::formatRefsList()!

Incomplete follow refs don't have a number, and are ordered to the top
because of this, as before. This doesn't change with this patch.

Change-Id: I43036420be22feb8f0f287d9ccee2afd317df2a9
2020-03-31 18:15:14 +02:00
Timo Tijhof ce27a400e1 CiteHooks: Remove wgResourceModules check (redundant with isModuleRegistered)
The isModuleRegistered() method was introduced a few years ago,
when the load order in ResourceLoader was undergoing a change.

It used to be that hooks like were run first to register modules, and then
wgResourceModules was registered afterwards. This was reversed to disallow
mutating the config at run-time from foreign modules and to allow better
caching and error detection.

It's been several years since then, so this redundant check is no longer
needed. ServiceWiring.php in MW core for ResourceLoader always processes
config and extension.json first before this hook is called.

Bug: T247265
Change-Id: I466f1fa70b8f0e9fe5e8e8df90bb0001b3329b87
2020-03-10 16:18:46 +00:00
Brian Wolff 5ed973a49a Fix unit tests for whitespace change in Html5 fragments
Bug: T238385
Depends-On: Ie2b7c9429691e2c491c3359d5b400d8f078aa789
Change-Id: Ie2b7c9429691e2c491c3359d5b400d8f078ab111
2020-02-25 13:56:53 +00:00
Brian Wolff 1c6a92ca9b Temp disable test to work around circular dependency in unit test
Html5 fragment mode now bans whitespace per html5 spec

See Ie2b7c9429691e2c491c3359d5b400d8f078aa789

Change-Id: Ie6fa40798f06a358f6082110b4d8cc0028c80321
2020-02-25 04:38:06 -08:00
Thiemo Kreuz 400ce89f30 Don't talk about follow being "broken" but "incomplete"
Bug: T240858
Change-Id: Iab6563fdf19d6e85795911e4140476fceabf7334
2020-02-05 16:38:49 +00:00
Adam Wight f2bd6b6dcc Revert "Standardize "follow" validation"
This reverts commit a3d312c8f4.

Bug: T240858
Change-Id: I3bee35f27797a04c41c265f7e598d8383414b67a
2020-02-05 11:42:28 +01:00
Adam Wight b15f1b81a0 Revert "Remove "follow" special case from ReferencesFormatter"
This reverts commit 38122d91cd.

Bug: T240858
Change-Id: I7198d5534acded94bc83962262c4cdfed9782454
2020-02-05 11:42:27 +01:00
Adam Wight eb799af3df Revert "Remove broken "follow" special case from ReferenceStack"
This reverts commit d01cba60fb.

Bug: T240858
Change-Id: I5b528a285ed6a658ceb333b58f0f4a81a64c7f15
2020-02-05 11:42:26 +01:00
jenkins-bot 7c3ace4fef Merge "Rewrite ErrorReporter for performance and separation of concerns" 2020-02-03 14:58:55 +00:00
jenkins-bot 74fab9755f Merge "Remove one unnecessary LogicException from ReferenceStack" 2020-02-03 14:50:40 +00:00
Thiemo Kreuz d80bd3ef97 Rewrite ErrorReporter for performance and separation of concerns
This patch is mostly moving code around without changing the behavior.
Exceptions:

* The ErrorReporter creates a <span> container. This was previously
parsed. The only benefit might be error checking and escaping. Rather
pointless. The code just created this HTML. With this patch, it is not
parsed any more. The unit test reflects this change. The output in
production will not change, as the parser tests show.

* Parsing of the message key (to detect it's type and id) is simplified
a lot, using explode. With this the code can, in theory, support more
types.

Bug: T239572
Change-Id: If2fe5f55db46dfc7e0ce445348608bef00bec64e
2020-02-03 15:23:40 +01:00
Adam Wight d01cba60fb Remove broken "follow" special case from ReferenceStack
This is unreachable now that broken follow refs fail validation.

Bug: T240858
Change-Id: I22adaee9c4eaeb94bee953ae15c642e044b6a54b
2020-02-03 12:27:59 +01:00
Adam Wight 38122d91cd Remove "follow" special case from ReferencesFormatter
This is unreachable, now that broken follow refs fail validation.

Bug: T240858
Change-Id: I77faeaac4bc53632ab8b82bff7e335ee8c99dfa5
2020-02-03 12:27:57 +01:00
Adam Wight a3d312c8f4 Standardize "follow" validation
Perform the validation in validateRef, and display a new error message for
broken "follow" refs.  This changes existing behavior, where broken folow
ref content is arbitrarily displayed at the top of the references list and
no error is rendered.

Thanks to weasely wording, the new error can later be reused for "extends"
errors.

Bug: T240858
Change-Id: I506e4dcd1151671f5302ecd99581145d979d8124
2020-01-30 17:25:42 +00:00
Thiemo Kreuz 0fda08b25a Remove one unnecessary LogicException from ReferenceStack
This exception was introduced very late in the patch I38c9929. It
already caused trouble. This here is essentially a revert. It restores
the previous behavior where this edge-case was silently ignored. The
worst thing that can happen is that appendText() creates an incomplete
entry in the $this->refs array, which will be rendered at the end. The
user can see it then.

As of now we are not aware of a code path where this would even be
possible. Still this does make the code *more* robust by not making it
explode, but give the user something they can work with.

Bug: T243221
Change-Id: I2e2d29bbd557090981903fcc2ece8796fafa4aa4
2020-01-28 16:15:55 +01:00
Thiemo Kreuz 51d55bb8de Introduce dedicated error message for nested <ref extends=…>
This resolves another TODO. Since this is an intentional limitation in
the design of the feature, I find it pretty signigicant to give it it's
own error message.

Note that the text does not need to be perfect, just good enough for now.
We will review all error messages later via T238188.

Bug: T242141
Change-Id: Id9c863061e855350320131e81f6702c8810736f4
2020-01-23 15:00:26 +01:00
jenkins-bot 84341c3603 Merge "Replace ReferenceStack mocks with actual instances" 2020-01-21 11:16:30 +00:00
jenkins-bot 8700177736 Merge "Use StatusValue::isGood() instead of isOK()" 2020-01-20 16:26:29 +00:00
Thiemo Kreuz 6a4a0fd013 Replace ReferenceStack mocks with actual instances
… if possible. In most cases it's possible to use the real object, and
reach into it's private parts via TestingAccessWrapper. This is almost
the same as using a mock, but I feel it's much more "light-weight".

The main change is that there is no strict assertion any more for the
number of ReferenceStack::pushInvalidRef() calls. Before this was mixed
into the same array as the valid references, as elements set to "false".
I think the test is as valueable as before without this extra check. If
the rollback stack works or not is already covered by other tests.

Change-Id: I90213557b164b3e43233a3dc393ee3f3d3d556a9
2020-01-20 16:31:48 +01:00
Thiemo Kreuz d8651dda81 Clean up mocks and assertions in ErrorReporterTest
For example, there is no need to create a mock in a callback.

Change-Id: I8879b662ac69ba62fe9c0eb86f592493065e24b1
2020-01-20 14:50:30 +01:00
Adam Wight b3ea9f4ef8 Relax empty-string name validation
Allow a ref with `name=""` for backwards-compatibility.
Partially reverts I07738cce2641026dfaa92ba263ed6f9834be0944

Bug: T242437
Change-Id: Iaed2d1c41be377a4961aff39838b0965f6c00616
2020-01-20 12:40:09 +00:00
Thiemo Kreuz b78d85e728 Use StatusValue::isGood() instead of isOK()
The difference between the two is that isOK() only reports "fatals",
while isGood() also reports "warnings" and "errors". I believe we
*want* to report all of these the same way.

Change-Id: I3be832c5db7aba3c03bd2ad8cfbba42362c093fd
2020-01-20 12:35:48 +01:00
jenkins-bot 1ca0905b98 Merge "Fix PHPUnit 8 warning" 2020-01-20 11:06:37 +00:00
Max Semenik 9ecf523eee Fix PHPUnit 8 warning
Bug: T192167
Change-Id: I78ef2aa360e71a5fe214c54807aaa4afbb40c026
2020-01-20 10:33:56 +00:00
jenkins-bot f2cda50778 Merge "Add unit test for section preview regression" 2020-01-20 10:08:43 +00:00
Adam Wight f3031b80b9 Fix for blank-named ref in #tag
A fun edge case where `name=""` fools both validation branches after
a references rollback, and triggered a LogicException.  Stop these
freak refs.

Bug: T242437
Change-Id: I07738cce2641026dfaa92ba263ed6f9834be0944
2020-01-17 11:19:29 +01:00
Thiemo Kreuz ceb3a1ed5f Add unit test for section preview regression
Bug: T242434
Change-Id: I3e87897a1f9f418c4dd72d3137c74340b6646930
2020-01-14 15:10:47 +01:00
jenkins-bot 09f4deede4 Merge "Replace now unused native cloning feature" 2020-01-09 14:13:58 +00:00
jenkins-bot d18fbcffef Merge "Rewrite ReferenceStackTest::provideRollbackRefs for readability" 2020-01-09 12:53:34 +00:00
jenkins-bot 6d02c1569d Merge "Final clean-ups for a more consistent parameter order" 2020-01-09 12:44:55 +00:00
Thiemo Kreuz 013e1bfa90 Final clean-ups for a more consistent parameter order
* Always have an empty line between @param and @return to improve
readability as well as consistency within this codebase (before, both
styles have been used).

* Flip parameter order in validateRefInReferences() for consistency with
the rest of the code.

* In Cite::guardedRef() the Parser was now the 1st parameter. I changed
all related functions the same way to make the code less surprising.

* Same in CiteUnitTest. This is really just the @dataProvider. But I feel
it's still helpful to have the arguments in the same order everywhere, if
possible.

* Add a few strict type hints.

* It seems the preferred style for PHP7 return types is `… ) : string {`
with a space before the `:`. There is currently no PHPCS sniff for this.
However, I think this codebase should be consistent, one way or the other.

Change-Id: I91d232be727afd26ff20526ab4ef63aa5ba6bacf
2020-01-09 12:13:54 +01:00
Thiemo Kreuz d07110b790 Fix incomplete undo/redo stack implementation
The rollback feature was not able to properly restore a __placeholder__.
That's why a specific use case was behaving different. This already
worked just fine:

<ref extends="a">…</ref>
<references>
<ref name="a">…</ref>
</references>

But this didn't, even if it is the exact same from the users
perspective:

<ref extends="a">…</ref>
{{#tag:references|
<ref name="a">…</ref>
}}

Bug: T239810
Change-Id: I163a1bffb9450a9e7f776e32e66fb08d0452cdb9
2020-01-08 17:43:02 +01:00
libraryupgrader 2e0792a0dd build: Updating mediawiki/mediawiki-phan-config to 0.9.0
One of the most significant changes is when I noticed that the $group
can never be null. We set it to DEFAULT_GROUP before. That's an empty
string.

I'm not very happy with the two @phan-suppress-next-line. Is there a
better way to fix these lines?

Change-Id: I33c1681e2f3857cb6701da71f4ed8893caff4d1e
2019-12-27 19:45:17 +00:00
Thiemo Kreuz ed5d72456d Rewrite ReferenceStackTest::provideRollbackRefs for readability
I hope this is more readable. This patch does two things: It uses
array keys to name all elements in the data provider. (Note these
array keys don't actually do anything, PHPUnit ignores them.) And this
patch merges two parameters into a single $expectedResult.

Change-Id: Ib7adc32bf8bfd523735591d35d0bcabd3b853cfc
2019-12-24 14:31:27 +01:00