Skip to content

Commit

Permalink
Fix undefined index errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashank Atreya committed Jan 2, 2024
1 parent 864bef2 commit 124991b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down
12 changes: 12 additions & 0 deletions src/Api/UpdateMessageApiModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ];

Expand Down

0 comments on commit 124991b

Please sign in to comment.