Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Sessions: SessionConfig does not allow setting non-directory save path #2932

Closed
wants to merge 2 commits into from

2 participants

@mwillbanks
Collaborator

The StandardConfig defines that the only way to specify a savePath is to utilize a directory. The SessionConfig then requires the savePath to be a directory since it inherits from the StandardConfig.

This pull request is to check in SessionConfig to see if the save_handler option is "files" and issue the set to the parent otherwise to skip checking.

This means it will allow the following use cases:
files => /path/to/directory
sqlite => /path/to/my.db
memcached => sess1:11211, sess2:11211
redis => tcp://0.0.0.0:6379

@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#2932] different save_handler in tests
- "sqlite" save handler is not installed by default; changed test to use
  "user" save handler instead
9bd84cd
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#2932] different save_handler in tests
- "sqlite" save handler is not installed by default; changed test to use
  "user" save handler instead
889964e
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/2932'
Close #2932
5de135e
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/2932' into develop
Forward port #2932
e1dee3f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
18 library/Zend/Session/Config/SessionConfig.php
@@ -148,6 +148,24 @@ public function setPhpSaveHandler($phpSaveHandler)
}
/**
+ * Set session.save_path
+ *
+ * @param string $savePath
+ * @return SessionConfig
+ * @throws Exception\InvalidArgumentException on invalid path
+ */
+ public function setSavePath($savePath)
+ {
+ if ($this->getOption('save_handler') == 'files') {
+ parent::setSavePath($savePath);
+ }
+ $this->savePath = $savePath;
+ $this->setOption('save_path', $savePath);
+ return $this;
+ }
+
+
+ /**
* Set session.serialize_handler
*
* @param string $serializeHandler
View
6 tests/ZendTest/Session/Config/SessionConfigTest.php
@@ -56,6 +56,12 @@ public function testSavePathAltersIniSetting()
$this->assertEquals(__DIR__, ini_get('session.save_path'));
}
+ public function testSavePathCanBeNonDirectoryWhenSaveHandlerNotFiles()
+ {
+ $this->config->setPhpSaveHandler('sqlite');
+ $this->config->setSavePath('/tmp/sessions.db');
+ }
+
// session.name
public function testNameDefaultsToIniSettings()
Something went wrong with that request. Please try again.