Merge "Allow hook implementations to modify params"

This commit is contained in:
jenkins-bot 2022-03-31 12:41:49 +00:00 committed by Gerrit Code Review
commit 4bd4410b7b
3 changed files with 8 additions and 6 deletions

View file

@ -24,8 +24,9 @@ interface VisualEditorApiVisualEditorEditPreSaveHook {
* @param ProperPageIdentity $page The page identity of the title used in the save attempt.
* @param UserIdentity $user User associated with the save attempt.
* @param string $wikitext The wikitext used in the save attempt.
* @param array $params The params passed by the client in the API request. See
* ApiVisualEditorEdit::getAllowedParams()
* @param array &$params The params passed by the client in the API request. See
* ApiVisualEditorEdit::getAllowedParams(). Note that these params are then passed on to ApiEditPage, so
* the array is modifiable in case the hook implementer needs to adjust any of the parameters.
* @param array $pluginData Associative array containing additional data specified by plugins, where the keys of
* the array are plugin names, and the value are arbitrary data. Plugins are expected to be in a one-to-one
* correlation with hook handlers and can be specified via the 'plugins' and 'data-*' parameters of the API.
@ -44,7 +45,7 @@ interface VisualEditorApiVisualEditorEditPreSaveHook {
ProperPageIdentity $page,
UserIdentity $user,
string $wikitext,
array $params,
array &$params,
array $pluginData,
array &$apiResponse
);

View file

@ -40,7 +40,7 @@ class VisualEditorHookRunner implements
ProperPageIdentity $page,
UserIdentity $user,
string $wikitext,
array $params,
array &$params,
array $pluginData,
array &$apiResponse
) {
@ -48,7 +48,7 @@ class VisualEditorHookRunner implements
$page,
$user,
$wikitext,
$params,
&$params,
$pluginData,
&$apiResponse
], [ 'abortable' => true ] );

View file

@ -26,11 +26,12 @@ class VisualEditorHookRunnerTest extends MediaWikiUnitTestCase {
$runner = new VisualEditorHookRunner( $container );
$apiResponse = [];
$params = [];
$result = $runner->onVisualEditorApiVisualEditorEditPreSave(
PageIdentityValue::localIdentity( 0, 0, 'test' ),
UserIdentityValue::newAnonymous( '' ),
'',
[],
$params,
[],
$apiResponse
);