Commit graph

610 commits

Author SHA1 Message Date
Isabelle Hurbain-Palatin d3f85b16c5 Only display the first occurrence of an error
It can happen that an error is reported multiple times for a given
reference. In this case, we only display one.
We still display different errors if a reference contains multiple
different errors. This behaviour is differs from the legacy parser's
(so, in this case, we add the category
cite-tracking-category-cite-diffing-error), but not from the legacy
parser's desired behaviour, as hinted by the various comments and TODO
in this area.

Bug: T380153
Change-Id: I9b3d5cbd086fc72c66a2afbae8f92297681989ce
2024-11-18 13:54:56 +01:00
C. Scott Ananian a5aeba739e Resolve PhanTypeMismatchArgumentNullable after tweak to StatusValue::newFatal
The type hints added in I3e0df790ff9db2fa630f82408a7254a359fe61ca
were sufficient to allow phan to detect that we were possibly passing
a null value in one instance.  The other instance was a false positive.

Follows-Up: I3e0df790ff9db2fa630f82408a7254a359fe61ca
Change-Id: I3bacc2aff3d36719133554a8f70d50a3790b84e4
2024-11-15 14:25:10 -05:00
jenkins-bot 1fa7271beb Merge "Use DOMCompat::getFirstElementChild() now that it is available from Parsoid" 2024-11-14 11:05:15 +00:00
jenkins-bot 6c92ce560b Merge "Remove redundant embedded attr processor" 2024-11-12 17:30:37 +00:00
Arlo Breault 20a1448e59 Remove redundant embedded attr processor
Use the standard one defined for processAttributeEmbeddedHTML by these
extension tags.

Change-Id: I47a713a8536ddc57a32842afcd40f36854533ab4
2024-11-11 20:17:21 -05:00
C. Scott Ananian 87d4d23737 Use DOMCompat::getFirstElementChild() now that it is available from Parsoid
There is only one child, so first/last element child are the same, but
it's a little less confusing to use 'first' here.

Follows-Up: Ifeb3b216e898bec1c3eb5917262820c5809fda45
Depends-On: I753bbbfaf99fb486384b0fa97de71159abb504b3
Change-Id: I65873c117cbd3e1d6efd82797c7b49bf707f5c3a
2024-11-11 17:29:50 +00:00
Isabelle Hurbain-Palatin dd6587c426 Display Cite error messages in Parsoid
Bug: T372709
Depends-On: Ieed7b5a18f5223c7b8a2918df88790d4dc305f9d
Change-Id: Ifeb3b216e898bec1c3eb5917262820c5809fda45
2024-11-07 13:42:55 +01:00
Adam Wight e4e6b59306 No-op wiring to get ref "extends" into Parsoid
This doesn't change behavior yet, it's pure wiring to make the
attribute available to Parsoid logic.

Bug: T378567
Change-Id: I6182b601f6fee66a9c32d5006d0a36150eb47e7f
2024-10-31 13:20:02 +01:00
Adam Wight 373ed01123 Parsoid wiring for footnote mark formatting
After this patch, Parsoid-rendered pages will include the same
footnote markers as the legacy parser for custom group markers.

The divergent CSS implementation is left intact, for a soft migration.

Bug: T377454
Change-Id: I576dfff4155fb8c2f91ef0d28a65b319aa5bbb07
2024-10-31 11:16:49 +00:00
Adam Wight 60fbb32c1a Split apart mark formatting into a simpler labeler
The new mark label renderer is a service and can be called from
Parsoid.

Bug: T377454
Change-Id: I6f4983c4288bf29954ad4e5fa3309f9bdf48215d
2024-10-31 11:16:13 +00:00
jenkins-bot 141b18277d Merge "Expose the footnote mark formatter label method" 2024-10-31 10:41:52 +00:00
Adam Wight 87d1229bf2 Expose the footnote mark formatter label method
Behavior change: previously, an error would be rendered once the
custom markers run out. After this patch there is a graceful fallback
to default group rendering (eg. "lower-greek 1000").
This is a slight improvement, but is user-facing so should be
discussed before merging.

In future work we'll render custom marks programmatically so this edge
case would be unreachable, and since the error message only exists to
nudge editors to extend the custom group symbol sequence, this would
also become wasted effort.

This patch splits out a lower-level method which produces the bare
mark label, with no link or wikitext formatting.  The patch narrows
and simplifies the interface so that the method can be made available
to Parsoid, and will be converted to a service in a separate patch.

Bug: T377454
Change-Id: I719b60b46cdef0be7463d76e9125d75ab4f333ae
2024-10-30 12:14:10 +01:00
Umherirrender ebd526f2af Split isset() check for array and property
Check the array part first and afterwards the property for null,
which does not need the isset() error suppression.

Found by a new phan plugin (2efea9f989)
This bypass a false positive from phan (T378284)

Change-Id: I08651c4b2cd03ecfb38d28ca1cbff599d922208a
2024-10-28 19:31:58 +01:00
Umherirrender 875b747d3c Replace isset() with null check
isset() should only be used to suppress errors, not for null check.
When the variable is always defined, there is no need to use isset.
Found by a new phan plugin (2efea9f989)
https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#isset

Change-Id: I2eee98fdcb21192108183c431b10e0072b951f72
2024-10-27 14:36:26 +01:00
Andre Klapper 41bafe6f2c Use explicit nullable type on parameter arguments (for PHP 8.4)
Implicitly marking parameter $... as nullable is deprecated in PHP
8.4. The explicit nullable type must be used instead.

Bug: T376276
Change-Id: I73a4ce1ecd9b4fe040e5bfd22889e783071fab0d
2024-10-26 14:56:31 +02:00
Umherirrender 411ee7efad Use namespaced classes
Changes to the use statements done automatically via script

Change-Id: I0768f296b528c81edd6bd9ac7d76515b15f3da6f
2024-10-19 23:25:16 +02:00
jenkins-bot 160b0d05d8 Merge "Use - instead of _ in LESS file names as language code" 2024-10-07 13:06:40 +00:00
jenkins-bot ebf38366e7 Merge "Rename internal BOOK_REF_ATTRIBUTE constant" 2024-10-07 12:02:13 +00:00
jenkins-bot e31bfa9845 Merge "Use DataMwError" 2024-10-04 23:08:07 +00:00
jenkins-bot 8f60a489bd Merge "Inject MainConfig services into Cite" 2024-10-04 19:34:11 +00:00
Fomafix 656b00134e Use - instead of _ in LESS file names as language code
Change-Id: Ifcd6d8f927a651d13e8a01ac3995210292551bc8
2024-10-04 08:25:49 +00:00
thiemowmde 0ed6cafb3b Use more narrow UserIdentity interface where possible
Change-Id: I766eaa904a9eaeb7ac2a32a98289a364b1c25355
2024-10-02 12:56:28 +02:00
C. Scott Ananian 87d747a54d Use DataMwError
Depends-On: I63f48887690ea916c4e54b4a1a703f301dd64b6a
Depends-On: I63ca14ad4d5b2cdbce2fd61c4d6eb544b634bc8d
Followup-To: I14930937c1beca039484cffd19e486cd06cbc124
Change-Id: Ic8ee0a7c9ba50e19baf06e21251f8f7710110051
2024-10-01 22:49:52 +00:00
Fomafix 521f44ede5 Inject MainConfig services into Cite
Change-Id: I24cc3e4965d4a9fe41dcd799dac4cbce762fb068
2024-09-28 22:01:09 +00:00
jenkins-bot 3b197da578 Merge "Use dependency injection for References/RefProcessor" 2024-09-25 17:18:42 +00:00
jenkins-bot 3beada9643 Merge "Move Reference Previews user preference into the Cite extension" 2024-09-23 10:47:16 +00:00
Isabelle Hurbain-Palatin 3a9ba45a7d Converts errors in data-mw to objects
Change-Id: I14930937c1beca039484cffd19e486cd06cbc124
2024-09-20 18:01:45 +02:00
C. Scott Ananian 7df30e0651 Use dependency injection for References/RefProcessor
This avoids the use of Parsoid's SiteConfig::getMWConfigValue() method,
which is unnecessary when the extension has direct access to MediaWiki
services itself.

This also fixes the omission of CiteResponsiveReferencesThreshold from
the extension.json.

Change-Id: I01b43136b0827f185523f1318253372b09750de4
2024-09-12 11:57:28 -04:00
Adam Wight c7b60735fe Move Reference Previews user preference into the Cite extension
This seems to play well with Popups with and without
Ie8fa1672b9fd .  However, it's not clear to me why this still works
and even gives priority to the Popups implementation when present,
regardless of the order the extensions are loaded in.  Happily, this
is the desired behavior.

Bug: T363162
Change-Id: Ic479c0a381ee16d1abcecfdd5ee48f0afccc1d3f
2024-09-10 15:33:50 +02:00
Adam Wight 8e4c83bfc6 [refactor] Rewrite context as service
Puts the ReferencePreviewsContext behind a service to improve
testability.

Bug: T363162
Change-Id: I63aa4144081a2625da1b89f4d56adb612741c8fc
2024-09-06 16:26:20 +02:00
thiemowmde e8fd6c093f Rename internal BOOK_REF_ATTRIBUTE constant
This has no user-facing consequences. The constant can be renamed any
time again, if needed. It's not used anywhere else:
https://codesearch.wmcloud.org/search/?q=BOOK_REF_ATTRIBUTE

Bug: T373307
Change-Id: Ia4d588e926bb6e75f96048f2d3782c0f23ece514
2024-09-03 09:45:46 +02:00
jenkins-bot 1116cfb9a9 Merge "Allow disabling the alternative backlink labels message" 2024-09-02 19:34:57 +00:00
jenkins-bot 6e6a7ebf2a Merge "Add parameters to Cite error messages in Parsoid" 2024-08-27 11:51:56 +00:00
Isabelle Hurbain-Palatin 3774c86a64 Add parameters to Cite error messages in Parsoid
The Parsoid error messages are missing a couple of parameters, according
to the json i18n files; this patch fixes that issue.

Change-Id: I4232c0b71ecc6d6f1220db3988e67d9cd4eb3d58
2024-08-27 12:01:30 +02:00
jenkins-bot 56ccdd0e48 Merge "Move existing ReferenceListFormatter code closer together" 2024-08-27 09:40:50 +00:00
jenkins-bot 9fb20ec09a Merge "Remove not needed int type from ReferenceListFormatter" 2024-08-27 09:37:49 +00:00
Subramanya Sastry b3af8fdcfd Parsoid: Add newline after every reference list item
Updated known failures to include the new output for previously
failing tests.

Bug: T372889
Change-Id: I32b2a7cff144d74f646962bb28a83180e5446798
2024-08-23 14:31:33 +00:00
thiemowmde b223649f9d Move existing ReferenceListFormatter code closer together
This moves existing code around a little bit without changing
anything, as proven by the tests.

This is motivated by Iaca0e14.

Change-Id: I30366d32b07f87f238b045f0d7817686b5cc26bd
2024-08-13 12:42:02 +00:00
thiemowmde a4ffedbcc2 Remove not needed int type from ReferenceListFormatter
It's always a string anyway. Also improve the test coverage. The
localization was pretty much untested before.

Change-Id: Ie6f34c67ae7dd9559346eb45a2604e14c5633991
2024-08-13 10:46:52 +02:00
thiemowmde d885a0c6b5 Allow disabling the alternative backlink labels message
The message cite_references_link_many_format_backlink_labels contains
e.g. "a b c …" and so on, to be used as alternative backlink labels
when a single reference is re-used multiple times. The default numeric
rendering is "1.1 1.2 …" and so on.

The two labels end in the message cite_references_link_many_format as
parameters $2 and $3. But only one of the two parameters is ever used.
By default the alternative label in $3 is unused.

This implies that everything about these alternative backlink labels
including the error message is effectively dead code most of the time,
never to be seen on the majority of wikis.

This change makes it possible to disable the message without breaking
anything. Instead the code will silently fallback to the default
behavior of showing the numeric label. This is much more efficient
than rendering possibly hundreds of error messages that never show
up anyhere. The same optimization is already done for the extremely
similar cite_link_label_group-… messages, see
FootnoteMarkFormatter::fetchCustomizedLinkLabel.

This is also partly motivated by T335129 as well as T321217.

Change-Id: Iab818d7db7eddaf7091234f6a22a18cdff70f8e8
2024-08-12 13:36:20 +02:00
thiemowmde fb8494b4dd Relax support for error/warning message keys with dashes
This is a direct follow up for I6f05842 where we already started
supporting dashes, but converted them to underscores. The only change
in this patch is that the CSS class will use the message key as it
is, without the dashes being converted to underscores. I added a test
case specifically for this.

Bug: T352676
Change-Id: Ic22e897c27b8371e3b1ed63932b619e7af71bd5c
2024-08-09 12:29:34 +00:00
jenkins-bot ae776a32ce Merge "Rename ReferencePreviews i18n keys from Popups" 2024-07-18 12:16:10 +00:00
WMDE-Fisch c87e6046ff Rename ReferencePreviews i18n keys from Popups
Final step to get the i18n key names align with this extension.

Note that the few community overrides should have a copy of the
keys we're changing here in place so the overrides work for both
variants as long as the deployment is not finished.

Bug: T363156
Change-Id: Idf098d2cb04e8f02247b78e6b4866338eaf02b44
2024-07-18 11:47:14 +00:00
thiemowmde 6dc56deebd Rename all remaining .css files to .less
Change-Id: Ib41cad1e14243577c0a78becb2bc5cb6a50afa5d
2024-07-15 21:59:02 +02:00
Adam Wight 08969af51c Make content language data available to VE
We have a use case in which the client needs to be able to use
language utilities in the content language (footnote markers), so the
data must be wired through.  This will only be done in VE, and in the
special case that the interface language != the content language.

Bug: T369613
Change-Id: I2c10e1e36ba594da98e0efa433dd9e1a25aae6fe
2024-07-10 13:41:31 +02:00
thiemowmde 36f4ab138d Split FootnoteMarkFormatter code into logical pieces
This is motivated by T367749 where we probably need this code to be
separated. This minor refactoring just moves existing code around
without changing anything. The idea is just to make the concepts more
visible in the code.

Bug: T367749
Change-Id: I765d19fa9cb43a6f8492b707a7ae46ddffe43897
2024-07-07 14:14:39 +00:00
thiemowmde 1aeac001fe Additional parser test cases for delayed extends usage
We want it to be possible to turn a <ref> into an extended one after
it was re-used for the first time, not knowing if it later turns out
to be an extended ref.

This should work: <ref name=x/> is a short re-use of a ref that later
turns out to be a <ref extends=… name=x>…</ref>.

<ref name=x></ref> is just another syntax that should behave
identical.

However, it should probably not be possible to turn
<ref name=x>foo</ref> into a subref later because it really, really
looks like a normal ref. Even if the content matches with a later
<ref extends=… name=x>foo</ref> and we usually ignore identical
content, I suggest to block this with a dedicated error message. But
this is for a later patch. This patch here just documents the status
quo.

This patch also contains minor code cleanups that will be useful in
Ia752a7d.

Bug: T367749
Change-Id: Ie38769b36e5c476b96e7af7f03b0fc800b32ba97
2024-07-05 13:08:23 +02:00
thiemowmde ec9c8bda00 Use slightly narrower interfaces in a few places
The idea is to make the code less ambiguous and easier to predict.
We passed the same information around two times in a few places.

Change-Id: I39c7a2962bb70bbe40074986e63b1051d0766ea2
2024-06-24 08:07:19 +00:00
Umherirrender 3de8f65114 Use namespaced classes
Changes to the use statements done automatically via script

Change-Id: I4b49c4ab87f1fcd5cdf29d5f882dec3c3902e146
2024-06-08 23:31:42 +02:00
jenkins-bot 0dedffacd3 Merge "A few tiny code cleanups in the ReferenceStack class" 2024-06-07 03:06:56 +00:00