Skip to content

Commit

Permalink
Update Telegram.php
Browse files Browse the repository at this point in the history
Added check NULL update object when execute command without update using $telegram->executeCommand('command') function. This would prevent fatal error caused coming from NULL object used as an argument in setUpdate() method.
  • Loading branch information
uspilot authored and TiiFuchs committed Apr 26, 2023
1 parent 728f2f5 commit c106383
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Telegram.php
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,11 @@ public function executeCommand(string $command): ServerResponse
} else {
//execute() method is executed after preExecute()
//This is to prevent executing a DB query without a valid connection
$this->last_command_response = $command_obj->setUpdate($this->update)->preExecute();
if ($this->update) {
$this->last_command_response = $command_obj->setUpdate($this->update)->preExecute();
} else {
$this->last_command_response = $command_obj->preExecute();
}
}

return $this->last_command_response;
Expand Down

0 comments on commit c106383

Please sign in to comment.