Commit graph

1375 commits

Author SHA1 Message Date
jenkins-bot 55640a8a0d Merge "Show no remote users when input is empty" 2020-05-18 02:51:32 +00:00
Ed Sanders d56b512f2e ReplyWidget: Move all events bind to setup
Bug: T252439
Change-Id: I3c76e6364b63679fcbe40d256d9ba0c3eaba1578
2020-05-17 21:12:23 +01:00
Ed Sanders bc437fc43f PHP: More missing typehints
Change-Id: I483c9e70b65dcd685436b4099bcfc4925c65b002
2020-05-16 16:46:25 +01:00
Ed Sanders 5e996fdfdd Modifier: Pass document to createWikitext
Change-Id: I1793e1d690835af746a4e25a50e2e0a474811e8e
2020-05-15 22:47:54 +01:00
jenkins-bot 9cc665a8bc Merge "Add missing use MWException" 2020-05-15 21:46:21 +00:00
jenkins-bot a6fcb965ea Merge "Fix return type of callable" 2020-05-15 21:46:20 +00:00
jenkins-bot db29a29306 Merge "Don't call non static functions statically" 2020-05-15 21:46:20 +00:00
jenkins-bot 973fc05f9a Merge "Add leading \ to covers" 2020-05-15 21:46:19 +00:00
Reedy 234988155e Add leading \ to covers
Change-Id: I1ed4cd28bf630c6aae238e548410d1293a8b71f1
2020-05-15 22:08:25 +01:00
Reedy ac6cd26ca0 Don't call non static functions statically
Change-Id: I2db66a8da3ab325f2bbabb37afd276d4a62077e9
2020-05-15 22:02:57 +01:00
Reedy 70c5a1e435 Fix return type of callable
Change-Id: I7e594a9f9f6f9d4737fd880e449c43b9b2cf24fb
2020-05-15 22:01:21 +01:00
Reedy c3a7ba1d13 Add missing use MWException
Change-Id: I4d00106718c0f7e32060d23aaa2bc8c74a4d6d1f
2020-05-15 22:00:30 +01:00
Reedy 08a6a83f9d Replace stObject with stdClass
Change-Id: Id380c34cf0ca85a0a9a0d044474aa228b620c78f
2020-05-15 21:57:28 +01:00
jenkins-bot 21a892d5e7 Merge "Follow-up b78fb3f4: Make sure we're using a MW User" 2020-05-15 20:38:42 +00:00
James D. Forrester d775f30791 Follow-up b78fb3f4: Make sure we're using a MW User
Change-Id: Iafd4d3b17a873c0702a64e063a1d0d7e19cf572b
2020-05-15 13:18:06 -07:00
Ed Sanders e6e0b1ead9 PHP: Add missing typehints
Change-Id: I5639f8cbdae9aaa9cfa06136e19cc94f9fad10ea
2020-05-15 22:04:47 +02:00
Ed Sanders b78fb3f4c1 Move all PHP to the MediaWiki\Extension\DiscussionTools namespace
Change-Id: I654ebb3e646a6d8d62f7bd14d48805e39f836d7e
2020-05-15 21:57:13 +02:00
Ed Sanders 340572bc05 Create a Utils class in PHP
Also move htmlTrim to utils in JS.

Change-Id: Ia5356d713c1c5d521c396cc28bcd4ecc7ee5bbbb
2020-05-15 00:25:32 +01:00
Ed Sanders a3889fd400 Port modifier.js to PHP
Change-Id: I03b9e4377cb3ce6a5ca9d06e49dca9b2516f4979
2020-05-15 00:20:41 +01:00
Bartosz Dziewoński 6f32369b6a tests: Fix comparing PHP and JS ranges
In JS, strings are internally encoded as UTF-16, and properties like
.length return values in UTF-16 code units.

In PHP, strings are internally encoded as UTF-8, and we have the
option of using methods that return bytes like strlen() or UTF-8 code
units like mb_strlen().

However, the values produced by preg_match( …, PREG_OFFSET_CAPTURE )
are in bytes, and there's nothing we can do about that. So let's use
bytes throughout, mixing the two types results in meaningless numbers.

Then in the test code, we have to calculate UTF-16 code units offsets
based on the UTF-8 byte offsets.

We also have to copy the entire workaround for mw:Entity nodes… Maybe
the parser should be fixed to return the real nodes for ranges' ends
in this case.

Change-Id: I05804489d7de0d60be6e9f84e6a49a885e9fb870
2020-05-14 22:37:34 +00:00
Bartosz Dziewoński 76289cdf73 tests: Fix failures due to CDATA handling in PHP
It appears PHP's DOM library always uses CDATA nodes for the contents of
<style> tags, even if there is no such markup in the source HTML.

Change-Id: Id04b27086c5e7a0b016a3a440b2b4895d6b13c93
2020-05-14 22:37:23 +00:00
Bartosz Dziewoński 33d69e26c9 tests: Fix different whitespace trimming in PHP and JS
Notably, JS trims the no-break space, while PHP doesn't. There are
some other differences that don't come up in our tests. What we really
want is to trim the ASCII whitespace as defined in the HTML spec.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
https://www.php.net/manual/en/function.trim.php
https://infra.spec.whatwg.org/#ascii-whitespace

Change-Id: I95b8fb38878716a2fa7ec84c9f2e8065ebe77c0d
2020-05-14 21:37:26 +00:00
Bartosz Dziewoński c0002be7cd tests: Fix computing ranges in Parsoid documents
In JS tests, we load the documents via mw.template, which apparently
causes the <html>, <head> and <body> tags to disappear, resulting
in the ranges not matching in PHP tests (and the real document).

Put in a big hack that makes them match, and update the JSON files.

Change-Id: I8194752cd5f82c3716c99e76a37226af5d4a0ec1
2020-05-14 01:11:44 +02:00
Bartosz Dziewoński 95a87911eb tests: Check ranges in PHP parser tests
Comment out only the cases that still fail, so it's easier to fix them.

Change-Id: I85d205731d572c93ababa7dd66e674321969edb7
2020-05-13 23:58:37 +02:00
Ed Sanders 076c6d828a Parser: Use Element instead of Node when appropriate
Change-Id: I67015989954e61810302bf8931d05419f007ffeb
2020-05-13 14:46:36 +01:00
Translation updater bot 0f532e9bb6 Localisation updates from https://translatewiki.net.
Change-Id: I8d7c3abfc546add45c48c787baf942edea77c143
2020-05-13 08:42:26 +02:00
Bartosz Dziewoński b8d7a75c34 Fix performance of DiscussionToolsCommentParser::childIndexOf()
Profiling reveals that >87% of the run time of our test suite is spent
in this tiny method. Apparently, DOMNodeList::item() is extremely slow
(possibly it's linear time instead of constant time?).

Profiled using XDebug and KCacheGrind:
https://phabricator.wikimedia.org/F31815264

We can calculate the child's index in its parent by counting its
precending siblings instead, which turns out to be much faster.

Before:
 1. 275444ms to run DiscussionToolsCommentParserTest:testGetComments with data set #2
 2. 12668ms to run DiscussionToolsCommentParserTest:testGetComments with data set #3
 ...
After:
 1. 9545ms to run DiscussionToolsCommentParserTest:testGetComments with data set #2
 2. 5549ms to run DiscussionToolsCommentParserTest:testGetComments with data set #3
 ...

That's still kind of slow but now it's bearable to run the test suite.

Change-Id: I49155f7aa2e231a9a20bf282cf6aaa28fc902e0b
2020-05-13 02:56:39 +02:00
Ed Sanders 745101c02b PHP tests: Move some test utils to a parent class
Change-Id: I6ae5aa85f8aaa02e1b9323820a841c06c5d62b64
2020-05-12 12:33:04 +01:00
Ed Sanders a000b8c7b1 Add comment tests to PHP
TODO: Make the assertions less slow (currently ~50s)

Change-Id: I1d774e353c070484b5bae18e2ec3e3e41da68202
2020-05-12 12:33:04 +01:00
Roan Kattouw 7b7a2cd69c The Great Parser JS to PHP port of 2020!*
* Not to be confused with the Parsing Team's
"Great Parser JS to PHP port of 2019"

Gasp as OR hacks are changed to null coalescing operators.
Applaud as variable declarations are dropped.
Cheer as parameters and return values are type-hinted.
Shudder as DomNodeLists have no indexOf method.

Moving discussion parsing to the server should allow
us to implement much cleaner APIs for commenting.

Bug: T252252
Co-authored-by: Ed Sanders <esanders@wikimedia.org>
Change-Id: Ic1438d516e223db462cb227f6668e856672f538c
2020-05-12 12:33:04 +01:00
Translation updater bot 111dbeba9a Localisation updates from https://translatewiki.net.
Change-Id: I538a737b31c25fd354c8cc1cd197116c803d10ec
2020-05-12 08:20:57 +02:00
jenkins-bot 8415b44837 Merge "Modifier: Fix missing docs and variable names" 2020-05-11 22:17:41 +00:00
jenkins-bot ee102a5a89 Merge "Modifier: Separate out test data" 2020-05-11 22:17:28 +00:00
Ed Sanders 07439609c4 Modifier: Fix missing docs and variable names
Change-Id: Ia5a7974f1efbe7465235fd1f1f548f53848ca960
2020-05-11 22:56:21 +02:00
Ed Sanders 6aa2fac2f8 Give username completion a min width of 10em
Change-Id: Id98643714e092f33034dcc84a97845fb2945bfb0
2020-05-11 19:44:52 +01:00
Ed Sanders 76bd22fe59 Show no remote users when input is empty
This could cause unrelated remote users to be shown
if you typed '@x<backspace>'.

Change-Id: I03c63ede4fce53c201398b6ba5256b68aa90391c
2020-05-11 19:35:48 +01:00
Bartosz Dziewoński 6237f0fe0f Show real error message when an exception is thrown
Exceptions were being treated like API errors, resulting in the
incorrect message "Invalid response from server." being shown to the
user. Instead show the error message.

Bug: T252238
Change-Id: Idbaee7d2b710812673992d30a17a9b5fe856a5a6
2020-05-11 19:04:54 +02:00
Ed Sanders 4397bda8cb Modifier: Separate out test data
Change-Id: I63d868a47daebee180c229b424311d10b80d2e89
2020-05-11 16:58:00 +01:00
Ed Sanders 78aba45909 Hooks: Remove unused variable
Change-Id: I80f5dd63a2224f1c523ab1aa53da435851c2789d
2020-05-11 16:55:08 +01:00
jenkins-bot dc2fe46032 Merge "parser.js: Fix some typos and variable names" 2020-05-11 15:19:36 +00:00
Translation updater bot ac35652811 Localisation updates from https://translatewiki.net.
Change-Id: I3b60e7c771859b72c9f2621aa0ac946b51ac6718
2020-05-11 08:37:03 +02:00
Ed Sanders ea0b95be05 Manually clear out session storage on teardown
We used to rely on this happening in onInputChange but
that listener is now detached.

Bug: T252176
Change-Id: I6654d68dc6107cd78172c455db9cba6cb9eabddf
2020-05-08 23:01:17 +01:00
Ed Sanders 77f1be3bd1 parser.js: Fix some typos and variable names
Change-Id: Ib80fd87893f8fad47eaeac8edabe03472b78b75c
2020-05-08 20:22:49 +01:00
jenkins-bot 4c8e92e0fb Merge "Disable VisualEditor page takeovers while a reply widget is open" 2020-05-08 14:24:26 +00:00
jenkins-bot af2fd3f8d8 Merge "Fix typo in parser.js 'dl' => 'dd'" 2020-05-08 14:20:14 +00:00
jenkins-bot c236306d16 Merge "Separate out more data from parser.tests.js" 2020-05-08 14:20:13 +00:00
Ed Sanders 4f22e32304 Fix typo in parser.js 'dl' => 'dd'
Doesn't actually affect the behaviour as we are
computing indentation level.

Change-Id: I8b6824460ffbee1c0acb361c26503d3b6c439025
2020-05-08 14:24:15 +01:00
Ed Sanders 41d5aa1d37 Separate out more data from parser.tests.js
Change-Id: Ib1c3ec30796dd6bff36835e4555b6974e2a5b376
2020-05-08 12:12:11 +01:00
Translation updater bot 99904ad553 Localisation updates from https://translatewiki.net.
Change-Id: I1994571dbb2b6547ccf0879bcf08ac4a3ad3f222
2020-05-08 09:28:10 +02:00
David Lynch 2f92e5d114 Disable VisualEditor page takeovers while a reply widget is open
This allows the unload handler to trigger on these links.

Depends-On: If52aa9d619eac08456874fc75c0f6e1adff01246
Bug: T244942
Change-Id: I9904e8af4a60b0f5e9a6e263cd4fd8e1e3fd1f98
2020-05-07 21:46:15 +02:00