Commit graph

1072 commits

Author SHA1 Message Date
Bartosz Dziewoński f7a8ba08fb Ignore transcluded items when finding permalinks
* Keep the information about this in the API result, which we were
  previously omitting
* Use it instead of duplicating the logic client-side

Bug: T356131
Change-Id: I7e7342e9d94a171b5ef56e646871c18c8c39c44c
2024-02-04 00:07:37 +01:00
Ed Sanders 8b99c1fbbe Add more search methods to findNewestRevisionsByHeading
In production, indexing the full history of every page will take
too long, so we can't rely on being able to find the target heading
text in the history of the current page.

When this search fails, fall back to the following searches:
* The heading appears in the current revision of a sub-page
* The heading appears anywhere on the wiki, but only once

Bug: T356276
Change-Id: I90e92cb9c85aaf6fb2355f842450981bbe6abf2d
2024-02-01 18:32:36 +00:00
Ed Sanders 8069585489 CommentParser: Ignore generated timestamp links
This will be present in parser cache output and can
sometimes be mistaken for user page links.

Bug: T356142
Change-Id: I800b23d8466f72affcadfa336aab07abf7f8d79e
2024-01-30 10:29:36 +00:00
jenkins-bot 184cd048f1 Merge "Refactor CommentFormatter->addTopicContainer()" 2024-01-18 01:16:07 +00:00
jenkins-bot 55daf9b617 Merge "Re-enable: "Temporarily disable isPreview in Parsoid's rendering""" 2024-01-17 19:47:11 +00:00
Subramanya Sastry 3f2f5dd237 Re-enable: "Temporarily disable isPreview in Parsoid's rendering""
This reverts commit 1cf6000d18.

Reason for revert: Want to do another round of visual diff testing
on wikitech as an anonymous user. Will revert this after test is done.

Change-Id: Ic3facb7ecd9c932be348d47d6a38cff71cd7e1db
2024-01-17 18:02:16 +00:00
Ed Sanders c076f170c4 Update TODO documentation around parsing
Change-Id: I14fb4874fdc3e97418b5f41665334e122c17d862
2024-01-10 18:29:40 +00:00
Novem Linguae 3436e2d9e9 Refactor CommentFormatter->addTopicContainer()
To get ready for the subtopic subscriptions feature, this patch
separates the code that adds the topic container from the code
that adds the subscribe button.

The idea is that in the future, an H3 would need a subscribe
button, but not a topic container. Whereas an H2 would need both.

Bug: T275943
Change-Id: I6a82773ed200dcb4083ac38a4d41838f639c097e
2023-12-24 13:34:30 -08:00
jenkins-bot 6ff126eab5 Merge "CommentFormatter: Do not add wrapper if the heading has attributes" 2023-12-20 17:17:18 +00:00
Bartosz Dziewoński 6f92654137 CommentFormatter: Do not add wrapper if the heading has attributes
Bug: T353489
Change-Id: Idf49b40cd745b804dbad3c09960507790be20ae3
2023-12-20 16:56:12 +01:00
jenkins-bot 2d2bcc05ce Merge "ContentCommentItem.php: Documentation fixes" 2023-12-18 17:21:36 +00:00
Ed Sanders 84bc45adf1 ContentCommentItem.php: Documentation fixes
Change-Id: I5ee1c3e1b79f4e9bdab417c68ff447313ecb752d
2023-12-15 17:05:22 +00:00
jenkins-bot 8e2d172960 Merge "CommentParser: Replace new uses of Title with TitleValue" 2023-12-15 16:21:19 +00:00
jenkins-bot bf9fc18120 Merge "Move finding transclusion source from ContentThreadItem to CommentParser" 2023-12-15 16:17:13 +00:00
jenkins-bot a77338fd6d Merge "Revert "Temporarily disable isPreview in Parsoid's rendering"" 2023-12-14 17:24:02 +00:00
Subramanya Sastry 1cf6000d18 Revert "Temporarily disable isPreview in Parsoid's rendering"
This reverts commit d004c001be.

Reason for revert: Visual diff done and results gathered.

Change-Id: Iefb0c74a121346286a353dae6cb795b86aa636ce
2023-12-14 14:16:41 +00:00
jenkins-bot 797bd2ea0b Merge "ThreadItemStore: Omit redundant updates to avoid warnings" 2023-12-14 11:06:45 +00:00
Bartosz Dziewoński ab2a83601a Use SQL expression builder instead of buildLike()
Follow-up to c82783a5b6.

Change-Id: If844b601b3887d5f853fb9f56be2741896114698
2023-12-14 11:55:34 +01:00
Bartosz Dziewoński 1e5dc67c36 ThreadItemStore: Omit redundant updates to avoid warnings
Bug: T353432
Change-Id: Ib095d622e549139efdd050cadc87ac9dd6a1f318
2023-12-14 10:54:16 +00:00
Subramanya Sastry d004c001be Temporarily disable isPreview in Parsoid's rendering
This will let us render reply links on wikitech and run visual diffs
(which runs in anonymous user mode). This will be reverted after
the visual diff test run.

Change-Id: Ibf175a7f5b1e68f66c257fc26ba9e4b55f752fbd
2023-12-12 14:08:46 -06:00
Subramanya Sastry 8671171b35 Remove checks for missing title info in ParserOutput extensiondata
This data was added to core in I328f533e6cdb11c0c3a873d23bab1a113dfa39be
and it will have been in production for 4 weeks next week which is
enough for all content to have rolled over.

Change-Id: I3d568eed56446f26aa329bfa554d609b8bcb973a
2023-12-12 14:08:46 -06:00
Bartosz Dziewoński cc9cccbd35 CommentParser: Replace new uses of Title with TitleValue
Follow-up to Ic718a964e309ae3a8e15e299081f46d4db860731.

Change-Id: Ida70ee080de44ec36f11c3c40816f6a198b63798
2023-12-11 22:19:13 +01:00
Bartosz Dziewoński a27e27fc68 Move finding transclusion source from ContentThreadItem to CommentParser
Reasons:
* Various other methods dealing with ranges already live there
* It would be neat if ContentThreadItem was just a value class
  without a lot of logic, similar to DatabaseThreadItem,
  particularly for writing unit tests
* The methods access global state through Title, which can't
  be fixed while they're in ContentThreadItem (see I9dfccc83)

The computation is now always done, instead of only when needed,
but that's a small drawback, since it's fast (fast enough that
I don't see the difference in the time taken when running tests),
and we were already computing it for all comments in many places.

Change-Id: Ic718a964e309ae3a8e15e299081f46d4db860731
2023-12-11 22:18:30 +01:00
Umherirrender 64bcb583e9 Use namespaced classes
Done automatically via script
Change to extension.json done manually

Change-Id: Ied7bbddd357290ac6be6bf480be0ee9116e77365
2023-12-11 16:38:02 +01:00
jenkins-bot d69dc24161 Merge "Ignore signatures with invalid timestamps" 2023-12-07 18:00:09 +00:00
Ed Sanders c82783a5b6 Find a heading by title in archives
* Looks for heading IDs matching "h-<heading text>-%" that once
  existed on the target page.
* For such IDs, finds where those items currently exist,
  presumably in an archive.

Pros:
* Doesn't need to know anything about the local wiki's archiving
  conventions, so can be deployed universally.

Cons:
* ID conflicts will return matches in unrelated archives, e.g.
  MassMessages.

Bug: T349653
Change-Id: Ie94efd0503e9f4689d3421babe445f9f4e2b4fb7
2023-12-06 18:39:28 +00:00
Ed Sanders 4733eb0362 Show new location of missing comments in notification
Bug: T304579
Change-Id: I5c9229a25875f0bb73c2a4dbfd0e1ac25f9c893e
2023-12-06 18:39:27 +00:00
Ed Sanders 4051c7faf4 Ignore signatures with invalid timestamps
Bug: T352455
Change-Id: Ie499db4594bfa23b618907383d0ac583849ff582
2023-12-05 13:23:15 +00:00
jenkins-bot 957788d9d5 Merge "Use upstream Title::inNamespace() instead of manual comparisons" 2023-12-04 23:09:28 +00:00
jenkins-bot d4d595c1b8 Merge "Check language fallbacks in isLanguageRequiringReplyIcon" 2023-12-01 21:29:23 +00:00
Ed Sanders 40ce262d7e Check language fallbacks in isLanguageRequiringReplyIcon
Bug: T352289
Change-Id: I0a1466c871143af85e7eeb07572021c387074705
2023-12-01 13:57:08 +00:00
gerritbot 5a51c63687 Update UserOptionsLookup's FQN
User-options related classes are being moved to the MediaWiki\User\Options namespace in MediaWiki Core; reflect that change here.

Bug: T352284
Depends-On: I9822eb1553870b876d0b8a927e4e86c27d83bd52
Change-Id: Iaf161106c323461929abe9b8a021bbb3e34c4ae7
2023-11-30 17:35:15 +00:00
jenkins-bot fdfc9a266e Merge "Remove small pieces of unused code from PageHooks class" 2023-11-28 20:22:10 +00:00
thiemowmde 12e7fba827 Remove small pieces of unused code from PageHooks class
Change-Id: I557bfb0f688d3e9455b5187df3cbbe67697fbd55
2023-11-28 15:39:20 +00:00
thiemowmde 00ad50c673 Use upstream Title::inNamespace() instead of manual comparisons
This might be a matter of personal preference. Not sure if it's
worth it. Both is well readable. On the other hand, the method
exists. Why not use it?

Change-Id: Id66fc6c888db6ae1cf28e60a51f90d9ae2cdb6ee
2023-11-28 09:49:00 +01:00
Subramanya Sastry bea2b1478d Work around Parsoid's messy handling of some extensions
* See T351461#9358034 for details

Bug: T351461
Change-Id: If438e99284018e3b78f4c2fc22ce714322877cf7
2023-11-28 03:00:27 +00:00
Subramanya Sastry e42450cd4f Revert "ParserOutputPostCacheTransform: Don't reprocess content"
This reverts commit 7aaaf51dfd.

Reason for revert: This is not right and doesn't work either.
See T351461#9358034 for why this strategy will not work right now.
We need a different strategy to prevent duplicate transforms if
they continue.

Change-Id: I97efee9197359ecdccdf89a0be850a707a11cc98
2023-11-26 22:06:39 -06:00
jenkins-bot 9699e57275 Merge "SpecialDiscussionToolsDebug: Replace Title::getPageViewLanguage()" 2023-11-22 21:55:13 +00:00
Subramanya Sastry 7aaaf51dfd ParserOutputPostCacheTransform: Don't reprocess content
* getText() could be called multiple times on a ParserCache object
  which would fire the ParserOutputPostCacheTransform handler
  multiple times.

  But, I could not track down how this could happen right now.

* As a separate issue, while conceptually there are no restrictions
  against calling getText() multiple times, there is a semantics and
  performance issue if that did actually happen. getText() does a
  bunch of transformations and makes no effort to avoid duplicate
  work. It will accumulate more transformations over time via the
  OutputTranform pipeline and it is preferable for getText() and/or
  the OutputTransform pipeline to guarantee semantics where the
  pipeline won't be run multiple times on the same content. That will
  free both hook handlers (like this) and the transforms themselves
  to avoid checks as in this patch.

  This patch should be reverted once such a change is made to core.

Bug: T351461
Change-Id: If5dfa0954e3fd2b7dbea1ed29b475be07f0f3986
2023-11-20 13:31:43 +00:00
jenkins-bot 43df071836 Merge "Document generated CSS classes" 2023-11-16 21:03:28 +00:00
Bartosz Dziewoński 90c6e64a49 SpecialDiscussionToolsDebug: Replace Title::getPageViewLanguage()
Bug: T350806
Change-Id: Iaf6d849867af4ce2cdc8210ae4707a6744b271dd
2023-11-10 02:44:34 +01:00
Subramanya Sastry a1c5130414 Add ParserOutputPostCacheTransformHook handler for Parsoid HTML
* This patch enables DT to work with Parsoid HTML without changing
  the functionality for legacy HTML.

* The code comments document some of the decisions being made here.
  Some of these decisions are temporary and need better solutions
  but this patch will let us run visual diff tests and expose any
  other latent bugs.

TODO
----
* We need to add new tests to verify CommentFormatter expectations
  for Parsoid HTML. I'll tackle this in a followup patch.

Known issues:
-------------
* Performance: Since the getText() transformed output in ParserOutput
  is not cached, if DiscussionTools is to switch over to Parsoid HTML,
  we have to add some form of caching of the transformed output because
  transformHtml can take a couple seconds in the p99 case which is too
  long to render uncached!

* Longer-term: Since this hook is called when getText() is
  called, all calls to getText() will now invoke this handler
  (which will return but still has to do a bunch of checks to
  determine this won't apply). Presumably, transformHtml() is
  idempotent because when some other code (other extensions, for ex)
  calls getText(), we will run the transfromHtml() on previously
  transformed content.

  My understanding is that getText() is going the way of the dodo
  and that getText() callers will have to explicit call the output
  transform pipeline code (and presumably this issue of repeatedly
  calling the same transforms on previously transformed content will
  be addressed there).

* Some CSS doesn't apply to Parsoid HTML because intervening <section>
  tags interfere with existing query selectors -- will be addressed
  separately.

Bug: T341010
Change-Id: I9846193656cdc658f5237df0a133d9d4dcc20d00
2023-11-09 18:37:56 +00:00
Ed Sanders 21e60ddeb1 Document generated CSS classes
Change-Id: I4a60e2faa81585b94b485b33ba0052a90d3f618b
2023-11-09 12:45:22 +00:00
Bartosz Dziewoński 5b1013124d ApiDiscussionToolsEdit: Remove unnecessary checks
According to EventLogging 'editattemptstep' data the error hasn't
happened in the last 90 days, and according to Logstash data the
warning hasn't happened in the last 90 days either.

The problem this guards against shouldn't be possible in a world
without RESTBase, but keep the checks as assertions just in case.

Change-Id: Id7eaf14294f8a7bb877f6a0e00a90976e560fc54
2023-11-03 16:55:06 +01:00
jenkins-bot e2f396fc99 Merge "Rewrite ImmutableRange::findCommonAncestorContainer for speed" 2023-11-02 18:41:29 +00:00
jenkins-bot 9db081c8b0 Merge "Document generated messages" 2023-11-02 17:47:18 +00:00
Ed Sanders be02707e10 Document generated messages
Change-Id: If91a32a48055b5f7d408151c7d2845f07ebd5e27
2023-11-02 16:29:54 +00:00
thiemowmde e739e6c4df Rewrite ImmutableRange::findCommonAncestorContainer for speed
While this method is not a huge bottleneck in this codebase it still
sticks out because it calls end() and array_pop() literally millions
of times. (Tested by running the unit test suite, which currently
takes about 30 seconds on my machine.)

Because of the way the method is used in this codebase (see especially
ImmutableRange::computePosition) $a is almost always a sub-element of
$b, or the other way around. It's almost never necessary to go all the
way up to the root element. We can use this additional knowledge and
stop much, much earlier. The extra code is worth it because we know it
will succeed very, very often.

When I measure the runtime of this method alone it goes down to less
than 1% of the previous runtime. The final loop at the end of the
method is almost never executed now (about 30 times in 15,000).

I also micro-benchmarked the final loop and optimized it to work with
passive array-indexes instead of actively manipulating the array with
array_pop().

Change-Id: Iffcaa8848780a85fde38e322649050c687567f29
2023-11-02 13:57:23 +01:00
jenkins-bot 048d5364e2 Merge "Replace preg_replace_callback with strtr in CommentParser" 2023-10-31 13:35:19 +00:00
thiemowmde 10dcd1f847 Replace preg_replace_callback with strtr in CommentParser
It does the same as before.

I think performance is not a concern here, and wasn't my motivation
either. But I hope this makes the code easier to read and to reason
with.

I added a pure unit test case (without involving an actual Language
object) to cover the previously uncovered digits feature.

Change-Id: I6a0fc86035817eabb42b55e58183ae094c052aa6
2023-10-31 08:55:40 +01:00