Commit graph

449 commits

Author SHA1 Message Date
thiemowmde c02595bb97 Drop obscure error message about an unused group
The message was part of the original patch that introduced the group
feature in 2009, see https://phabricator.wikimedia.org/rECIT75004e33.
Notice how there was never a test scenario for this message. A test
was added in 2020 via I07738cc.

The message appears only in a rare edge-case when a group is entirely
unused in the text, and only when the group is not empty. The shortest
possible example is:

 <references group=g>
 <ref group=g name=a>a</ref>
 </references>

Just adding something unrelated like `<ref group=g>x</ref>` to the
text changes the error message. Now the group is "used". But this
notion is confusing to begin with. References can be part of a group,
and we can use references, but we can't use groups as if they are a
separate entity.

A better error message already exists.

Notice how this special error message doesn't appear anywhere in the
Parsoid code path. That was already using the other, more generic
error message.

Bug: T269531
Change-Id: I63f663d76e45e6c3d664f145d9a564ee00ff53cd
2024-03-04 13:04:36 +01:00
thiemowmde e5eee2d049 Fix confusing error message with empty group
This is about the error message that currently says:

 »Cite error: <ref> tag with name "a" defined in <references> has
  group attribute "" which does not appear in prior text.«

This is a special error message that appears only when a group name
does not appear anywhere in the text. In all other cases a simpler
error message is shown:

 »Cite error: <ref> tag with name "a" defined in <references> is
  not used in prior text.«

While the first error message is not wrong in the edge-case
described in T269531, it's very confusing for a multitude of
reasons. For example:
* There is no group attribute in the wikitext.
* Just adding something completely unrelated like `<ref>x</ref>` to
  the text shows the other error message.

The reason for this behavior is that the assumed default is an empty
`group=""`. The error message changes the moment any other <ref> in
the same group appears in the text vs. when the group is entirely
unused.

We can probably remove this error message entirely, but should at
least not use it when there is no group.

Notice how the Parsoid code path was already using the other error
message.

Bug: T269531
Change-Id: Ifa2e97254f4cda72233a057d8760fb1116143552
2024-03-04 12:43:26 +01:00
jenkins-bot 46499cd9c0 Merge "Rename ReferencesFormatter to ReferenceListFormatter" 2024-02-07 18:00:04 +00:00
thiemowmde 7c75d44b8a Rename ReferencesFormatter to ReferenceListFormatter
I always found the name a little ambiguous. The fact that it outputs
an actual HTML list and not just some "references" – whatever that
means – is relevant, in my opinion.

Change-Id: I0d169455c8d2b42d62da4dccb8376c09fb6902bc
2024-02-07 18:20:02 +01:00
thiemowmde 5eea8ebd90 Simplify ErrorReporter PHPUnit test setup
This was slightly overengineered ever since I4b1f890 and slowly became
more and more complicated over time, notably when withConsecutive was
replaced in Icb951b4. Turns out this was never really needed. It's
impossible to get more than one tracking category from this code path.

While we might add more tracking categories later that will most
probably not happen in this code path.

Change-Id: Ie32d17bac8d3518c985b18f83a846c3fb2bd053f
2024-02-01 17:28:44 +01:00
Subramanya Sastry 15f5cc71be Add dummy html/parsoid sections for three failing tests
* This is to worka round some confusing html2html failures in CI
  for these tests (that are not reproducible locally for me).

Change-Id: I07725155ef5e04eb4346a90c34cbacbd70e88ea6
2024-01-26 23:56:41 -06:00
jenkins-bot b4d8b9ccc6 Merge "Enable all Parsoid test modes for citeParserTests.txt" 2024-01-26 23:18:46 +00:00
Subramanya Sastry b3dff81b6d Enable all Parsoid test modes for citeParserTests.txt
* Updated the known failures file.

Depends-On: I093aeed933fe5927e031c879d48e0191e8ef4685
Depends-On: I0df36653de4c70c7a4669b874f43385a18ac5e9d
Depends-On: Id81e2f4331ce73145389e717b7c78f49b29743bf
Depends-On: I7fb86778cfb674ecc76f748786fa08d8f6ac9c65
Change-Id: I101564587dc7959cd620f0b2cc4f8e436bfba6da
2024-01-25 22:11:49 +00:00
jenkins-bot 53bc13024b Merge "Cypress Improvements" 2024-01-25 15:26:54 +00:00
jenkins-bot abb007b133 Merge "Ensure CiteParsoidTest registers our Cite implementation" 2024-01-24 20:33:11 +00:00
C. Scott Ananian 129b222e97 Ensure CiteParsoidTest registers our Cite implementation
These tests pass today because Parsoid is providing an
alternative implementation of Cite, but that means this
test case isn't actually testing the code in this repo.

Bug: T354215
Change-Id: I42521026bab36035ae5eded7c05716234a5a29ea
2024-01-24 20:09:36 +00:00
mareikeheuer 2fac0fca74 Cypress Improvements
General improvements
Ensure proper module loading in Cypress tests to prevent failures by waiting for specific modules to be loaded
Delete the selenium test suite.

Bug: T353436
Change-Id: Ieb71b122d3c6513f1a15d6574967e2bb9c21a393
2024-01-24 12:01:10 +01:00
thiemowmde 80c8eaf3ce Convert (almost) all .css files to .less
Intentionally no other change is made (yet). This is for a later,
separate patch.

Intentionally not touching the huge list of per-language
ext.cite.style.*.css files for the moment. Again, I would prefer to
do this in a separate patch.

Change-Id: I4e392c7bd1c69849a6c7946676a64c749ddbcd60
2024-01-21 15:39:08 +01:00
Umherirrender e3bbe96939 Stop writing to tablesUsed in tests
Bug: T351733
Change-Id: I2d9d7f5358b6d370a904305a0d9e152375a5aaf9
2024-01-20 12:23:34 +01:00
Subramanya Sastry ff699c31aa Sync up Cite repo with Parsoid
This now aligns with Parsoid commit a8db16f33a638931f91ba75d639bb9d661cb979b

Change-Id: Ibd53e38121231a3501dbbfce1c1e1db370740c0b
2024-01-19 12:24:59 -06:00
C. Scott Ananian 234da84418 Hook up Parsoid implementation of Cite
This commit also moves certain parser tests involving <ref> from
the Parsoid repo to citeParserTests.txt in this repo.

Bug: T354215
Change-Id: Ie5b211d2af01a56684473723c68a9ab2775542e3
2024-01-19 11:57:11 -05:00
jenkins-bot cf776d8ce0 Merge "Documenting state of subref reuse rollback" 2024-01-10 12:55:20 +00:00
jenkins-bot 04e1dc66f7 Merge "Move extendsCount into parent ref item" 2024-01-10 11:53:11 +00:00
Adam Wight c36d1b90a5 Move extendsCount into parent ref item
Eliminates a complex shared structure in favor of more encapsulation.

Change-Id: I70efabf0ee263ac578472e16dc35047b0601b7ff
2024-01-10 11:55:16 +01:00
Adam Wight e4b964eec7 Documenting state of subref reuse rollback
Some interesting stuff is happening, seems to have revealed bugs:
* Rolled-back warnings are still present on the ref
* Subref reuse numbering starts at 0 instead of 1, and formatting is cringe.

But subref rollback does seem to work!

Change-Id: If6321b34d27370553ba85e63dd1e2ae6a3b7c099
2024-01-09 18:05:05 +01:00
thiemowmde 9f6dd63ef4 Don't search for [[MediaWiki:cite_link_label_group-]]
Such a message shouldn't exist, and doesn't:
https://global-search.toolforge.org/?q=.&regex=1&namespaces=8&title=Cite+link+label+group-

Additional notes:
* Rename the method to make it more obvious that it's not a cheap
  getter, but doing something slightly more expensive.
* Use more appropriate array_key_exists to check if a cache entry
  already exists.
* Also add a bit more documentation.

Bug: T297430
Bug: T353227
Change-Id: Ia5827bbf6fd700b87a749aac17320796428f0688
2024-01-09 17:00:07 +01:00
Adam Wight 0e01e39061 Encapsulate ref: groupRefs returned as objects
This patch only affects the consumers of groupRefs.

Bug: T353451
Change-Id: I1eff735dbc26dda07aa8ac7af9ea4ddc0906f5a4
2024-01-09 10:22:04 +01:00
Adam Wight f148c65078 Encapsulate ref: pushRef returns an object
This patch affects a few methods which use the output of pushRef.

Bug: T353451
Change-Id: I10b3fe89406c11cdaede92f18a4b96586ecaf5a0
2024-01-09 10:18:57 +01:00
Adam Wight 262fbe24eb Encapsulate ref object: limited to ReferenceStack
This encapsulation gives us field name, type validation and code
documentation.

This patch only affects ReferenceStack and continues to return
approximately the same array outputs to callers.  Some additional
information is included and the placeholder column has a new name.

Bug: T353451
Change-Id: I405fe7ac241f6991fd4c526bfbb58fbc34f2e147
2024-01-09 09:59:16 +01:00
Adam Wight 1434dc5ca6 Switch to a 1-based "count"
The previous patch deprecated the last conditional depending on magic
meanings of 0 and -1, so now we're free to let "count" take on a more
natural meaning: the number of times a footnote mark appears in
article text.

Includes a small hack to avoid changing parser output, by
artificially decrementing the count by one during rendering.  The
hack can be removed and test output updated in a separate patch.

Bug: T353227
Change-Id: I6f76c50357b274ff97321533e52f435798048268
2024-01-08 11:45:36 +01:00
Adam Wight 86edddc8c2 Use semantic field to test ref type
Stop relying on the magic number distinction between "count" = 0 and -1,
by explicitly testing the "name" field instead.

Bug: T353227
Change-Id: I9dce16b01814e19f508d45b927de570049f0e0f5
2024-01-06 16:46:56 +01:00
Arlo Breault fa5100fa92 Sync up Cite repo with Parsoid
This now aligns with Parsoid commit 285e5e390af1c9370203bb3f6111f01fd41d3009

Change-Id: I9311cd580b938d4dabc43f4a659fb49243f22783
2024-01-05 14:30:56 -05:00
jenkins-bot 0071289f79 Merge "Inline constant for "placeholder" key" 2024-01-05 11:53:19 +00:00
jenkins-bot 0f4c90cc54 Merge "Store group in ref items" 2024-01-05 11:53:17 +00:00
jenkins-bot 005f6d9dc6 Merge "More explicit test fixtures: key and count" 2024-01-05 11:53:14 +00:00
jenkins-bot 9b770fba99 Merge "Include more information in missing parent placeholder" 2024-01-05 11:50:06 +00:00
jenkins-bot 1f7d6527a4 Merge "Render list-defined parent without a backlink" 2024-01-05 11:40:37 +00:00
Adam Wight a6cb979d88 Inline constant for "placeholder" key
Minor refactoring of an internal field, which can be treated like the
other columns.

Change-Id: I255578694c5ab9f2ad3cbe232217af3cea60669c
2024-01-05 11:22:30 +00:00
Adam Wight fd648aec98 Store group in ref items
Encapsulate all information about a ref inside of the internal
structure, rather than relying on the container to be organized by
group.

Bug: T353451
Change-Id: I4c91e8089638b7655bf120402a4a5fcbd1b35452
2024-01-05 11:22:12 +00:00
Adam Wight ca6414320f More explicit test fixtures: key and count
These fields get automatic values during normal operation, but we
should make this explicit in tests which meddle with internals.  This
seems to add some clarity, and helps prepare for encapsulation.

Bug: T353451
Change-Id: I8b012a270f16139671f77ea04645d627b2fba87d
2024-01-05 11:21:58 +00:00
Adam Wight 76e6e870d4 Include more information in missing parent placeholder
This allows the subreferences to be collected together under a heading.

Bug: T353451
Change-Id: Ibf28f0baca14de8140c87b03ad4aa86d2f81a20d
2024-01-05 11:21:12 +00:00
Adam Wight 5a69c54900 Render list-defined parent without a backlink
In this case, there was never a ref with this name in the article so
no backlinks should be rendered.

TODO:
* test case with empty parent backlink and LDR parent

Bug: T353451
Change-Id: I8a7abd05a48ce83da3beb92b15e894d53252bd33
2024-01-05 12:07:22 +01:00
thiemowmde b01b420199 Track errors in a status object instead of an array
This is another improvement after I7390b68. Status objects are made
to keep track of multiple errors. The only difference is: The merge
method skips duplicates when the message and all parameters are
identical. This causes a minor user-facing change. One of the
shortest possible examples is:

 <references>
 <ref />
 <ref />
 </references>

This showed two identical, indistinguishable error messages before,
but will only show one now. We argue this is fine. The duplicates
are confusing and of (almost) no value to the user. In case the
information is relevant the correct solution is to make the error
messages distinguishable, or introduce a message like "multiple
<ref> tags defined in <references> have the same error". This is
something for a later patch, if needed.

Bug: T353266
Change-Id: I444105462ed24d5ba37b057622b4dc847b40f8d8
2024-01-05 10:49:08 +01:00
jenkins-bot 23a1a8999d Merge "Remove test for a private method" 2024-01-04 16:30:29 +00:00
Adam Wight ddf5cb2458 Remove test for a private method
Testing internal methods is brittle.  This code path is already
covered by parser test "Valid follow="…" after it's parent"

Bug: T353451
Change-Id: I3b7a4b9962de1f25a7b57f82d80813219d633594
2024-01-04 17:07:36 +01:00
jenkins-bot 733824005a Merge "Drop unused cite_reference(s)_link_prefix messages" 2024-01-04 16:04:34 +00:00
jenkins-bot ab20cb3cdf Merge "Rename appendText() to resolveFollow()" 2024-01-04 15:29:44 +00:00
thiemowmde ddda536792 Drop unused cite_reference(s)_link_prefix messages
Same as Icfa8215 where we removed the …_suffix messages.

This patch is not blocked on anything according to CodeSearch:
https://codesearch.wmcloud.org/search/?q=cite_references%3F_link_prefix

According to GlobalSearch there are 2 usages we need to talk about:
https://global-search.toolforge.org/?q=.&regex=1&namespaces=8&title=Cite.references%3F.link.prefix.*

zh.wiktionary replaces "cite_ref-" with "_ref-", and "cite_note-"
with "_note-", i.e. they did nothing but remove the word "cite". This
happened in 2006, with no explanation.

ka.wikibooks and ka.wikiquote replace "cite_note-" with "_შენიშვნა-",
which translates back to "_note-". One user did this in 2007,
16 seconds apart.

It appears like both are attempts to localize what can be localized,
no matter if it's really necessary or not.
https://zh.wiktionary.org/wiki/Special:Contributions/Shibo77?offset=20060510
https://ka.wikiquote.org/wiki/Special:Contributions/Trulala?offset=20070219
Note how one user experimented with an "a" in some of the edits to
see what effect the change might have, to imediatelly revert it.

The modifications don't really have an effect on anything, except on
the anchors in the resulting <a href="#_ref-5"> and <sup id="_ref-5">
HTML. It might also be briefly visible in the browser's address bar
when such a link is clicked. We can only assume the two users did this
to make the URL appear shorter (?). A discussion apparently never
happened. Bot users are inactive.

Both pieces of HTML are generated in the Cite code. Removing the
messages will change all places the same time. All links will
continue to work. The only possible effect is that hard-coded
weblinks to an individual reference will link to the top of the
article instead. But:
a) This is extremely unlikely to happen. There is no reason to link
   to a reference from outside of the article.
b) Such links are not guaranteed to work anyway as they can break
   for a multitude of other reasons, e.g. the <ref> being renamed,
   removed, or replaced.
c) Even if such a link breaks, it still links to the correct article.

There is also no on-wiki code on zh.wiktionary that would do anything
with the shortened prefix:
https://zh.wiktionary.org/w/index.php?search=insource%3A%2F_%28ref%7Cnote%29-%2F&title=Special%3A%E6%90%9C%E7%B4%A2&profile=advanced&fulltext=1&ns2=1&ns4=1&ns8=1&ns10=1&ns12=1&ns828=1&ns2300=1

I argue this is safe to remove, even without contacting the mentioned
communities first.

Bug: T321217
Change-Id: I160a119710dc35679dbdc2f39ddf453dbd5a5dfa
2024-01-04 13:17:42 +01:00
thiemowmde ca3203699c Capitalized dir="RTL" should not trigger any error
This fixes a minor issue introduced in I294b59f. Two identical
dir="…" with different capitalizations should not be reported as an
error.

Turns out the implementation in the Cite extension doesn't care
about this capitalization at all. That's why I suggest to do the
normalization as early as possible. This is slightly different in
the Parsoid implementation.

Bug: T202593
Change-Id: I96b4a281d6020d61d1f36ec027cf833bbb244f03
2024-01-03 16:30:16 +00:00
jenkins-bot fc5d0bb6a8 Merge "Disable Parsoid-integrated-mode tests for now" 2024-01-02 20:04:15 +00:00
Subramanya Sastry c3b1492d10 Disable Parsoid-integrated-mode tests for now
* Since Cite development happens in two repos (here and the Parsoid
  repo), integrated tests ensures that changes don't fall too far
  out of sync.

  CI runs Parsoid-integrated-mode tests in extensions repo with the
  vendor-released Parsoid.

  Parsoid CI runs Parsoid-standalone-mode tests in the Parsoid repo
  which also has a copy of the citeParserTests.txt file found here.
  But, that CI run uses the Parsoid patch itself.

  This difference makes for unnecessrily laborious test syncing
  while making changes to the two repos. It is manageable for one-off
  changes but when making lots of updates that changes tests a lot,
  this quickly becomes painful.

* For now, we can break this coupling temporarily by disabling
  Parsoid-integrated-mode test runs. This simplifies the test syncing
  by letting patches in Cite repo to be merged in a chain and then
  doing a single test sync to the Parsoid repo (otherwise, Parsoid's
  CI will be broken since the html/php sections in Parsoid's cite
  test copy will be out of date).

* Filed T354215 to move Parsoid's Cite implemntation to this repo
  which eliminates this complexity altogether.

Change-Id: Id5727381b0e23058d098180c308797b2555ad02f
2024-01-02 19:31:52 +00:00
Adam Wight d2b92c5253 Explicit test fixture field names
Bug: T353451
Change-Id: I8a308dd2785939da52a698cf5e63bce4bc228b77
2023-12-22 23:52:22 +01:00
jenkins-bot d8711ce3ed Merge "Show warning when dir="…" don't match" 2023-12-21 21:24:13 +00:00
Adam Wight 5d1335e279 Explicit parameter names for all test fixtures
This is much more readable.  Patch changes nothing.

Bug: T353451
Change-Id: I72b58881a7329dbe98659553b84e53896ccafc2b
2023-12-21 20:59:25 +01:00
Adam Wight e0e8b2dc33 Drop constant parameters
Some tests didn't vary the key parameter, so converting to a
constant.

Change-Id: I9a42352573cc16fec11a799b878c06751eb03fc8
2023-12-21 20:52:43 +01:00