Commit graph

125 commits

Author SHA1 Message Date
Adam Wight 5ac57def59 refArg parses and returns the refines attribute
Incremental patch which extracts the refines attribute from the tag.
Doing this now to allow the calling function to have responsibility
for doing something with the attribute value.

Bug: T237531
Change-Id: I59bb409bedd8e6ed06268e705e02e8ffb45b1f0e
2019-11-08 12:30:12 +01:00
Thiemo Kreuz 1a371ec6a5 Extract all hook handler functions to small glue classes
As of now, this patch does not touch the existing code. However, the
goal is to remove a lot of the related code from the Cite class. This
will be done in later patches. This here is a separate patch to make
reviewing the later patches much easier.

The existing parser tests should be proof enough this chain of patches
is not changing any behavior.

Change-Id: I27ae972f81071bb4036bd452560768fae409417b
2019-11-07 09:45:32 +01:00
Thiemo Kreuz f590379a64 Fix incomplete @param PHPDoc
Change-Id: I3b17178737cc42e8519a60a2ae2f7cca6ac6ccb3
2019-11-05 14:19:57 +00:00
WMDE-Fisch e3ef0e3a0d Consistently name the variable for the content
Renaming to $text since this is also already used in the array structure
to store the references and seems more intuitive than $str

Change-Id: I4dbe5d10ddc355b4587d195b50cf078ac01fac55
2019-11-05 10:04:49 +00:00
jenkins-bot 250f7e9973 Merge "Remove not needed and collapse overly complicated code" 2019-11-04 17:03:08 +00:00
Thiemo Kreuz a4b9302d88 Remove not needed and collapse overly complicated code
Change-Id: Iee4241245280b23ab2aaf452363e7db3e21f5554
2019-11-04 16:04:42 +01:00
Thiemo Kreuz 5397919857 Remove obsolete comments
Change-Id: I66246a4d4978e070d45def38ff5b6300f6057eb3
2019-11-04 16:03:33 +01:00
jenkins-bot 4ae083fe72 Merge "Extract handling of guardedRef inside reference tags" 2019-11-04 12:29:13 +00:00
jenkins-bot e006e9682c Merge "Elaborate comment on invalid keys" 2019-11-03 10:35:30 +00:00
WMDE-Fisch e2a98505d1 Fix PHPdoc for Cite::stack()
The text could be null if we're stacking a re-used reference there.
Also content is a more precise word for what was forwarded here.

Change-Id: Ic78fb4744314c40360a61c21e92462b6eb2ae1ab
2019-11-01 16:26:56 +01:00
WMDE-Fisch 2ddae75d95 Elaborate comment on invalid keys
Change-Id: If8e800d69d4ff01ff6c9471e5324c7184e74c136
2019-11-01 15:43:47 +01:00
WMDE-Fisch 85fe486e6a Extract handling of guardedRef inside reference tags
This is just simply moving the code to make the structure more clear.

Change-Id: I680047237458dcfe539525fbb826602d683facc9
2019-11-01 15:41:00 +01:00
jenkins-bot 87a2bf4bdb Merge "Move unrelated static code to ApiQueryReferences" 2019-10-25 13:01:12 +00:00
Thiemo Kreuz ed8dee9bfe Move unrelated static code to ApiQueryReferences
I tried to avoid unrelated refactorings. The only thing I ended doing
is turning a huge if-else around into a guard-clause.

Main motivation here is:
* Make the huge, almost 2000 line Cite class smaller.
* Turn public code into private implementation details.

Bug: T236260
Change-Id: Ifca28040ae60d021a31aaee65417c7584627a975
2019-10-25 10:26:37 +00:00
jenkins-bot 2012944930 Merge "Move misplaced ParserFirstCallInit hook handler to CiteHooks" 2019-10-25 09:02:17 +00:00
jenkins-bot d67684dfe0 Merge "Make use of PHP7's ?? feature instead of isset()" 2019-10-25 08:52:51 +00:00
Thiemo Kreuz 28dd373d24 Move misplaced ParserFirstCallInit hook handler to CiteHooks
All other hook handlers are in the dedicated CiteHooks class.

Main motivation here is to make the huge Cite class smaller,
especially by removing static code that does not rely on anything
else the class does.

Bug: T236260
Change-Id: If0b3f6c989e44283428cda4b2c4d8d5303385d22
2019-10-25 10:34:35 +02:00
jenkins-bot f62736c58c Merge "Simplify private listToText() implementation" 2019-10-25 08:32:49 +00:00
jenkins-bot 714996d72a Merge "Fix capitalization mismatch in class name" 2019-10-25 08:28:40 +00:00
Thiemo Kreuz ddafb6adee Make use of PHP7's ?? feature instead of isset()
Main motivation here is to make the code shorter and faster to read.

Bug: T236260
Change-Id: Ieddc0fe8a292f8f46e9f011a588946dcd063d53d
2019-10-25 10:19:08 +02:00
Thiemo Kreuz 7f99a1bfe1 Simplify private listToText() implementation
Motivation is to make the code shorter and faster to read, and also
perform better.

Bug: T236260
Change-Id: I9186370a628833c1563eb5fa4f2e062fb27d6ed7
2019-10-25 10:17:05 +02:00
Thiemo Kreuz 5acc1e5a2d Fix capitalization mismatch in class name
Change-Id: Id0f9331aecc8b26f4df78839cd43818c4221a5ff
2019-10-25 10:15:53 +02:00
Thiemo Kreuz b65e1bb238 Make use of ctype_digit() instead of a regex
Relevant edge-cases:
* ctype_digit() only works on strings. Anything else, including
integers, will make it return false.
* The empty string will return false.

Both is identical to what the code did before.

Motivation for this change is to streamline the code, and make it
smaller and faster to read.

Bug: T236260
Change-Id: I2d209347d16f2bde14b345c3f88ec64b081283cb
2019-10-25 10:12:39 +02:00
jenkins-bot 88266ade91 Merge "Refine some workflow related comments" 2019-10-24 13:07:55 +00:00
WMDE-Fisch 9196ccead7 Refine some workflow related comments
Change-Id: Ib7a6c4cc085d91fe27c96cbfd9c7035465149319
2019-10-24 14:38:46 +02:00
Adam Wight 5e8d48b331 Minimal support for bookreferencing tag
Allows the "refines" attribute when the feature flag is set, but doesn't
render.  This is part of our rollback strategy, so that we aren't left
with invalid wikitext in case of undeployment.

Bug: T236257
Change-Id: I936be0e62dccb46caeb84162d2c5166956fd9916
2019-10-24 12:24:36 +00:00
Thiemo Kreuz 3e2d1a23e0 Fix all PHPCS issues and add missing array type hints
* I used https://codesearch.wmflabs.org to make sure the private
constants are indeed not used anywhere.

* The added type hints are safe, as far as I can tell. There is no way
one of these parameters can contain anything else. Otherwise the code
would fail already.

Change-Id: Iaa7615e9864805760fa652700b58b69680b4f17e
2019-10-17 09:23:20 +02:00
jenkins-bot f64ac926f1 Merge "Bundle tracking with another RL module" 2019-10-16 11:02:42 +00:00
Adam Wight 741f5dcdaa Bundle tracking with another RL module
This is slightly more efficient because it saves on early page-
load bandwidth.

Bug: T234605
Change-Id: If83420a9b4e654fd790e810fa82f922a8ba06e50
2019-10-10 10:44:50 +02:00
jenkins-bot a9d30ab836 Merge "Baseline reference interaction tracking" 2019-10-04 09:45:10 +00:00
Adam Wight c12150082c Baseline reference interaction tracking
Collect EventLogging metrics for footnote and reference link
interactions, so that we can compare behavior with and without
Reference Previews enabled.

This tracking will be reverted once analysis is complete.

A mostly arbitrary sample rate of 1/1000 is hardcoded here.  This is
loosely based on the latest tuning of Popups sampling at 1/100,
divided by a conservative factor of 10 to ensure headroom.

The sample is skewed by skipping clients without sendBeacon support,
but we're avoiding the mw.track synchronous fallback, which injects an
image tag and introduces lag any time the user clicks external links
in the references.

Bug: T231529
Change-Id: Iad32b64114f88675eecbb01712418c968e3cf661
2019-10-01 10:23:31 +02:00
jenkins-bot 12c7fd7ac2 Merge "Citation needed template handling" 2019-09-21 19:10:48 +00:00
Derick Alangi 35e6993ffc Avoid usage of deprecated $wgContLang global (dep in 1.32)
Change-Id: Ib3972dc0a7ef3dad4db64e268b613dfafb18a242
2019-09-02 19:53:34 +01:00
Ed Sanders 659d461806 Citation needed template handling
Bug: T211243
Depends-On: I82124b24cc9edbbfc41dedc72452cbb583051cf8
Depends-On: Icfc39e350452da238d0e0c17cb2305c60d9ca16a
Change-Id: Ic443c1ae759a058673b71e47f09f2a7d219fc12e
2019-08-30 13:13:37 +01:00
WMDE-Fisch e0602be6a9 Remove warning about hard-coded class name
Core now uses the extension name to check if the Cite extension is
loaded. Therefore the class name could be changed in that regard.

Change-Id: Ibdc0725045f7a0b0afcbf6cb94ccdab9509ad672
Depend-On: I35e5aa9955141b575de68a5be2c0d5b87585eb77
2019-08-14 19:17:24 +02:00
James D. Forrester bceb94ca2a build: Upgrade phan-taint-check-plugin from 1.5.x to 2.0.1
Change-Id: I909d3cfa726d7b68b5a580baf00f6746d4689404
2019-07-10 16:31:30 +00:00
Ed Sanders 367e7a2803 Use upstream OOUI icons
Provide a mapping from the old icons to the new defaults
as the names are defined on-wiki.

Bug: T217132
Change-Id: I7fd22078789f4a06c5ed165a0c979fb543801af2
2019-04-12 14:11:47 +01:00
Kunal Mehta 45c01a6b78 Upgrade to newer phan
Bug: T216911
Change-Id: Ib228ac26a9a87c51a107407b6162110681b5e75c
2019-03-17 16:46:06 -07:00
Umherirrender 51784f62f7 Use ExtensionRegistry rather than class_exists
Change-Id: I5c6a6ed3f6ecef1cde5519bcdac5ae35e7ab1a73
2019-03-03 01:49:43 +01:00
Bartosz Dziewoński 17555dd934 ve.ui.MWReferenceDialog: Remove 'Use an existing reference' button
The same functionality is available using the 'Cite → Re-use' tool
on the toolbar (T214991).

We want to use the same location for a new 'Replace reference' button,
to be implemented in the Citoid extension (T208981).

Bug: T208981
Bug: T214991
Change-Id: I511e3c27a7d2175bdc2b6bdb648f04ac96cd1e0b
2019-02-26 00:30:56 +01:00
libraryupgrader 32658c84ac build: Updating mediawiki/mediawiki-codesniffer to 24.0.0
Change-Id: Ieaba78a1c1d946bebbfba6419e554d62fdbe6715
2019-02-06 11:32:11 +00:00
James D. Forrester 39b70b003e Tests: Depend on newly-renamed VE test suite
Depends-On: If6e0450ec73051d9b1d9111aed808fee26b45705
Change-Id: I5a9a6162144dd7cdd34cd771a62477a9a1b6886d
2019-01-23 22:02:07 +00:00
Bartosz Dziewoński 2286e5fde1 Improve warning that reference is reused
* Show the warning in the context menu (on desktop only) in addition
  to the reference dialog.
* Add more details to the warning in reference dialog, and adjust
  spacing around it to make it more noticeable.

Bug: T208981
Bug: T212609
Depends-On: I6ca605ddd580d6259952c8799ecdca08da07474a
Change-Id: I23cc02f651c15b3276613d32a0c2537032f731c2
2019-01-10 02:01:09 +01:00
Thiemo Kreuz 3f22189998 Fix <ref> ignoring all parameters when there are more than two
We can resolve this bug by either replacing the bogus "return false"
with the intended "return [ false, … ]". Or rely on the code a few
lines below that also bails out with a "return [ false, … ]" when to
many parameters ($cnt is not 0 then) are present. The tests prove both
solutions are equally valid.

Bug: T211576
Change-Id: Iadd55c134dede7042cfd152c69bc8f27b59d8912
2018-12-11 20:49:40 +01:00
Thiemo Kreuz (WMDE) 06b821a451 Rewrite private Cite::refArg for readability
The biggest issue with this code was that it was tracking the exact
same state in two ways: Processed array elements got removed from the
$argv array, *and* the $cnt was decremented the same time. This is not
necessary and a potential source of confusion and errors.

I carefully transformed the code. I'm sure it still does exactly what
it did before. The tests should prove this.

Change-Id: I642d38e7944aa3e2239179fa58e1e231b4698263
2018-12-11 17:58:19 +01:00
jenkins-bot 9e981d28b6 Merge "Sanitize underscores as core does, to not create broken links" 2018-12-11 00:01:57 +00:00
jenkins-bot c6e13db74f Merge "Simplify weirdly complex [\n\t ] regex" 2018-11-30 23:50:55 +00:00
Thiemo Kreuz (WMDE) 8760fe5e62 Rearrange Cite::listToText for performance
The two message are not needed in case there is only one element.
Since fetching messages is a little expensive, I feel it's worth
rearranging this code.

Or not, because it seems this method is never called with one
element only.

Change-Id: Ie915278b41f053afe0d14a29d2aec54c98e5185e
2018-11-21 18:16:55 +00:00
jenkins-bot 1fe6947693 Merge "Use \d shortcut in regular expressions" 2018-11-21 18:13:00 +00:00
jenkins-bot 7c7f258aac Merge "Remove unused parameter from two private Cite functions" 2018-11-21 18:03:30 +00:00