-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for issue 14265 #14279
Fix for issue 14265 #14279
Conversation
Codecov Report
@@ Coverage Diff @@
## 4.0.x #14279 +/- ##
==========================================
- Coverage 66.4% 66.39% -0.01%
==========================================
Files 489 489
Lines 116432 116428 -4
==========================================
- Hits 77312 77308 -4
Misses 39120 39120
Continue to review full report at Codecov.
|
@ruudboon I would like suggest something like: diff --git a/phalcon/Session/Adapter/Stream.zep b/phalcon/Session/Adapter/Stream.zep
index cb6d649f7..9f13990ea 100644
--- a/phalcon/Session/Adapter/Stream.zep
+++ b/phalcon/Session/Adapter/Stream.zep
@@ -54,10 +54,13 @@ class Stream extends Noop
*/
if !fetch path, options["savePath"] {
let path = ini_get("session.save_path");
+ if empty path {
+ let path = sys_get_temp_dir();
+ }
}
if unlikely !is_writable(path) {
- throw new Exception("The save_path [" . path . "]is not writeable");
+ throw new Exception("The session save path [" . path . "] is not writeable");
}
let this->path = Str::dirSeparator(path);
@@ -69,7 +72,9 @@ class Stream extends Noop
let file = this->path . this->getPrefixedName(id);
- if file_exists(file) && is_file(file) {
+ // is_file() will return FALSE if the given path points to
+ // a directory or there is no file.
+ if is_file(file) {
unlink(file);
}
@@ -84,9 +89,9 @@ class Stream extends Noop
time = time() - maxlifetime;
for file in glob(pattern) {
- if file_exists(file) &&
- is_file(file) &&
- (filemtime(file) < time) {
+ // is_file() will return FALSE if the given path points to
+ // a directory or there is no file.
+ if is_file(file) && (filemtime(file) < time) {
unlink(file);
}
}
@@ -96,33 +101,28 @@ class Stream extends Noop
public function open(var savePath, var sessionName) -> bool
{
- var path;
-
- if true !== ends_with(savePath, "/") {
- let path = savePath . "/";
+ if unlikely !empty savePath {
+ if ends_with(savePath, "/") {
+ let this->path = savePath;
+ } else {
+ let this->path = savePath . "/";
+ }
}
- let this->path = path;
-
return true;
}
public function read(var id) -> string
{
- var data, name;
+ var name;
- let name = this->path . this->getPrefixedName(id),
- data = "";
+ let name = this->path . this->getPrefixedName(id);
if file_exists(name) {
- let data = file_get_contents(name);
-
- if false === data {
- return "";
- }
+ return (string) file_get_contents(name);
}
- return data;
+ return "";
}
public function write(var id, var data) -> bool
Also I'm not sure about getPath. Do you need it only for testing purposes? Is it possible to achieve the same result using reflection? cphalcon/tests/_support/Helper/Unit.php Lines 103 to 112 in a0b25ed
|
@ruudboon can you please try rebasing instead of merging? |
Fixed issue #14265, added test and added method to get Path.