diff --git a/i18n/en.json b/i18n/en.json index af9ac7a..0de7d88 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -39,6 +39,8 @@ "liquipediamediawikimessages-column-delete": "Delete", "apihelp-updatelpmwmessageapi-summary": "API Helper to update LiquipediaMediaWikiMessages message values", + "liquipediamediawikimessages-api-error-missing-messagename": "Missing parameter 'messagename'. It should be passed via POST", + "liquipediamediawikimessages-api-error-missing-value": "Missing parameter 'value'. It should be passed via POST", "liquipediamediawikimessages-api-message-name": "Message name to update the value for", "liquipediamediawikimessages-api-message-value": "Value for the particular message defined before", "liquipediamediawikimessages-api-example": "Example:", diff --git a/src/Api/UpdateMessageApiModule.php b/src/Api/UpdateMessageApiModule.php index 02e31ba..c0d7d21 100644 --- a/src/Api/UpdateMessageApiModule.php +++ b/src/Api/UpdateMessageApiModule.php @@ -14,6 +14,18 @@ class UpdateMessageApiModule extends ApiBase { */ public function execute() { $postValues = $this->getRequest()->getPostValues(); + if ( !array_key_exists( 'messagename', $postValues ) ) { + $this->getResult()->addValue( null, $this->getModuleName(), [ + 'message' => $this->msg( 'liquipediamediawikimessages-api-error-missing-messagename' ) + ] ); + return; + } + if ( !array_key_exists( 'value', $postValues ) ) { + $this->getResult()->addValue( null, $this->getModuleName(), [ + 'message' => $this->msg( 'liquipediamediawikimessages-api-error-missing-value' ) + ] ); + return; + } $messageName = $postValues[ 'messagename' ]; $value = $postValues[ 'value' ];