Skip to content
Merged
Show file tree
Hide file tree
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
70 changes: 49 additions & 21 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trigger:
- master
- stable*
event:
- pull_request
# - pull_request
- push

---
Expand Down Expand Up @@ -64,7 +64,7 @@ trigger:
- master
- stable*
event:
- pull_request
# - pull_request
- push

---
Expand Down Expand Up @@ -99,7 +99,7 @@ trigger:
- master
- stable*
event:
- pull_request
# - pull_request
- push

---
Expand Down Expand Up @@ -136,7 +136,7 @@ trigger:
- master
- stable*
event:
- pull_request
# - pull_request
- push

---
Expand Down Expand Up @@ -173,7 +173,7 @@ trigger:
- master
- stable*
event:
- pull_request
# - pull_request
- push

---
Expand Down Expand Up @@ -208,7 +208,7 @@ trigger:
- master
- stable*
event:
- pull_request
# - pull_request
- push

---
Expand Down Expand Up @@ -243,7 +243,7 @@ trigger:
- master
- stable*
event:
- pull_request
# - pull_request
- push

---
Expand Down Expand Up @@ -279,7 +279,11 @@ services:
MYSQL_USER: oc_autotest
MYSQL_PASSWORD: owncloud
MYSQL_DATABASE: oc_autotest
command: [ "--innodb_large_prefix=true", "--innodb_file_format=barracuda", "--innodb_file_per_table=true" ]
command:
- --innodb_large_prefix=true
- --innodb_file_format=barracuda
- --innodb_file_per_table=true
- --sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
tmpfs:
- /var/lib/mysql

Expand All @@ -288,7 +292,7 @@ trigger:
- master
- stable*
event:
# - pull_request
- pull_request
- push

---
Expand Down Expand Up @@ -324,7 +328,11 @@ services:
MYSQL_USER: oc_autotest
MYSQL_PASSWORD: owncloud
MYSQL_DATABASE: oc_autotest
command: [ "--innodb_large_prefix=true", "--innodb_file_format=barracuda", "--innodb_file_per_table=true" ]
command:
- --innodb_large_prefix=true
- --innodb_file_format=barracuda
- --innodb_file_per_table=true
- --sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
tmpfs:
- /var/lib/mysql

Expand All @@ -333,7 +341,7 @@ trigger:
- master
- stable*
event:
# - pull_request
- pull_request
- push

---
Expand Down Expand Up @@ -369,7 +377,11 @@ services:
MYSQL_USER: oc_autotest
MYSQL_PASSWORD: owncloud
MYSQL_DATABASE: oc_autotest
command: [ "--innodb_large_prefix=true", "--innodb_file_format=barracuda", "--innodb_file_per_table=true" ]
command:
- --innodb_large_prefix=true
- --innodb_file_format=barracuda
- --innodb_file_per_table=true
- --sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
tmpfs:
- /var/lib/mysql

Expand All @@ -378,7 +390,7 @@ trigger:
- master
- stable*
event:
# - pull_request
- pull_request
- push

---
Expand Down Expand Up @@ -416,7 +428,11 @@ services:
MYSQL_USER: oc_autotest
MYSQL_PASSWORD: owncloud
MYSQL_DATABASE: oc_autotest
command: [ "--innodb_large_prefix=true", "--innodb_file_format=barracuda", "--innodb_file_per_table=true" ]
command:
- --innodb_large_prefix=true
- --innodb_file_format=barracuda
- --innodb_file_per_table=true
- --sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
tmpfs:
- /var/lib/mysql

Expand All @@ -425,7 +441,7 @@ trigger:
- master
- stable*
event:
# - pull_request
- pull_request
- push

---
Expand Down Expand Up @@ -463,7 +479,11 @@ services:
MYSQL_USER: oc_autotest
MYSQL_PASSWORD: owncloud
MYSQL_DATABASE: oc_autotest
command: [ "--innodb_large_prefix=true", "--innodb_file_format=barracuda", "--innodb_file_per_table=true" ]
command:
- --innodb_large_prefix=true
- --innodb_file_format=barracuda
- --innodb_file_per_table=true
- --sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
tmpfs:
- /var/lib/mysql

Expand All @@ -472,7 +492,7 @@ trigger:
- master
- stable*
event:
# - pull_request
- pull_request
- push

---
Expand Down Expand Up @@ -508,7 +528,11 @@ services:
MYSQL_USER: oc_autotest
MYSQL_PASSWORD: owncloud
MYSQL_DATABASE: oc_autotest
command: [ "--innodb_large_prefix=true", "--innodb_file_format=barracuda", "--innodb_file_per_table=true" ]
command:
- --innodb_large_prefix=true
- --innodb_file_format=barracuda
- --innodb_file_per_table=true
- --sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
tmpfs:
- /var/lib/mysql

Expand All @@ -517,7 +541,7 @@ trigger:
- master
- stable*
event:
# - pull_request
- pull_request
- push

---
Expand Down Expand Up @@ -553,7 +577,11 @@ services:
MYSQL_USER: oc_autotest
MYSQL_PASSWORD: owncloud
MYSQL_DATABASE: oc_autotest
command: [ "--innodb_large_prefix=true", "--innodb_file_format=barracuda", "--innodb_file_per_table=true" ]
command:
- --innodb_large_prefix=true
- --innodb_file_format=barracuda
- --innodb_file_per_table=true
- --sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
tmpfs:
- /var/lib/mysql

Expand All @@ -562,7 +590,7 @@ trigger:
- master
- stable*
event:
# - pull_request
- pull_request
- push

---
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5

steps:
- name: Enable ONLY_FULL_GROUP_BY MySQL option
run: |
echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword

- name: Checkout server
uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion lib/Chat/MessageParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function setActor(Message $message): void {
$displayName = $this->guestNames[$comment->getActorId()];
} else {
try {
$participant = $message->getRoom()->getParticipantByActor(Attendee::ACTOR_GUESTS, $comment->getActorId(), false);
$participant = $message->getRoom()->getParticipantByActor(Attendee::ACTOR_GUESTS, $comment->getActorId());
$displayName = $participant->getAttendee()->getDisplayName();
} catch (ParticipantNotFoundException $e) {
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ protected function getGuest(Room $room, string $actorId): array {

protected function getGuestName(Room $room, string $actorId): string {
try {
$participant = $room->getParticipantByActor(Attendee::ACTOR_GUESTS, $actorId, false);
$participant = $room->getParticipantByActor(Attendee::ACTOR_GUESTS, $actorId);
$name = $participant->getAttendee()->getDisplayName();
if ($name === '') {
return $this->l->t('Guest');
Expand Down
2 changes: 1 addition & 1 deletion lib/Chat/Parser/UserMention.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function parseMessage(Message $chatMessage): void {
];
} elseif ($mention['type'] === 'guest') {
try {
$participant = $chatMessage->getRoom()->getParticipantByActor(Attendee::ACTOR_GUESTS, substr($mention['id'], strlen('guest/')), false);
$participant = $chatMessage->getRoom()->getParticipantByActor(Attendee::ACTOR_GUESTS, substr($mention['id'], strlen('guest/')));
$displayName = $participant->getAttendee()->getDisplayName() ?: $this->l->t('Guest');
} catch (ParticipantNotFoundException $e) {
$displayName = $this->l->t('Guest');
Expand Down
11 changes: 2 additions & 9 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1508,15 +1508,8 @@ protected function changeParticipantType(int $attendeeId, bool $promote): DataR
}

// Prevent users/moderators modifying themselves
if ($attendee->getActorType() === Attendee::ACTOR_USERS) {
if ($attendee->getActorId() === $this->userId) {
return new DataResponse([], Http::STATUS_FORBIDDEN);
}
} elseif ($attendee->getActorType() === Attendee::ACTOR_GUESTS) {
$session = $targetParticipant->getSession();
$currentSessionId = $this->session->getSessionForRoom($this->room->getToken());

if ($session instanceof Session && $currentSessionId === $session->getSessionId()) {
if ($attendee->getActorType() === $this->participant->getAttendee()->getActorType()) {
if ($attendee->getActorId() === $this->participant->getAttendee()->getActorId()) {
return new DataResponse([], Http::STATUS_FORBIDDEN);
}
} elseif ($attendee->getActorType() === Attendee::ACTOR_GROUPS) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/SignalingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,14 @@ private function backendRoom(array $roomRequest): DataResponse {
// If the user joins the session might not be known to the server yet.
// In this case we load by actor information and use the session id as new session.
try {
$participant = $room->getParticipantByActor($actorType, $actorId, false);
$participant = $room->getParticipantByActor($actorType, $actorId);
} catch (ParticipantNotFoundException $e) {
}
}
}
} else {
try {
$participant = $room->getParticipantByActor($actorType, $actorId, false);
$participant = $room->getParticipantByActor($actorType, $actorId);
} catch (ParticipantNotFoundException $e) {
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ protected function parseChatMessage(INotification $notification, Room $room, Par
* @throws ParticipantNotFoundException
*/
protected function getGuestParameter(Room $room, string $actorId): array {
$participant = $room->getParticipantByActor(Attendee::ACTOR_GUESTS, $actorId, false);
$participant = $room->getParticipantByActor(Attendee::ACTOR_GUESTS, $actorId);
$name = $participant->getAttendee()->getDisplayName();
if (trim($name) === '') {
throw new ParticipantNotFoundException('Empty name');
Expand Down
40 changes: 3 additions & 37 deletions lib/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,10 @@ public function getParticipantByPin(string $pin): Participant {

/**
* @param int $attendeeId
* @param string|null|false $sessionId Set to false if you don't want to load a session (and save resources),
* string to try loading a specific session
* null to try loading "any"
* @return Participant
* @throws ParticipantNotFoundException When the pin is not valid (has no participant assigned)
*/
public function getParticipantByAttendeeId(int $attendeeId, $sessionId = null): Participant {
public function getParticipantByAttendeeId(int $attendeeId): Participant {
$query = $this->db->getQueryBuilder();
$helper = new SelectHelper();
$helper->selectAttendeesTable($query);
Expand All @@ -574,20 +571,6 @@ public function getParticipantByAttendeeId(int $attendeeId, $sessionId = null):
->andWhere($query->expr()->eq('a.room_id', $query->createNamedParameter($this->getId())))
->setMaxResults(1);

if ($sessionId !== false) {
if ($sessionId !== null) {
$helper->selectSessionsTable($query);
$query->leftJoin('a', 'talk_sessions', 's', $query->expr()->andX(
$query->expr()->eq('s.session_id', $query->createNamedParameter($sessionId)),
$query->expr()->eq('a.id', 's.attendee_id')
));
} else {
$helper->selectSessionsTableMax($query);
$query->groupBy('a.id');
$query->leftJoin('a', 'talk_sessions', 's', $query->expr()->eq('a.id', 's.attendee_id'));
}
}

$result = $query->executeQuery();
$row = $result->fetch();
$result->closeCursor();
Expand All @@ -602,15 +585,12 @@ public function getParticipantByAttendeeId(int $attendeeId, $sessionId = null):
/**
* @param string $actorType
* @param string $actorId
* @param string|null|false $sessionId Set to false if you don't want to load a session (and save resources),
* string to try loading a specific session
* null to try loading "any"
* @return Participant
* @throws ParticipantNotFoundException When the pin is not valid (has no participant assigned)
*/
public function getParticipantByActor(string $actorType, string $actorId, $sessionId = null): Participant {
public function getParticipantByActor(string $actorType, string $actorId): Participant {
if ($actorType === Attendee::ACTOR_USERS) {
return $this->getParticipant($actorId, $sessionId);
return $this->getParticipant($actorId, false);
}

$query = $this->db->getQueryBuilder();
Expand All @@ -622,20 +602,6 @@ public function getParticipantByActor(string $actorType, string $actorId, $sessi
->andWhere($query->expr()->eq('a.room_id', $query->createNamedParameter($this->getId())))
->setMaxResults(1);

if ($sessionId !== false) {
if ($sessionId !== null) {
$helper->selectSessionsTable($query);
$query->leftJoin('a', 'talk_sessions', 's', $query->expr()->andX(
$query->expr()->eq('s.session_id', $query->createNamedParameter($sessionId)),
$query->expr()->eq('a.id', 's.attendee_id')
));
} else {
$helper->selectSessionsTableMax($query);
$query->groupBy('a.id');
$query->leftJoin('a', 'talk_sessions', 's', $query->expr()->eq('a.id', 's.attendee_id'));
}
}

$result = $query->executeQuery();
$row = $result->fetch();
$result->closeCursor();
Expand Down
Loading