Commit graph

259 commits

Author SHA1 Message Date
jenkins-bot a0d97212cd Merge "Improve API parameter documentation" 2021-02-13 22:15:16 +00:00
jenkins-bot 5a9a4dc525 Merge "computeId() can't return null" 2021-02-13 22:14:02 +00:00
Bartosz Dziewoński 6659bb3f00 CommentFormatter: Fix problems with editsection and quotes
Bug: T274709
Change-Id: I918fdd97064186381b65ab1567d02abf6f944b8f
2021-02-13 20:01:58 +01:00
Bartosz Dziewoński 03f22c538e Improve API parameter documentation
These messages are used on Special:ApiSandbox.

Change-Id: I07809d3f9402d30c5d2d364e0634bd020f86f64f
2021-02-13 00:08:31 +01:00
Bartosz Dziewoński 1998c983f1 computeId() can't return null
It used to return null for headings, but now it doesn't. Simplify some
code checking for that.

Change-Id: I28131c4aee89b901879b4c49953d6b15ed91b5e7
2021-02-13 00:08:15 +01:00
jenkins-bot f393fa5f03 Merge "Remove a TODO note about wrappers" 2021-02-11 00:09:50 +00:00
jenkins-bot d5b2389ffa Merge "Fix replying outside wrappers for partially indented comments" 2021-02-11 00:09:48 +00:00
Ed Sanders 361fd4c4a4 Add body class to enable reply links
Going forward this will allow us to remove the parser
cache split, and toggle features just using CSS.

The CSS will be modified in a later commit to give the
anon caches time to clear.

Bug: T273072
Change-Id: I83c84b8bc63e1881e07b49acd8499b811adfccd4
2021-02-10 15:40:34 +00:00
Thiemo Kreuz 1e0d2d93b3 Add missing out-of-index guard to CommentUtils
I found this error in our logstash. I was not able to find an
existing Phabricator ticket.

Note how line #348 extracts the last element from the
$siblings array. It uses the function end() there, which
returns false in case the array is empty. $siblings[0] can't
do this but yields an error.

An alternative is to use reset(), which can return false as
well. But that's not really better. Especially not better
readable, I would argue.

Change-Id: Ic90cd2392ede15078ba0d5b4d67b8dc5d05f9bf7
2021-02-09 12:27:41 +01:00
Bartosz Dziewoński 3a1b8e09ea Remove a TODO note about wrappers
Yes, this is still needed, removing it causes failures in tests
(and the old outputs look better).

Change-Id: I5bcedb0295a1f0ac4f6e51eaa9a9e072d8236f3c
2021-02-08 22:23:54 +01:00
Bartosz Dziewoński 9d2b35828d Fix replying outside wrappers for partially indented comments
Top-level comments that start or end with a list (inconsistent
indentation) would not have triggered the logic for detecting
wrappers.

Bug: T273692
Change-Id: Idcb4eed73e391f5f86eca2eb05cb3cea0d86f30a
2021-02-08 22:18:37 +01:00
Ed Sanders d05109b24d Truncate user generated part of IDs to 80 characters
This ensures that IDs fit in a 255 character database field.

Bug: T273658
Change-Id: I3cfe4fce6a865b4343f0f01121cd696aa5f98b22
2021-02-03 15:04:58 +00:00
Ed Sanders 6c3dd3aaa9 Move Hooks to HookUtils
Now that all the real hooks have been separated out

Change-Id: Ibdb42f98614fc551068f8f8e5297dcc99251ab46
2021-02-01 22:35:11 +00:00
Ed Sanders 2908c2808d Move Hooks::addReplyLinks to CommentFormatter
Change-Id: I9f5483cd801f48efff22cba045ae6851da9719fd
2021-02-01 22:35:04 +00:00
Ed Sanders bf51f1f65c Use new HookHandler system and group hooks by purpose
Bug: T273303
Change-Id: I2d940e1944a9d7686bf7bc544a318c88c0b2afad
2021-02-01 22:34:57 +00:00
Bartosz Dziewoński f21e6dfc7c New error message when the page doesn't exist
The previous confusing error was coming from the getLatestRevision() call.

Bug: T273068
Change-Id: I5bb53c875bb08f6fb087875a6e55fb033d182056
2021-01-27 16:41:03 +01:00
jenkins-bot 50f749d676 Merge "Handle category links at ends of comments affecting indentation" 2021-01-26 17:21:34 +00:00
Bartosz Dziewoński c781b127c9 Handle category links at ends of comments affecting indentation
* Ignore rendering-transparent nodes between discussion comments.
* Improve isRenderingTransparentNode() so that <link> nodes
  representing TemplateStyles are not considered transparent,
  otherwise this would undo ae920b831f.
  Using a regexp from Parsoid.

Bug: T272746
Change-Id: I0b3c3251156ba6c4826abf5ba44ea93f80ebc01d
2021-01-26 04:55:03 +01:00
Bartosz Dziewoński ca9db69b40 Fix check for null edits
Yet again, the CAPTCHA being neither an error nor a success bites us.

Bug: T272922
Change-Id: I5ef85df452638ad3208e7a1cadad44c83237dbfe
2021-01-26 01:06:31 +01:00
David Lynch 15c4052168 A/B test output when a specific feature is being tested
Bug: T268191
Change-Id: Ib4fb59e4dc28aebc45854c293cb25bb3006267c3
2021-01-21 15:46:05 -06:00
jenkins-bot 994abdac39 Merge "Store reply links in the parser cache" 2021-01-19 21:35:36 +00:00
Ed Sanders 32789a9a55 Store reply links in the parser cache
Splits the cache on the reply links feature being enabled
for a particular user and title.

An additional check is done after parsing in case the user
has the feature enabled via query string or cookie.

Bug: T267404
Depends-On: I883a37fd67108243e7a20683b1a5d59fd0f6e39f
Change-Id: I3bc06ca7d4aea7f0fe39eef0e77ad88d1f9c1043
2021-01-19 17:01:53 +00:00
jenkins-bot e17467b09c Merge "Fix exception when trying to use non-existent 'typeof' attribute" 2021-01-18 18:58:35 +00:00
Bartosz Dziewoński 8f42c74985 Fix skipping to the end of paragraph, now it considers nested tags
Add yet another tree walking utility: CommentUtils::linearWalk().
Unlike TreeWalker, it allows handling the beginnings and ends of nodes
separately – kind of like parsing a XML token stream, or kind of like
VisualEditor's linear model.

(Add unit tests for this utility. The simple.html test case is copied
from [VisualEditor/VisualEditor]/demos/ve/pages/simple.html.)

Use this utility to stop skipping when we reach either a closing or
opening block node tag. Previously we'd skip over such tags inside
nested "transparent" nodes (like <a>, <del>, or apparently <font>).

Bug: T271385
Change-Id: I201a942eb3a56335e84d94e150ec2c33f8b4f4e0
2021-01-18 18:20:20 +00:00
Ed Sanders 1c741d3450 Preserve a user's beta preference when not in beta
The tool may go in and out of beta as new features
are release/graduated to opt-out. Users should only
need to opt in to the beta feature once to get all
future sub-features.

Bug: T272071
Change-Id: If6834b7fc07fc7e84757dc5fdcea814cd0d65936
2021-01-14 23:46:47 +00:00
Bartosz Dziewoński c20e7765ea Fix exception when trying to use non-existent 'typeof' attribute
Bug: T272090
Change-Id: I4d1e7457441f28d789dec8b7fd2dc3ba10fd995e
2021-01-14 22:11:32 +01:00
Ed Sanders c42e86f0f6 Config: Explicitly check feature availability in the client
Don't assume a feature is available because the code has
loaded and the user option is set. Export the logic from
Hooks.php to the client.

Change-Id: Ica0e58de7ed0d59e3b09645193eb2b691ae41c39
2021-01-14 19:04:18 +00:00
jenkins-bot 99acd2a925 Merge "A/B test bucketing for beta enrollment" 2021-01-14 12:49:05 +00:00
Ed Sanders f6fe40b500 Fix check for feature availability
If asking if any feature is available, also check if
any feature has been set to 'available'.

Change-Id: I417f8756d91c5d3abab8b24109320737b8b86509
2021-01-13 19:35:42 +00:00
David Lynch 27a995d5a2 A/B test bucketing for beta enrollment
If DiscussionToolsABTest is enabled (set to `all` or a feature), logged
in users who have never used the tool before will be assigned to an a/b
test bucket. If they're in the test bucket, they get the feature
enabled.

If they manually set their beta feature preference, we don't override
that but do maintain their bucket for logging purposes.

Bug: T268191
Change-Id: I9c4d60e9f9aaef11afa7f8661b9c49130dde3ffa
2021-01-13 10:32:00 -06:00
Ed Sanders 706f4438fc Add "new topic" user preference
Bug: T270119
Change-Id: Ie27ea645602f7533610826cbc0cc422e3682d863
2021-01-12 20:15:46 +00:00
Bartosz Dziewoński d76143bc08 Ability to add new discussion sections
1. Extend the JS modifier to allow adding top-level comments
   (that is, replies to headings). PHP modifier doesn't do this
   because we'll save the changes using paction=addtopic instead.

2. Subclass CommentController to allow adding a new heading and a
   top-level comment underneath it at the same time.

3. A lot of ugly code in ReplyWidget to customize the interface
   for this case. Much of it should probably be moved to
   CommentController/NewTopicController.

Bug: T267595
Change-Id: I9c707bb7f7aae1b92c72fb4dee436490f8c8409b
2021-01-12 20:15:28 +00:00
jenkins-bot 81cb4e8fe8 Merge "Load site config data in CommentFormatter tests" 2021-01-09 15:39:52 +00:00
Ed Sanders 8b71a2b5dc Load site config data in CommentFormatter tests
This fixes missing reply links in arwiki test output.

Change-Id: I24d3b8371a8343c4445c716fadf0692be0924eed
2021-01-08 23:03:33 +00:00
jenkins-bot 3625f2d8f6 Merge "Catch when no changes are actually saved when posting a comment" 2021-01-08 22:46:14 +00:00
Bartosz Dziewoński 1c8ca53c92 Catch when no changes are actually saved when posting a comment
Bug: T268069
Change-Id: Ib9c136d846668335884a242322d5b0d4e038c6b1
2021-01-08 22:39:18 +00:00
Ed Sanders 9ba6c3d159 CommentItem/HeadingItem: Make more constructor args required
This ensures the getters always return the promised types.

Change-Id: I1a3c909f5395463ef7a89d896ead1520b2a17509
2021-01-08 20:45:29 +00:00
Ed Sanders 0d2d3b16b8 Pass interface language object to addReplyLinks
Change-Id: I8a5562e11df3ad6430db48020d6005d0c4fd6834
2021-01-08 21:43:21 +01:00
jenkins-bot 4b1fe2d3b8 Merge "Refactor availability checks" 2021-01-05 19:04:29 +00:00
Ed Sanders dcc23f1108 Refactor availability checks
Allows for multiple features in the near future.

Separate availability and enabled.

Separate User/Title/Output checks.

Change-Id: I454bd8407675749d93ff3d2b4c5d624b433204db
2021-01-05 19:42:37 +01:00
jenkins-bot 8a6bb8efd0 Merge "Ignore outdent templates at the beginning of comments" 2021-01-04 21:48:27 +00:00
jenkins-bot fa9d729728 Merge "Change which nodes are ignored at the beginning of comments again" 2021-01-04 21:47:40 +00:00
Bartosz Dziewoński 6e37a172ae Fix detecting decorative comment frames with whitespace
As a result of 0fc71f60cd, "empty" text
nodes (containing only whitespace) at the end of the comment may be
inside the comment's range, and trying to ignore them caused the
ranges not to match and the frame not to be detected.

Now the code works whether they're inside the comment's range or not.

Add a test case for wrapped discussion comments with HTML comments and
with whitespace.

Bug: T250126
Bug: T268407
Change-Id: I2217ff5a635fd1c9c9e803f46795b1bfb3d17535
2021-01-04 20:31:33 +01:00
Ed Sanders 6710b80d4f Make Hooks::$tags a constant
Change-Id: I63bacc9bc6fc18ef677325439b6186d1813d23cf
2020-12-17 21:17:58 +00:00
Ed Sanders ffbfbc0dd8 Separate out isAvailableForTitleAndUser from isAvailable
Change-Id: I3d9375d35e893c3e139d55a8505a78411ad58577
2020-12-17 21:17:44 +00:00
Ed Sanders 3bb2d25a74 Use PageProps for fetching newsectionlink flag
Now we don't require the ParserOutput to be available.

As a result, we now check the flag on the latest revision of the page,
rather than the one being viewed.

Change-Id: Id77a332643cb8ad95afc5cec6713fa0a3636a5ce
2020-12-17 21:17:24 +00:00
Ed Sanders 6ad1f05d16 CommentFormatter: Don't parse replylink label
Change-Id: Ic2e77b78d12931d5b2c2c6e2cf29b652a2be8aca
2020-12-15 22:18:08 +00:00
jenkins-bot 9a37c71300 Merge "Disable reply links on mobile" 2020-12-14 22:41:05 +00:00
Bartosz Dziewoński 50ad5bb2b4 Ignore outdent templates at the beginning of comments
Bug: T264116
Change-Id: Iae9dbb30a1aead897cc274f655d3ecff4b297dbd
2020-12-14 21:35:56 +01:00
Bartosz Dziewoński ae920b831f Change which nodes are ignored at the beginning of comments again
While working on T270009, I noticed that <style> and <link> nodes
are treated differently, which seemed weird. Rewrite this again,
hopefully this is the last time.

The changed test cases also involve <area> and <input> nodes,
and the new results make more sense to me.

Bug: T264116
Change-Id: I3af90c84768a4b3dc53446927f4dba6f72175a2f
2020-12-14 21:33:50 +01:00