Skip to content

Commit ed3e2f3

Browse files
authored
Fix external logout handler to process all sessions. (vufind-org#3798)
1 parent 850a345 commit ed3e2f3

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

module/VuFind/src/VuFind/Controller/ShibbolethLogoutNotificationController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,14 @@ public function postAction()
116116
*/
117117
public function logoutNotification($sessionId)
118118
{
119-
$row = $this->getDbService(ExternalSessionServiceInterface::class)->getByExternalSessionId(trim($sessionId));
120-
if ($row) {
119+
$rows = $this->getDbService(ExternalSessionServiceInterface::class)
120+
->getAllByExternalSessionId(trim($sessionId));
121+
if ($rows) {
121122
$sessionManager = $this->serviceLocator->get(\Laminas\Session\SessionManager::class);
122123
$handler = $sessionManager->getSaveHandler();
123-
$handler->destroy($row->getSessionId());
124+
foreach ($rows as $row) {
125+
$handler->destroy($row->getSessionId());
126+
}
124127
}
125128
}
126129

module/VuFind/src/VuFind/Db/Service/ExternalSessionService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ public function addSessionMapping(
8282
}
8383

8484
/**
85-
* Retrieve an object from the database based on an external session ID
85+
* Retrieve objects from the database based on an external session ID
8686
*
8787
* @param string $sid External session ID to retrieve
8888
*
89-
* @return ?ExternalSessionEntityInterface
89+
* @return ExternalSessionEntityInterface[]
9090
*/
91-
public function getByExternalSessionId(string $sid): ?ExternalSessionEntityInterface
91+
public function getAllByExternalSessionId(string $sid): array
9292
{
93-
return $this->getDbTable('ExternalSession')->select(['external_session_id' => $sid])->current();
93+
return iterator_to_array($this->getDbTable('ExternalSession')->select(['external_session_id' => $sid]));
9494
}
9595

9696
/**

module/VuFind/src/VuFind/Db/Service/ExternalSessionServiceInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ public function addSessionMapping(
6363
): ExternalSessionEntityInterface;
6464

6565
/**
66-
* Retrieve an object from the database based on an external session ID
66+
* Retrieve objects from the database based on an external session ID
6767
*
6868
* @param string $sid External session ID to retrieve
6969
*
70-
* @return ?ExternalSessionEntityInterface
70+
* @return ExternalSessionEntityInterface[]
7171
*/
72-
public function getByExternalSessionId(string $sid): ?ExternalSessionEntityInterface;
72+
public function getAllByExternalSessionId(string $sid): array;
7373

7474
/**
7575
* Destroy data for the given session ID.

module/VuFind/src/VuFind/Db/Table/ExternalSession.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ public function addSessionMapping($localSessionId, $externalSessionId)
9494
*
9595
* @return ?\VuFind\Db\Row\ExternalSession
9696
*
97-
* @deprecated Use ExternalSessionServiceInterface::getByExternalSessionId()
97+
* @deprecated Use ExternalSessionServiceInterface::getAllByExternalSessionId()
9898
*/
9999
public function getByExternalSessionId($sid)
100100
{
101-
$this->getDbService(ExternalSessionServiceInterface::class)->getByExternalSessionId($sid);
101+
$sessions = $this->getDbService(ExternalSessionServiceInterface::class)->getAllByExternalSessionId($sid);
102+
return $sessions[0] ?? null;
102103
}
103104

104105
/**

0 commit comments

Comments
 (0)