Skip to content

Commit

Permalink
Merge pull request #1457 from AkramiPro/develop
Browse files Browse the repository at this point in the history
Fix PHP Error - Call to a member function getChat() on null
  • Loading branch information
noplanman authored May 24, 2024
2 parents 8a985c8 + d386abf commit 784c209
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Commands/AdminCommands/ChatsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ChatsCommand extends AdminCommand
*/
public function execute(): ServerResponse
{
$message = $this->getMessage();
$message = $this->getMessage() ?: $this->getEditedMessage() ?: $this->getChannelPost() ?: $this->getEditedChannelPost();

$chat_id = $message->getChat()->getId();
$text = trim($message->getText(true));
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/AdminCommands/CleanupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public function executeNoDb(): ServerResponse
*/
public function execute(): ServerResponse
{
$message = $this->getMessage();
$message = $this->getMessage() ?: $this->getEditedMessage() ?: $this->getChannelPost() ?: $this->getEditedChannelPost();
$text = $message->getText(true);

// Dry run?
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/AdminCommands/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DebugCommand extends AdminCommand
public function execute(): ServerResponse
{
$pdo = DB::getPdo();
$message = $this->getMessage();
$message = $this->getMessage() ?: $this->getEditedMessage() ?: $this->getChannelPost() ?: $this->getEditedChannelPost();
$chat = $message->getChat();
$text = strtolower($message->getText(true));

Expand Down
4 changes: 2 additions & 2 deletions src/Commands/AdminCommands/SendtochannelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SendtochannelCommand extends AdminCommand
*/
public function execute(): ServerResponse
{
$message = $this->getMessage();
$message = $this->getMessage() ?: $this->getEditedMessage() ?: $this->getChannelPost() ?: $this->getEditedChannelPost();
$chat_id = $message->getChat()->getId();
$user_id = $message->getFrom()->getId();

Expand Down Expand Up @@ -359,7 +359,7 @@ protected function publish(Message $message, $channel_id, $caption = null): stri
*/
public function executeNoDb(): ServerResponse
{
$message = $this->getMessage();
$message = $this->getMessage() ?: $this->getEditedMessage() ?: $this->getChannelPost() ?: $this->getEditedChannelPost();
$text = trim($message->getText(true));

if ($text === '') {
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/AdminCommands/WhoisCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class WhoisCommand extends AdminCommand
*/
public function execute(): ServerResponse
{
$message = $this->getMessage();
$message = $this->getMessage() ?: $this->getEditedMessage() ?: $this->getChannelPost() ?: $this->getEditedChannelPost();

$chat_id = $message->getChat()->getId();
$command = $message->getCommand();
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function preExecute(): ServerResponse
}

if ($this->isPrivateOnly() && $this->removeNonPrivateMessage()) {
$message = $this->getMessage();
$message = $this->getMessage() ?: $this->getEditedMessage() ?: $this->getChannelPost() ?: $this->getEditedChannelPost();

if ($user = $message->getFrom()) {
return Request::sendMessage([
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/SystemCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function execute(): ServerResponse
*/
protected function executeActiveConversation(): ?ServerResponse
{
$message = $this->getMessage();
$message = $this->getMessage() ?: $this->getEditedMessage() ?: $this->getChannelPost() ?: $this->getEditedChannelPost();
if ($message === null) {
return null;
}
Expand Down Expand Up @@ -84,7 +84,7 @@ protected function executeActiveConversation(): ?ServerResponse
*/
protected function executeDeprecatedSystemCommand(): ?ServerResponse
{
$message = $this->getMessage();
$message = $this->getMessage() ?: $this->getEditedMessage() ?: $this->getChannelPost() ?: $this->getEditedChannelPost();
if ($message === null) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/UserCommands/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class StartCommand extends UserCommand
*/
public function execute(): ServerResponse
{
//$message = $this->getMessage();
//$message = $this->getMessage() ?: $this->getEditedMessage() ?: $this->getChannelPost() ?: $this->getEditedChannelPost();
//$chat_id = $message->getChat()->getId();
//$user_id = $message->getFrom()->getId();

Expand Down

0 comments on commit 784c209

Please sign in to comment.