Skip to content

Commit

Permalink
Merge pull request #1123 from wagnert/1.1
Browse files Browse the repository at this point in the history
Fixed concurrent session errors
  • Loading branch information
wagnert authored May 23, 2019
2 parents 48146f4 + c709346 commit 325f532
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 14 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Version 1.1.22

## Bugfixes

* Fixed concurrent session errors
* Update to appserver-io/ldap version 2.0.1

## Features

* None

# Version 1.1.21

## Bugfixes
Expand Down
3 changes: 3 additions & 0 deletions UPGRADE-1.1.22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Upgrade from 1.1.21 to 1.1.22

Updating from 1.1.21 to 1.1.22 doesn't have any impacts. Please read the apropriate UPGRADE-1.x.x files for updates from older versions to 1.1.22.
2 changes: 1 addition & 1 deletion build.default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
;--------------------------------------------------------------------------------

; ---- Module Release Settings --------------------------------------------------
release.version = 1.1.21
release.version = 1.1.22
release.name = Iron Knight

; ---- PHPCPD Settings ----------------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,57 @@ public function save(ServletSessionInterface $session)
$marshalledSession = $this->marshall($session);

// decode the session from the filesystem
$fh = fopen($sessionFilename, 'w+');
$fh = fopen($sessionFilename, 'c');

// try to lock the session file
if (flock($fh, LOCK_EX) === false) {
throw new SessionCanNotBeSavedException(sprintf('Can\'t get lock to save session data to file "%s"', $sessionFilename));
throw new SessionCanNotBeSavedException(
sprintf(
'Can\'t get lock to save session data to file "%s"',
$sessionFilename
)
);
}

// try to truncate the session file
if (ftruncate($fh, 0) === false) {
throw new SessionCanNotBeSavedException(
sprintf(
'Can\'t truncate session file "%s"',
$sessionFilename
)
);
}

// finally try to write the session data to the file
if (fwrite($fh, $marshalledSession) === false) {
throw new SessionCanNotBeSavedException(sprintf('Session with ID "%s" can\'t be saved', $session->getId()));
throw new SessionCanNotBeSavedException(
sprintf(
'Session with ID "%s" can\'t be saved to file "%s"',
$session->getId(),
$sessionFilename
)
);
}

// try to unlock the session file
if (flock($fh, LOCK_UN) === false) {
throw new SessionCanNotBeSavedException(sprintf('Can\'t unlock session file "%s" after saving data', $sessionFilename));
throw new SessionCanNotBeSavedException(
sprintf(
'Can\'t unlock session file "%s" after saving data',
$sessionFilename
)
);
}

// try to close the session file
if (fclose($fh) === false) {
throw new SessionCanNotBeSavedException(
sprintf(
'Can\'t close session file "%s" after saving data',
$sessionFilename
)
);
}
}

Expand Down Expand Up @@ -151,7 +187,12 @@ protected function unpersist($pathname)

// try to lock the session file
if (flock($fh, LOCK_EX) === false) {
throw new SessionDataNotReadableException(sprintf('Can\'t get lock to load session data from file "%s"', $pathname));
throw new SessionDataNotReadableException(
sprintf(
'Can\'t get lock to load session data from file "%s"',
$pathname
)
);
}

// read the marshalled session data from the file
Expand All @@ -161,12 +202,22 @@ protected function unpersist($pathname)

// try to unlock the session file
if (flock($fh, LOCK_UN) === false) {
throw new SessionDataNotReadableException(sprintf('Can\'t unlock session file "%s" after reading data', $pathname));
throw new SessionDataNotReadableException(
sprintf(
'Can\'t unlock session file "%s" after reading data',
$pathname
)
);
}

// query whether or not the session has been unmarshalled successfully
if ($marshalled === null) {
throw new SessionDataNotReadableException(sprintf('Can\'t load any session data from file %s', $pathname));
throw new SessionDataNotReadableException(
sprintf(
'Can\'t load any session data from file %s',
$pathname
)
);
}

// unmarshall and return the session data
Expand Down

0 comments on commit 325f532

Please sign in to comment.