The HookRunner class is a lightweight class and not designed to be a
service, the needed HookContainer should be injected instead and a hook
runner created when needed.
The overhead from the service wiring is the same as using new objects
when needed.
This follows practice from core and the documentation in
core/docs/Hooks.md in the section "Hook runner classes"
Change-Id: Ib42281dfae8a5a260005d82ed3bb7da12e1b645e
We diff only on provided wikitext. This was causing inaccurate diffs on
pages with slotted content (e.g. File: pages on commons), which would
claim the edit would delete all the slot contents other than the
wikitext in main.
Also, remove the very old backwards compatibility params that were being
passed to getResultData in this method.
Bug: T351235
Change-Id: I135082162b96503e8d896aa4014abc9f4b936580
- The code in the hook handler is more related to the hook and the
structure of the $links array as to the special page.
- Loading another class to process the hook is not necessary.
- Allows better migration to new hook handlers (special page classes and
hook handler should be separated).
- Replace SpecialCollabPad::getSubPage with
SpecialPageFactory::resolveAlias.
- The local url to Special:CollabPad is now in the content language
(only relevant for non-english wikis).
Change-Id: I82985a8ba129b4e336cee337af31452e804090b3
Why:
ApiVisualEditorEdit passes most of its params down to
action=edit. However, $params contains parsed version
of the params. Using it with tags results in the param
validator logic on ApiEdit's end receiving a PHP array,
which it does not expect (neither it should; it is impossible
to pass one via an actual API call).
This feature will be used in DiscussionTools,
which itself reuses ApiVisualEditorEdit.
What:
Use WebRequest::getText() to get the unparsed
value for 'tags', which makes the parameter
forwarding actually work.
Bug: T343339
Change-Id: I0ac60ca8473fe28461b2da60f9911baac4994388
This reverts a change from 5a792b6558. The hook only requires
a PageIdentity, and we only used toPageRecord() because it takes
a parameter to read latest data, and toPageIdentity() does not.
Instead call another method to update the internal data within the
Title instance. Maybe it's not great to rely on this side-effect…
Bug: T340568
Change-Id: If9cbd95eb84b6c39bf50af4564710839628a9bc3
Sometimes we call this API and then reload the page (or navigate to
another URL), without using the page content it returns. Save some
work and some data transfer and don't generate it in those cases.
Change-Id: Ic5fac61f3ef9b2dfce6ff757f1d414a9f41f217d
There are no occurrences of the error message in our error logging
data, so it most likely can never happen.
https://superset.wikimedia.org/superset/sqllab/
```
select count(*)
from editattemptstep
where event.save_failure_message = 'visualeditor-docserver'
```
Change-Id: I8172564057418283468c657cbc6d42ce8ddb35f4
More could be done, but these are the ones that annoy me the most,
and I'm not willing to do more changes right now.
Change-Id: Ia02af09d631fea191e57da75420f0d2d1ed46c19
We want to be able to measure how backend performance changes
when we switch from RESTbase to calling Parsoid directly.
We expect to see a performance boost, in particular for
html/to/wikitext, since we avoid the network overhead.
Since we will make the switch by wiki, we need to be able to compare
the metric before vs. after for a single wiki. So, this adds the
wiki ID as a prefix to all existing metrics. Once fully rolled out,
we should get rid of the wiki prefix.
We will need to update the dashboard found at this url:
https://grafana.wikimedia.org/d/000000249/edit-stash?orgId=1
Change-Id: Iac9070b27f4b0d25b0e31c9fad38abc08c433a28
All code that used to live in ParsoidHelper has been moved to
VisualEditorParsoidClientFactory and VRSParsoidClient.
ParsoidHelper is no longer needed.
Change-Id: I21c4a8cd86f8d085e75a601ed6d2509dedd75d42
Introduced in FlaggedRevs with Idbdab9a7396 (6bfd276e64), and I've
migrated consumers away from the singleton in I192b962147 (5ee96e5ca7)
and I04fdbd497b8 (bbdfc4c024).
The one thing that remains global by default is the context, but
VE already avoids that with setContext, and (correctly) restores this
afterward since the FlaggablePageView object is re-used by title.
That's exactly as terrible as it sounds, but at least it's a bit more
visible after my refactor.
Bug: T314008
Change-Id: I0008818ec821c35c570d9db9c82f737783e6729b
Remove WikiFilePage instance check, isLocal exists also on WikiPage and
newFromTitle never returns null
Bug: T297688
Change-Id: I925771a84afe4402fdb0f201c0b562c7028c44b2
This also matches the current code in OutputPage::setPageTitle()
Depends-On: Ic864c01471c292f11799c4fbdac4d7d30b8bc50f
Change-Id: I018b34bb5f6e113056da9b04cc72d4318422adce
Passing the useskin parameter ensures that output hooks are run
on the new page HTML. This already happens because we request
the 'subtitle' and 'categorieshtml' props which also trigger
skin mode (along with the 'headhtml' which we don't request).
However it is better for us to be explicit that we want the rendering
for a specific skin, rather than relying on these props to trigger
the correct mode.
Also pass through mobileformat param, which is added by a hook
in MobileFrontend.
Change-Id: I1cd2c5c5c13ae0b90cc32e441b453532343a434a
Specifying it as such creates a 0 based index for what is a single value
property. This wasn't noticed before because I6b81ea318f52e accessed the
request object directly instead of using $params. See also
I3baa1ebb66559 for how this bug manifested in GrowthExperiments.
Bug: T289652
Change-Id: Ife8350d1cea79fc1dd6f3cb040a7801b9fe6db91
What:
Add a hook that runs before a save attempt is made in
ApiVisualEditorEdit. The hook receives the same data available in
ApiVisualEditorEdit, and implementations of the hook can modify the API
response.
Why:
VE plugins may send additional data when saving an edit, and extensions
might want to prevent the save from taking place based on that
additional data.
See for example the AddLink plugin in Ic8225933c9, where the save is
blocked if link suggestions don't exist in the database at save time.
Bug: T283109
Change-Id: I6b81ea318f52ec47661086d85b5cc242a3fcd0e4
* Mismatching capitalization.
* Unused pieces of code.
* Properties that can be constants.
* Use $this->getConfig() in special pages.
Change-Id: Ia7e2c438c5ddd3c770070701e4cbdfc79fccf009
What:
Add hook that runs after a save attempt is made in ApiVisualEditorEdit.
The hook receives the same data available in ApiVisualEditorEdit, and
implementations of the hook can modify the API response.
Also introduce templated
parameters (https://www.mediawiki.org/wiki/API:Templated_parameters) in
the API parameters; this allows plugins to pass arbitrary data along
with their request using e.g. plugins=linkrecommendation&data-linkrecommendation=foo
Add ServiceWiring files, a PHP namespace, and a HookRunner class to
support the above changes.
Why:
VE plugins may wish to send additional data when saving an edit and take
action based on that data on the server-side. See for example the
AddLink plugin in I7a052f8e which sends annotation data, and then uses
the new hook to perform a database operation.
Change-Id: I392691475fbdcec766acbd832600e82efcb5bfe8
Otherwise, the global context is used (RequestContext::getMain()),
which is undesirable when you're building a rubegoldbergian
contraption and we're already inside an internal action API request
with a fake context.
Change-Id: I66e79e641eda185f7af2561d3655c92cba762135
isRegistered is part of the slick UserIdentity interface, i.e.
it's the more "canonical" form. This change makes it a bit
easier to move away from using the huge (4000+ LOC) User class
everywhere, in favor of the UserIdentity interface, where
possible.
This patch is meant as a small step towards this goal. I tried
to replace some usages of User type hints already, but prefer
to go in small, incremental steps.
Change-Id: I827b83a5304b1975437d5fd5083f2877dba6f6d8
Although wikitext is (expected to be) in Unicode Normalization Form C,
the output HTML may not be, due to the presence of explicit entities in
the wikitext representing non-NFC codepoints.
Bug: T266140
Depends-On: I2e78e660ba1867744e34eda7d00ea527ec016b71
Change-Id: I0d34c9a01f1132c2616ed3392ea40d8b73e15325
This patch starts using watchlist related values from ApiEditPage
results instead of updating the "watch link" based on whether the
checkbox was selected or not at the time of saving the article.
This change does not depend on T261030 and can be merged without it
but T261030 needs to be fixed or temporarily watched items will not
display the right tooltip when hovering the "watch link" or star icon.
Bug: T260434
Change-Id: I2c844223620d7d28f36a0cd8ae3dee4b0c8ae5bf
The output is assumed to be the same as you would get if you
fetched the page again, so this output-modifying hook needs to run.
Bug: T258980
Change-Id: I015ac183a0c25dafb9b95c577edd4ef59c112d43