Commit graph

3265 commits

Author SHA1 Message Date
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
jenkins-bot 8105f64740 Merge "Localisation updates from https://translatewiki.net." 2020-01-28 07:29:12 +00:00
Translation updater bot ebf2558f90 Localisation updates from https://translatewiki.net.
Change-Id: If803b51ecc244650221dfa0f1af2019d3d09356d
2020-01-28 08:24:50 +01:00
libraryupgrader 691746576b build: Updating jakub-onderka/php-console-highlighter to 0.4.0
Change-Id: I8bb60a80550a52117bfd5330422667fddf0b42d4
2020-01-28 06:56:20 +00:00
Raymond cb85569d1f Remove unneeded nowiki
[[MediaWiki:...]] are rendered as normal wikilinks. I see no need to
wrap them by <nowiki>.

Change-Id: I5688ad18bfeffad68de88e85947343c74c9150b3
2020-01-25 17:16:51 +01:00
jenkins-bot 3c8a225052 Merge "Fix incomplete rollback producing bad footnote numbers" 2020-01-24 15:11:31 +00:00
Thiemo Kreuz 2ddc6f133b Fix incomplete rollback producing bad footnote numbers
Bug: T48140
Change-Id: I53ce5d8488d4c24d6f23f6f0e70806d7db4064e1
2020-01-24 13:02:53 +01:00
Thiemo Kreuz 816b1b0add Remove newline characters from all error messages
These create bogus output, depending on the surrounding wikitext the
<ref> tag is used in. For example, this example wikitext:

* Example.<ref name="1">a</ref> More text.

… will be rendered with the "More text" sentence wrapped on the next
line, outside of the list. However, this does *not* happen in many of
the localizations, e.g. German, because many Tanslatewiki translators
did not copied the bogus \n. Why should they.

TL;DR: These newline characters either do nothing, or destroy the output.
In both cases the proper fix is to replace them with spaces.

Some of the test cases touched in this patch demonstrate the issue.

Change-Id: I395a40637a5293eda1f477963d252ce1a215f8b2
2020-01-24 12:29:14 +01:00
jenkins-bot 6ad54f0d63 Merge "Introduce dedicated error message for nested <ref extends=…>" 2020-01-24 10:58:01 +00:00
Adam Wight fe7356622e Extract backlink formatting into a function
No-op, prepare for reusing this code in subreferences.

Bug: T243278
Change-Id: I8ad9778b0fecd462ff18eccbe86885dd6fc21c76
2020-01-24 09:03:17 +00:00
Translation updater bot 647987b129 Localisation updates from https://translatewiki.net.
Change-Id: Ie5cf2c2784dec1dd255c894aa0c93245d9442fce
2020-01-24 08:14:57 +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
Thiemo Kreuz 6cb84a1829 Remove TODOs and FIXMEs that we are not going to fix
Change-Id: I588d9e8f74247adcb26ecdc14b49cf8056291a2e
2020-01-23 07:27:27 +00:00
Translation updater bot 832a7ff9b8 Localisation updates from https://translatewiki.net.
Change-Id: I4ef7e3bcb801761d4aa9d840d683d24452d93d7b
2020-01-22 08:29:41 +01:00
jenkins-bot 84341c3603 Merge "Replace ReferenceStack mocks with actual instances" 2020-01-21 11:16:30 +00:00
jenkins-bot 7057c48e27 Merge "Simplify initialization in ReferenceStack::pushRef" 2020-01-21 10:59:23 +00:00
jenkins-bot cf000508a9 Merge "Resolve a TODO by covering it with a test case" 2020-01-21 10:27:46 +00:00
Thiemo Kreuz 9565d6e887 Resolve a TODO by covering it with a test case
It turns out this is indeed necessary. The test demonstrates why.

Change-Id: Id9c6a48f72ef8d3f0cc9a714d826418e69913b0a
2020-01-21 10:11:03 +00:00
Thiemo Kreuz 2da4305cd9 Simplify initialization in ReferenceStack::pushRef
Change-Id: I52b0f891e41a0d0b25ac0aade0d4f4fcc4dcd2f2
2020-01-21 08:22:24 +01:00
Translation updater bot b62d6e6fd4 Localisation updates from https://translatewiki.net.
Change-Id: If4269f4cc52b21fd7d315c1c0d5de3ad7c82332a
2020-01-21 08:15:50 +01:00
jenkins-bot e343af3408 Merge "Reduce some nesting in Cite::guardedRef()" 2020-01-20 16:28:55 +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
jenkins-bot 258b23a6dd Merge "Error when reusing <ref> with conflicting "extends" attributes" 2020-01-20 13:49:41 +00:00
Adam Wight 8a58ed55dc Error when reusing <ref> with conflicting "extends" attributes
"Conflicting" here includes the case where one of two <ref> with the
same name does not have an extends attribute. The first occurence of
a name specifies if a <ref> is a top-level or a sub-reference. This can
not be changed later.

This patch changes multiple existing test cases. I checked all of them
in detail and confirmed the behavior is fine. The error reporting is
better or at least equally good in all cases.

Bug: T242141
Change-Id: Iaec306eefe5b168d496990105e297ca044a5e721
2020-01-20 13:33:52 +00: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 f352609816 Reduce some nesting in Cite::guardedRef()
The goal of this patch is to not change any behavior, just make the
code less nested and less complicated.

Change-Id: I89170960ffbf61f57e245adf097f3e8d8196bbce
2020-01-20 12:36:34 +01: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
jenkins-bot 74bc00fcd7 Merge "Fix all remaining PHPCS issues" 2020-01-20 11:06:34 +00:00
Max Semenik 9ecf523eee Fix PHPUnit 8 warning
Bug: T192167
Change-Id: I78ef2aa360e71a5fe214c54807aaa4afbb40c026
2020-01-20 10:33:56 +00:00
Thiemo Kreuz 6472bdb369 Fix all remaining PHPCS issues
Change-Id: I977a9f2efc5d95692341b17c6c2f41b7446d13e2
2020-01-20 11:13:47 +01:00
jenkins-bot f2cda50778 Merge "Add unit test for section preview regression" 2020-01-20 10:08:43 +00:00
Translation updater bot e555485825 Localisation updates from https://translatewiki.net.
Change-Id: I60e6144fe1fc1a080e453245f968324422c10e1b
2020-01-20 08:48:30 +01:00
Arlo Breault 7e2bbae4c2 Sync up with Parsoid citeParserTests.txt
This now aligns with Parsoid commit 0a6c576ad6ccfc81c2bfa20757417c62e554ef56

Change-Id: Ifa5d60e362e5c530d12d3b94351aef2d1b1962cc
2020-01-17 14:51:03 -05: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
jenkins-bot d6e97547c1 Merge "Remove misleading version number 1.0.0" 2020-01-17 08:52:36 +00:00
jenkins-bot 385eb42bab Merge "Fix for nested #tag:references" 2020-01-17 08:43:51 +00:00
Adam Wight 1c947a808d Fix for nested #tag:references
It's possible to nest <references> by using tricky constructs like the
{{#tag function, and this breaks our rollback logic.  Try to show normal
output, otherwise show an error.

Includes regression tests.

Bug: T242437
Change-Id: I33e497cdf8508ce7ccb7f0f315c00af5eee47d0e
2020-01-15 12:44:29 +01:00
Translation updater bot 2691237121 Localisation updates from https://translatewiki.net.
Change-Id: I5b4f429de277f3f629a497527a043b0b64e591ad
2020-01-15 09:53:22 +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 41a1859e90 Merge "Don't fail with a LogicException during section preview" 2020-01-14 08:08:29 +00:00
libraryupgrader 812df4820a build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch

Additional changes:
* Also sorted "composer fix" command to run phpcbf last.

Change-Id: I148ec7fca3d53bddc2dc5abbcc1c229461feea33
2020-01-14 04:06:09 +00:00
Thiemo Kreuz 42fd0cef58 Don't fail with a LogicException during section preview
This error happens only when previewing an edit, because some of the
validation in Cite::validateRefInReferences() is disabled in preview
mode. Unfortunately this codebase was never properly tested in preview
mode.

This patch is intentionally so small to make it easy to backport.
Tests will follow.

Bug: T242434
Change-Id: I5e529b7227598ab2acc624c90a0cb5d09b3f5452
2020-01-13 14:19:08 +01:00
Translation updater bot 25a13e0e69 Localisation updates from https://translatewiki.net.
Change-Id: I1c6364e9d38f8b1ed0e1d0767b8175319bc3d83d
2020-01-13 09:09:49 +01:00
Thiemo Kreuz bcbc356c14 Remove misleading version number 1.0.0
I would like to argue that calling the current state of this codebase
"version 1.0.0" is plain wrong. A more meaningful version number can
easily be introduced later if one is needed.

Bug: T213066
Change-Id: I4854263592784feb072acea2d9efe99f1f04ab28
2020-01-10 21:31:38 +01:00
Translation updater bot 81f676e35f Localisation updates from https://translatewiki.net.
Change-Id: I338684fcfcd5827a957ce40dc340ad51e56c5ed6
2020-01-10 08:34:04 +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