Commit graph

2835 commits

Author SHA1 Message Date
Thiemo Kreuz 042a4ecf7a Add basic unit tests for all 3 hook classes
Change-Id: Ib444717465f8dda96c89afd8b2d60336e8bcdeec
2019-11-12 11:11:45 +00:00
Thiemo Kreuz c9310ff7b4 Use __CLASS__ instead of repeating the class name
Change-Id: I97e9d973accd1d3467ed1f04af37e021e55783b3
2019-11-12 10:55:35 +00:00
Thiemo Kreuz 7ce10d7539 Remove lazy registration of Parser related hooks
To be honest I don't get why this lazy registration was done in the
first place. None of the 4 other hooks should ever be called before
the ParserFirstCallInit hook got called.

Also, under which circumstances can the ParserFirstCallInit hook be
called more than once?

Both scenarios would be wrong, as far as I'm concerned. Either I'm
missing something, or this code can indeed be simplified. Maybe it was
something to make it more compatible with older MediaWiki versions?

The only reason I can think of is: in all situations that do not
involve a parser, having the 4 extra hooks registered is pointless.
Does this waste space and/or runtime in the $wgHooks registry?

Change-Id: I5ef1495f4ce7bce940fa5f8e700af3d2c4851a01
2019-11-12 11:47:55 +01:00
jenkins-bot 9de8876ecf Merge "Remove an unused private variable" 2019-11-12 10:45:41 +00:00
Adam Wight 9d706047f3 Rename refines -> extends
Bug: T171581
Change-Id: I42b2d8859f2958357024cbba089715c10712f370
2019-11-12 10:19:17 +00:00
Adam Wight 8963536278 Remove an unused private variable
Change-Id: If52cc90bacee96afce4528f98d7f07f869d2acde
2019-11-12 11:15:47 +01:00
jenkins-bot c75fe5dccd Merge "Move $this->mParser setters up one level" 2019-11-12 09:58:02 +00:00
jenkins-bot 5ae75353e4 Merge "Don't use $this->mParser in Cite::saveReferencesData()" 2019-11-12 09:48:52 +00:00
Thiemo Kreuz 818e869b0b More narrow method signatures involving Parser
Change-Id: I2da717b9a8d104644c59a62b49090605c95323d6
2019-11-12 10:24:58 +01:00
jenkins-bot 657b81abd2 Merge "Add basic test coverage for all CiteHooks code" 2019-11-11 19:24:06 +00:00
Thiemo Kreuz bd72636b95 Move $this->mParser setters up one level
Two motivations:

1. I want the two deeper nested functions guardedRef() and
guardedReferences() to have less side effects.

2. In guardedReferences() guardedRef() is called. Both set the
property. That's redundant. The new code avoids this.

Change-Id: I48146f8b6d91122a904be0a552ffe3b03bc0481f
2019-11-11 20:16:05 +01:00
Thiemo Kreuz 960b6ed17f Don't use $this->mParser in Cite::saveReferencesData()
Main motivation is to make the code easier to test, and easier to
extract to smaller services.

Does this make sense? I'm not sure any more. One can argue that
everything Cite does happens in the context of a specific Parser. Why
shouldn't the code have access to this Parser?

Change-Id: I9d0cb44d96ec70a56af57f86aeb1f264f52c8bc4
2019-11-11 20:12:05 +01:00
Translation updater bot d2cc18d38a Localisation updates from https://translatewiki.net.
Change-Id: I6288c824496adde97027640db0c192e07b169bb0
2019-11-11 14:47:10 +01:00
jenkins-bot 15a84769b8 Merge "Test cleanup: drop equalTo" 2019-11-11 12:43:04 +00:00
jenkins-bot 62ca80536e Merge "Block all combinations of refines="…" and follows="…"" 2019-11-11 12:37:34 +00:00
jenkins-bot 6b7d6ebd10 Merge "Merge bookReferencingUnimplemented.txt into bookReferencing.txt" 2019-11-11 12:37:33 +00:00
jenkins-bot 3cac8643a6 Merge "Move some glue code from Cite to the Cite…Hooks classes" 2019-11-11 12:37:31 +00:00
Adam Wight bde9e175a8 Test cleanup: drop equalTo
Can use a shortcut where we pass the expected value directly.  Verified
that we're still asserting equality.

Change-Id: I63512488c50e599df23d5dae2a5064218e311e90
2019-11-11 12:57:09 +01:00
Thiemo Kreuz fe385ecc37 Block all combinations of refines="…" and follows="…"
Note it doesn't make a difference if this is behind the feature flag or
not. It should always be forbidden, and in fact is: Either the follows
attribute is unknown, or the combination is forbidden.

Bug: T236256
Change-Id: Iebbb2d1d5bab183ab0590b8a7a7f6e79d319b72c
2019-11-11 12:56:58 +01:00
Thiemo Kreuz d919615e28 Merge bookReferencingUnimplemented.txt into bookReferencing.txt
What we find critical is:
* That all tests relevant for book referencing are in a separate file.
* That unimplemented stuff is marked with TODOs.

Not having to move tests to another file allows for nice diffs.

I tried to order the tests as good as I could. E.g. have all tests with
a group="…" next to each other, followed by all with a follow="…".

Change-Id: Idc1d9e7843b341235ab3d8ebe398e01946eb1845
2019-11-11 12:50:51 +01:00
Adam Wight b7a7457ffd Add page property when parsing book reference
Any time the book referencing attribute is used in a page,
permanently tag that page with the `ref-extends` property, so
that it can be watched and cleaned up if necessary.

Bug: T237531
Change-Id: Ice5d9d8f7a305702cdc7c2a55d4147c4f79b5881
2019-11-11 11:06:31 +01:00
Thiemo Kreuz ae01d35bf2 Add basic test coverage for all CiteHooks code
This also updates an existing test to cover all trim() in the code.

Change-Id: I0f0b4f8154004f941f4eaa5a9b2c3be0598fb137
2019-11-08 15:59:01 +01:00
jenkins-bot f62acf7e89 Merge "refArg parses and returns the refines attribute" 2019-11-08 12:01:33 +00:00
jenkins-bot 1eaedd98c2 Merge "Split out BookReferencing parser tests" 2019-11-08 11:56:39 +00:00
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
jenkins-bot 468b7e05e8 Merge "Extract all hook handler functions to small glue classes" 2019-11-08 09:58:46 +00:00
jenkins-bot e9383f3cf4 Merge "Add dedicated unit test for Cite::refArg()" 2019-11-08 09:44:30 +00:00
Adam Wight 0ebf86fdf3 Split out BookReferencing parser tests
Encapsulate the feature tests in dedicated files.  These are picked
up by the test runner for matching glob `tests/parser/*.txt`, as can
be shown by,

  phpunit.php --testsuite parsertests --filter=bookRef

Also adds TODO comments to some tests, documenting how the current output
will not match the fully implemented code's results.

Bug: T236256
Change-Id: Ie3e769c84856256180754aeff417da893a84b479
2019-11-08 10:02:38 +01:00
Andrew Kostka 1dcb096776 Add parser tests for refined references as rendered right now
These tests document the current status quo, and are meant to change
with every patch that makes the code for refined references more
feature complete.

Bug: T236256
Change-Id: I8c11b1decc36b86e7f7d1919cc39d0c16a200055
2019-11-08 09:38:08 +01:00
Thiemo Kreuz 7965659b82 Add dedicated unit test for Cite::refArg()
Again, this is intentionally testing a private method.

Change-Id: I559b88e38f7a7a4128ba0b16ff3de42f2fab2055
2019-11-07 13:14:05 +01:00
Thiemo Kreuz 64c94662f0 Add the first small PHPUnit test for Cite::normalizeKey()
Note this is intentionally testing a private method. As of now, the
code is so heavily entangled, it's not yet possible to test individual
aspects without calling private methods. The plan is to slowly increase
the overall test coverage, and the start restructuring the code as
necessary.

Change-Id: Ib3b01bddaffd0469fb66979c67c8114a5807df6d
2019-11-07 09:23:13 +00:00
Thiemo Kreuz ae8360f84a Move some glue code from Cite to the Cite…Hooks classes
I was particularly suprised by the conditions that checked if
`$parser->extCite !== $this`. This can never happen. Maybe it was
possible in a very old version of this code, but it is not any more.

Change-Id: I049ff4109a747eb9dbf325c24cf20f65753827dd
2019-11-07 09:48:08 +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
Translation updater bot 16b757b88d Localisation updates from https://translatewiki.net.
Change-Id: I8999b6b407545de2f28394322bb7798e27146632
2019-11-07 09:40:56 +01:00
Thiemo Kreuz f590379a64 Fix incomplete @param PHPDoc
Change-Id: I3b17178737cc42e8519a60a2ae2f7cca6ac6ccb3
2019-11-05 14:19:57 +00:00
jenkins-bot fe596f7eb3 Merge "Consistently name the variable for the content" 2019-11-05 10:21:17 +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
Translation updater bot 3a1a89c364 Localisation updates from https://translatewiki.net.
Change-Id: Ie7c9f4a14ec0f6a6f1f7d6f71d5530a98f3ff916
2019-11-05 09:45:00 +01: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
Translation updater bot 85ce680bcb Localisation updates from https://translatewiki.net.
Change-Id: I6bf381a41aac07931c13cfed633c581141d7941b
2019-11-04 09:29:35 +01:00
jenkins-bot e006e9682c Merge "Elaborate comment on invalid keys" 2019-11-03 10:35:30 +00:00
jenkins-bot 164463c090 Merge "build: Updating mediawiki/mediawiki-phan-config to 0.8.0" 2019-11-01 23:16:29 +00:00
Umherirrender 0f17669424 build: Updating mediawiki/mediawiki-phan-config to 0.8.0
Bug: T235049
Change-Id: I317a48bec0fc1a432e8253b357641379828b39a7
2019-11-01 23:50:43 +01: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
Translation updater bot c5fe31f806 Localisation updates from https://translatewiki.net.
Change-Id: I87a0e2f2a758bcce1ec2d3bd2bfb45e18531a794
2019-10-31 09:27:15 +01:00