Commit graph

4621 commits

Author SHA1 Message Date
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
Adam Wight 12cd4b979e Test explicitly for parent ref existence
This test was obscured by testing for a field on the parent, but that
would exist if and only if the parent also existed.  Clarify the
guard condition and introduce a named local variable for the parent.

Change-Id: I03079f45cf5ba00d54642c89ac4232a944b2f353
2024-01-09 17:30:10 +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 89099e93d6 Rename internal variables
We can be more specific than "value".

Bug: T353451
Change-Id: I8f958a04d7fb6f5a0f10f3c3974b38257ab86f16
2024-01-09 09:53:21 +00: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 c23b824c34 Reorder conditions
The placeholder field will only be set if the ref exists, so we can
put these in a more logical order.

Change-Id: I2ddfb501fcc3aca936bb45c0d40e4f68c5d2b192
2024-01-09 09:57:03 +01:00
Translation updater bot 137cbb43c0 Localisation updates from https://translatewiki.net.
Change-Id: I55f1d43581b14cef496265c52e4ad1a9e8168754
2024-01-09 08:59:05 +01:00
jenkins-bot e06b2347b2 Merge "Switch to a 1-based "count"" 2024-01-08 11:33:53 +00: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
jenkins-bot e2a771f344 Merge "Localisation updates from https://translatewiki.net." 2024-01-08 10:08:48 +00:00
Translation updater bot 9f52baf53a Localisation updates from https://translatewiki.net.
Change-Id: Ifba3a49ef2b9dbaf3f5ba7ccd0c57c46ea51185c
2024-01-08 09:14:48 +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
Adam Wight 6b0ebb3066 Reduce deeply nested variables
These can be hard to read so this patch introduces named, temporary
variables.

PHP reference assignment is helpful here, and has the nice property
of responding correctly to `isset` as if it were called on the
referenced variable.  However, we're prevented from using this trick
in more places in the code because of an unfortunate side-effect that
PHP will store `null` under the referenced array key.  In some cases
(the ones here), this is harmless because we always test using
`isset` and null behaves the same as an unset value.  In other cases
such as arrays that are iterated over, the spurious key and null
value would be more of a nuisance.

Bug: T353227
Change-Id: Ie43592a2f10677ba19842e92fa29eb4bf3be240c
2024-01-06 16:39:46 +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 4d14f9c701 Merge "Merge two code paths about <references> sections" 2024-01-04 16:06:06 +00: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
jenkins-bot be755491cc Merge "Capitalized dir="RTL" should not trigger any error" 2024-01-04 11:14:47 +00: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 533869a8de Merge "Use 'html' instead of 'text' on headings in WikiEditor toolbar config" 2024-01-03 12:46:31 +00:00
Translation updater bot 086f5af8f8 Localisation updates from https://translatewiki.net.
Change-Id: I26541cfb187ee00cfee76e74d57ef702adcd8fed
2024-01-03 08:34:14 +01:00
thiemowmde 8b86a4adac Give a different error from too_many_keys when 'follow' attribute conflicts
* Same as Ie64f4ab in the Cite codebase.
* Mark the changed tests as standalone since this Parsoid code isn't yet
  released to vendor and integrated tests run with vendor.

Bug: T299280
Depends-On: Ie64f4ab4831966f66f812ea67cc244718f818afb
Change-Id: I0ea1bc3f57576d215ba4060a0e886e588ffda0b3
2024-01-02 21:27:56 +00:00
Ed Sanders 71c52196f0 Document generated CSS classes
Change-Id: Id4bc9bfbffb278372f2e234861ad521db6d43643
2024-01-02 21:05:40 +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
Translation updater bot 07d75d4ebe Localisation updates from https://translatewiki.net.
Change-Id: Ie77f4c3e4e29cb1a67e40438443d4ad560404d7b
2024-01-02 08:48:22 +01:00
Translation updater bot 33217226a9 Localisation updates from https://translatewiki.net.
Change-Id: I9b32aeb2d9254587acb643c4c5d69261db63367e
2023-12-29 19:21:37 +01:00
Translation updater bot 052f579470 Localisation updates from https://translatewiki.net.
Change-Id: Ia47a8b1a370fab9012ba9df353ca54ddb385c115
2023-12-28 14:49:33 +01:00
Translation updater bot 81502b4294 Localisation updates from https://translatewiki.net.
Change-Id: I540883ba46e78aaf77d20714bb3975ede2d676c3
2023-12-26 14:42:33 +01:00
Adam Wight d2b92c5253 Explicit test fixture field names
Bug: T353451
Change-Id: I8a308dd2785939da52a698cf5e63bce4bc228b77
2023-12-22 23:52:22 +01:00
Translation updater bot 12c414f4c4 Localisation updates from https://translatewiki.net.
Change-Id: Iaab9324e298b755d96678ac8868cbd98fc9d82f8
2023-12-22 17:45:28 +01:00
Fomafix 184fc92c3f Use 'html' instead of 'text' on headings in WikiEditor toolbar config
WikiEditor also uses 'html' instead of 'text' on headings. At the
moment both keys have the same behavior, but the original intended idea
is to have 'html' as already valid HTML (like on .parse()) and 'text'
on plain text which has to be escaped.

Change-Id: I1b4035a86ed56bfeb12d33b463d67099f7ae40e3
2023-12-22 13:29:39 +00: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