Commit graph

7 commits

Author SHA1 Message Date
Umherirrender
e00a52e6f5 Clean up line indent with mixed tabs and whitespaces
Change-Id: Ifcd15ecc4212d4ebfc26b2e18d6f1da47abf2a86
2022-07-09 22:21:53 +02:00
Umherirrender
d79fd02d4b Use injection for LinksMigration on LinkBatch, action, api, special page
Even the service does not long stay in that classes,
it should be injected to avoid global state

Bug: T304780
Change-Id: Ib488037f5a6966ab61042ed3cd889ddc50f1ba8e
2022-05-10 20:19:58 +00:00
jenkins-bot
24aa34d06c Merge "phpcs: Disable Generic.Files.LineLength for test files" 2022-02-21 15:51:29 +00:00
Timo Tijhof
8d406bbcd6 phpcs: Disable Generic.Files.LineLength for test files
There is a common and reasonable need for longer lines in tests.
The nudge for shorter lines doesn't seem valuable here. The natural
breaks will likely still fall in 80-100 given the enforced practice
for non-test code, e.g. whether through habit, or 80-100 column markers
in text editors, or the finite width of diff and code review
interfaces.

Change-Id: I879479e13551789a67624ce66f0946d2f185e6ee
2022-02-18 18:32:05 +00:00
Ammarpad
a078ad29d5 CommentParser: Treat known titles as always known for linking
Existence of global userpages (or similar nonlocal pages)  can only be
known if the relevant title hook is involved, but LinkBatch is caching
these pages as bad links immediately after querying the local database.

CommentParser is then relying on this information to treat them as
always bad; thus preempting any further checks that might be done by
LinkRenderer to properly account for their magical existence.

Now title always-known status will be checked, to preempt bad linking.

Bug: T293665
Change-Id: Ica8733fb4a890fd2d2fc37eb85657c3715805133
2022-02-18 10:20:51 +00:00
Tim Starling
16979ecf29 Fix pollution of LinkBatch/LinkCache with interwiki link
* In LinkBatch::addObj(), reject interwiki links with a warning.
  Otherwise the link is added to the batch by ns/title and later
  reconstructed as if it were a local link without an interwiki
  prefix.
* In CommentParser, treat interwiki links as always good, don't defer
  the existence check.
* In LinkBatch, inject a LoggerInstance instead of calling LoggerFactory
  in four places.
* Add a regression test, and some general tests for known links.

Bug: T300311
Change-Id: I0e5825eb48a6ba2932aea69a4d0fff3439c50ff5
2022-01-28 10:52:38 +11:00
Tim Starling
f7f84dddb3 Introduce CommentFormatter
CommentParser:

* Move comment formatting backend from Linker to a CommentParser service.
  Allow link existence and file existence to be batched.
* Rename $local to $samePage since I think that is clearer.
* Rename $title to $selfLinkTarget since it was unclear what the title
  was used for.
* Rename the "autocomment" concept to "section link" in public
  interfaces, although the old term remains in CSS classes.
* Keep unsafe HTML pass-through in separate "unsafe" methods, for easier
  static analysis and code review.

CommentFormatter:

* Add CommentFormatter and RowCommentFormatter services as a usable
  frontend for comment batches, and to replace the Linker static methods.
* Provide fluent and parametric interfaces.

Linker:

* Remove Linker::makeCommentLink() without deprecation -- nothing calls
  it and it is obviously an internal helper.
* Soft-deprecate Linker methods formatComment(), formatLinksInComment(),
  commentBlock() and revComment().

Caller migration:

* CommentFormatter single: Linker, RollbackAction, ApiComparePages,
  ApiParse
* CommentFormatter parametric batch: ImageHistoryPseudoPager
* CommentFormatter fluent batch: ApiQueryFilearchive
* RowCommentFormatter sequential: History feed, BlocklistPager,
  ProtectedPagesPager, ApiQueryProtectedTitles
* RowCommentFormatter with index: ChangesFeed, ChangesList,
  ApiQueryDeletedrevs, ApiQueryLogEvents, ApiQueryRecentChanges
* RevisionCommentBatch: HistoryPager, ContribsPager

Bug: T285917
Change-Id: Ia3fd50a4a13138ba5003d884962da24746d562d0
2021-09-28 11:13:03 -07:00