Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lib/MatterbridgeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,32 @@ private function cleanUrl(string $url): string {
private function checkBridgeProcess(Room $room, array $bridge, bool $relaunch = true): int {
$pid = 0;

// check if current $bridge parts (domain) are still valid before doing anything
try {
$this->validateParts($bridge); // no return needed, validateParts will throw exception

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be validateParts($bridge[parts]) otherwise validation always fails (on my machine at least.
$bridge looks like: ['enabled' => false, 'pid' => 0, 'parts' => []]
The validator only wants the [] inside 'parts'. (

if ($part['skiptls']) {
$content .= ' SkipTLSVerify = true' . "\n";
}
$content .= ' PrefixMessagesWithNick = true' . "\n";
$content .= ' RemoteNickFormat = "[{PROTOCOL}] <{NICK}> "' . "\n\n";
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you very much for your report!
This indeed slipped my tests before, but I confirmed the parts is missing here.
I created a new PR and will backport:
#20052

} catch (\InvalidArgumentException $e) {
$this->logger->error($e->getMessage());

// if the pid is set, kill the process and set it to disabled in the database
if (isset($bridge['pid']) && (int)$bridge['pid'] !== 0) {
if ($this->isRunning($bridge['pid'])) {
$this->killPid($bridge['pid']);
}

$query = $this->db->getQueryBuilder();
$query->update('talk_bridges')
->set('enabled', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))
->set('pid', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))
->where($query->expr()->eq(
'pid',
$query->createNamedParameter($bridge['pid'], IQueryBuilder::PARAM_INT)));
$result = $query->executeQuery();
$result->closeCursor();

}
return $pid; // pid remains unchanged 0, i.e. no process with invalid parts running
}

if (isset($bridge['pid']) && (int)$bridge['pid'] !== 0) {
// config : there is a PID stored
$isRunning = $this->isRunning($bridge['pid']);
Expand Down
Loading