Commit graph

5 commits

Author SHA1 Message Date
Umherirrender
52a980fc0f api: Replace deprecated Hooks::run in ApiParse
Similar to OutputPageCheckLastModifiedHook,
which is also part of the ApiHookRunner

Follow-up: I5b41251ad95ea58153fb7e32dba62d407f0844ac
Change-Id: I439a208ea713e44b9603053987d9933ea6167c3a
2021-07-01 03:06:03 +00:00
C. Scott Ananian
f9433de05e api: Use GetLinkColours hook to export CSS classes in page info
Several important extensions (Disambiguator, ProofreadPage, and
SoftRedirector) use the GetLinkColours hook to add additional CSS
classes to links on article pages. Parsoid previously relied on
backdoor knowledge of the way Disambiguator used the page property
table to support these, but they should be exported properly from the
API.

Bug: T237538
Change-Id: I945940aa872541d7e01f1e543ca854231c857fe2
2020-12-14 17:51:50 -05:00
DannyS712
a7d5f4055d Remove deprecated api token hooks
Hooks removed:
APIQueryInfoTokens
APIQueryRecentChangesTokens
APIQueryRevisionsTokens
APIQueryUsersTokens
ApiTokensGetTokenTypes

Bug: T248022
Change-Id: Ieae43b05e7ba4853a3b6c7e2b03197e85a8d3579
2020-09-08 17:08:21 +00:00
Timo Tijhof
01f3efe4ff Hook: Mark abortable=false hooks as void
* Remove the mention of 'return true' being legal.
  This is only allowed for compat with code from before MW 1.21,
  when I added hook aborting as well as tolerance for null to
  be the same as true.

  Since then, there is no reason to return null or return true.
  For early returns, an explicitly void 'return;' should be used
  instead. Returning anything else like null/true serves no purpose
  other than to confuse the reader.

* Mark the interfaces as natively 'void' with return type hints.

  This means in core code that runs the hook, static analysis
  like Phan and in IDEs, it will be known that these onFoo()s
  never return a value, thus allowing them to detect if its
  return value is assigned or used in a conditional for any
  reason, which can be an easy mistake.

  It also means that in the future when extensions start using
  these interfaces in 'implements' statement, they will be
  required to mark their hooks as void.

  That migration is opt-in and still up ahead. This is not
  a breaking change even for all existing extensions where
  a return true/null may exist in an abortable hook since this
  only applies to code directly typed against the interface.
  The internal run() method doesn't care.

Change-Id: Ib79289bd486ac97cec492e72f9a8dee70cf2f6c2
2020-06-22 19:07:35 +00:00
Tim Starling
4df108429a Add HookRunner classes
These classes implement hook interfaces, providing implementations which
proxy calls to HookContainer::run().

To reduce the size of the HookRunner class, I split it into two parts:
one for the API and one for everything else. The API was the largest
identifiable component, and this matches the way we modularize i18n
files.

These two classes were originally generated by the hook interfaces
script. I've added abortable options for hooks that were
called with runWithAbort().

Bug: T240307
Change-Id: Id6789070bf830ecea271ddc74fa929e0bd39356d
2020-05-05 11:22:24 +10:00